Compare commits
12 Commits
2026-05
...
b1cbc3d304
| Author | SHA1 | Date | |
|---|---|---|---|
| b1cbc3d304 | |||
| 08fd57ada1 | |||
| f9c826ffea | |||
| 55fd3df55d | |||
| 7c8e7d1b7e | |||
| a6228faaba | |||
| 92b7d3cd73 | |||
| e7519e5524 | |||
| ef80aff151 | |||
| 81f90ce0f2 | |||
| 8622f25048 | |||
| 3dff953b8d |
12
.gitignore
vendored
12
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
node_modules
|
||||
docs/
|
||||
.worktrees/
|
||||
out/
|
||||
logs/
|
||||
@@ -10,3 +11,14 @@ public/electron/
|
||||
pnpm-lock.yaml
|
||||
CLAUDE.md
|
||||
/public/dist/
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/00/0000
|
||||
/build/extraResources/influxdb-1.7.0/meta/meta.db
|
||||
/build/extraResources/influxdb-1.7.0/influxdb.runtime.conf
|
||||
/build/extraResources/influxdb-1.7.0/wal/_internal/monitor/1/_00001.wal
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/07/0000
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/06/0000
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/05/0000
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/04/0000
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/03/0000
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/02/0000
|
||||
/build/extraResources/influxdb-1.7.0/data/_internal/_series/01/0000
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
@echo off
|
||||
cd /d "%~dp0"
|
||||
influxd.exe -config "%~dp0influxdb.conf"
|
||||
pause
|
||||
set "CONFIG_FILE=%~1"
|
||||
if "%CONFIG_FILE%"=="" set "CONFIG_FILE=%~dp0influxdb.conf"
|
||||
influxd.exe -config "%CONFIG_FILE%"
|
||||
|
||||
@@ -95,6 +95,13 @@ qr:
|
||||
db:
|
||||
type: mysql
|
||||
|
||||
steady:
|
||||
influxdb:
|
||||
url: http://127.0.0.1:{{INFLUXDB_PORT}}
|
||||
database: pqsbase
|
||||
username:
|
||||
password:
|
||||
|
||||
|
||||
# 比对录波需要的配置,晚点再做优化
|
||||
# 系统配置
|
||||
|
||||
@@ -48,6 +48,11 @@
|
||||
"to": "mysql",
|
||||
"filter": ["**/*"]
|
||||
},
|
||||
{
|
||||
"from": "build/extraResources/influxdb-1.7.0",
|
||||
"to": "influxdb-1.7.0",
|
||||
"filter": ["**/*"]
|
||||
},
|
||||
{
|
||||
"from": "build/extraResources/jre",
|
||||
"to": "jre",
|
||||
|
||||
@@ -11,45 +11,40 @@ const { app } = require('electron');
|
||||
function getScriptsPath(scriptName) {
|
||||
const fs = require('fs');
|
||||
|
||||
// 判断是否是打包后的环境
|
||||
// 只要 process.resourcesPath 存在,就是打包后的环境(无论在哪个目录)
|
||||
const isProd = !!process.resourcesPath;
|
||||
|
||||
if (isProd) {
|
||||
// 生产环境(打包后):从 resources 目录
|
||||
if (process.resourcesPath) {
|
||||
const prodPath = path.join(process.resourcesPath, 'scripts', scriptName);
|
||||
const prodFile = `${prodPath}.js`;
|
||||
if (fs.existsSync(prodFile)) {
|
||||
console.log(`[getScriptsPath] Production mode, using: ${prodPath}`);
|
||||
return prodPath;
|
||||
} else {
|
||||
// 开发环境:从项目根目录
|
||||
// __dirname 是 electron/preload 或 public/electron/preload
|
||||
// 需要找到项目根目录
|
||||
let currentDir = __dirname;
|
||||
let scriptsPath = null;
|
||||
|
||||
// 向上查找,直到找到 scripts 目录
|
||||
for (let i = 0; i < 5; i++) {
|
||||
currentDir = path.join(currentDir, '..');
|
||||
const testPath = path.join(currentDir, 'scripts', scriptName + '.js');
|
||||
if (fs.existsSync(testPath)) {
|
||||
scriptsPath = path.join(currentDir, 'scripts', scriptName);
|
||||
console.log(`[getScriptsPath] Development mode, found at: ${scriptsPath}`);
|
||||
return scriptsPath;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果找不到,返回一个默认路径
|
||||
console.warn(`[getScriptsPath] Cannot find ${scriptName}, returning default path`);
|
||||
return path.join(__dirname, '../../../scripts', scriptName);
|
||||
}
|
||||
|
||||
// 开发环境:从项目根目录向上查找 scripts 目录,避免误用 Electron 安装目录 resources。
|
||||
let currentDir = __dirname;
|
||||
let scriptsPath = null;
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
currentDir = path.join(currentDir, '..');
|
||||
const testPath = path.join(currentDir, 'scripts', scriptName + '.js');
|
||||
if (fs.existsSync(testPath)) {
|
||||
scriptsPath = path.join(currentDir, 'scripts', scriptName);
|
||||
console.log(`[getScriptsPath] Development mode, found at: ${scriptsPath}`);
|
||||
return scriptsPath;
|
||||
}
|
||||
}
|
||||
|
||||
console.warn(`[getScriptsPath] Cannot find ${scriptName}, returning default path`);
|
||||
return path.join(__dirname, '../../../scripts', scriptName);
|
||||
}
|
||||
|
||||
// 延迟加载 scripts
|
||||
let MySQLProcessManager, JavaRunner, ConfigGenerator, PortChecker, StartupManager, LogWindowManager;
|
||||
let MySQLProcessManager, InfluxDBProcessManager, JavaRunner, ConfigGenerator, PortChecker, StartupManager, LogWindowManager;
|
||||
|
||||
function loadScripts() {
|
||||
if (!MySQLProcessManager) {
|
||||
MySQLProcessManager = require(getScriptsPath('mysql-process-manager'));
|
||||
InfluxDBProcessManager = require(getScriptsPath('influxdb-process-manager'));
|
||||
JavaRunner = require(getScriptsPath('java-runner'));
|
||||
ConfigGenerator = require(getScriptsPath('config-generator'));
|
||||
PortChecker = require(getScriptsPath('port-checker'));
|
||||
@@ -61,10 +56,12 @@ function loadScripts() {
|
||||
class Lifecycle {
|
||||
constructor() {
|
||||
this.mysqlProcessManager = null;
|
||||
this.influxdbProcessManager = null;
|
||||
this.javaRunner = null;
|
||||
this.startupManager = null;
|
||||
this.logWindowManager = null;
|
||||
this.mysqlPort = null;
|
||||
this.influxdbPort = null;
|
||||
this.javaPort = null;
|
||||
this.autoRefreshTimer = null;
|
||||
}
|
||||
@@ -124,9 +121,38 @@ class Lifecycle {
|
||||
}
|
||||
}
|
||||
|
||||
// InfluxDB 用于稳态趋势、补数等时序数据能力,必须早于后端服务启动。
|
||||
this.logWindowManager.addLog('system', '▶ 步骤7: 启动 InfluxDB 进程管理器...');
|
||||
this.startupManager.updateProgress('check-influxdb-port', { mysqlPort: this.mysqlPort });
|
||||
|
||||
this.influxdbProcessManager = new InfluxDBProcessManager(this.logWindowManager);
|
||||
this.logWindowManager.addLog('system', '正在检查 InfluxDB 进程状态...');
|
||||
|
||||
try {
|
||||
this.influxdbPort = await this.influxdbProcessManager.ensureServiceRunning(
|
||||
PortChecker.findAvailablePort.bind(PortChecker),
|
||||
PortChecker.waitForPort.bind(PortChecker)
|
||||
);
|
||||
|
||||
logger.info(`[lifecycle] InfluxDB process running on port: ${this.influxdbPort}`);
|
||||
this.logWindowManager.addLog('success', `✅ InfluxDB 服务已就绪,端口: ${this.influxdbPort}`);
|
||||
this.startupManager.updateProgress('wait-influxdb', {
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort
|
||||
});
|
||||
await this.sleep(500);
|
||||
} catch (error) {
|
||||
logger.error('[lifecycle] InfluxDB error:', error);
|
||||
this.logWindowManager.addLog('error', `InfluxDB 错误: ${error.message}`);
|
||||
throw error;
|
||||
}
|
||||
|
||||
// 步骤5: 检测 Java 端口
|
||||
this.logWindowManager.addLog('system', '▶ 步骤7: 检测可用的 Java 端口(从18093开始)...');
|
||||
this.startupManager.updateProgress('check-java-port', { mysqlPort: this.mysqlPort });
|
||||
this.logWindowManager.addLog('system', '▶ 步骤8: 检测可用的 Java 端口(从18093开始)...');
|
||||
this.startupManager.updateProgress('check-java-port', {
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort
|
||||
});
|
||||
|
||||
this.javaPort = await PortChecker.findAvailablePort(18093, 100);
|
||||
|
||||
@@ -136,7 +162,7 @@ class Lifecycle {
|
||||
}
|
||||
|
||||
// 步骤5.5: 检测 WebSocket 端口
|
||||
this.logWindowManager.addLog('system', '▶ 步骤8: 检测可用的 WebSocket 端口(从7778开始)...');
|
||||
this.logWindowManager.addLog('system', '▶ 步骤9: 检测可用的 WebSocket 端口(从7778开始)...');
|
||||
|
||||
this.websocketPort = await PortChecker.findAvailablePort(7778, 100);
|
||||
|
||||
@@ -161,14 +187,16 @@ class Lifecycle {
|
||||
logger.info(`[lifecycle] WebSocket will use port: ${this.websocketPort}`);
|
||||
this.startupManager.updateProgress('check-java-port', {
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort,
|
||||
javaPort: this.javaPort
|
||||
});
|
||||
await this.sleep(500);
|
||||
|
||||
// 步骤6: 生成配置文件
|
||||
this.logWindowManager.addLog('system', '▶ 步骤9: 生成 Spring Boot 配置文件...');
|
||||
this.logWindowManager.addLog('system', '▶ 步骤10: 生成 Spring Boot 配置文件...');
|
||||
this.startupManager.updateProgress('generate-config', {
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort,
|
||||
javaPort: this.javaPort,
|
||||
websocketPort: this.websocketPort
|
||||
});
|
||||
@@ -176,6 +204,7 @@ class Lifecycle {
|
||||
const configGenerator = new ConfigGenerator();
|
||||
const { configPath, dataPath } = await configGenerator.generateConfig({
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort,
|
||||
javaPort: this.javaPort,
|
||||
websocketPort: this.websocketPort,
|
||||
mysqlPassword: 'njcnpqs'
|
||||
@@ -194,9 +223,10 @@ class Lifecycle {
|
||||
await this.sleep(500);
|
||||
|
||||
// 步骤7: 启动 Spring Boot
|
||||
this.logWindowManager.addLog('system', '▶ 步骤10: 启动 Spring Boot 应用...');
|
||||
this.logWindowManager.addLog('system', '▶ 步骤11: 启动 Spring Boot 应用...');
|
||||
this.startupManager.updateProgress('start-java', {
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort,
|
||||
javaPort: this.javaPort,
|
||||
dataPath: dataPath
|
||||
});
|
||||
@@ -204,9 +234,10 @@ class Lifecycle {
|
||||
await this.startSpringBoot(configPath, dataPath);
|
||||
|
||||
// 步骤8: 等待 Spring Boot 就绪
|
||||
this.logWindowManager.addLog('system', '▶ 步骤11: 等待 Spring Boot 就绪(最多60秒)...');
|
||||
this.logWindowManager.addLog('system', '▶ 步骤12: 等待 Spring Boot 就绪(最多60秒)...');
|
||||
this.startupManager.updateProgress('wait-java', {
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort,
|
||||
javaPort: this.javaPort,
|
||||
dataPath: dataPath
|
||||
});
|
||||
@@ -224,9 +255,10 @@ class Lifecycle {
|
||||
await this.sleep(1000);
|
||||
|
||||
// 步骤9: 完成
|
||||
this.logWindowManager.addLog('system', '▶ 步骤12: 启动完成,准备显示主窗口...');
|
||||
this.logWindowManager.addLog('system', '▶ 步骤13: 启动完成,准备显示主窗口...');
|
||||
this.startupManager.updateProgress('done', {
|
||||
mysqlPort: this.mysqlPort,
|
||||
influxdbPort: this.influxdbPort,
|
||||
javaPort: this.javaPort,
|
||||
dataPath: dataPath
|
||||
});
|
||||
@@ -235,6 +267,7 @@ class Lifecycle {
|
||||
this.logWindowManager.addLog('system', '='.repeat(60));
|
||||
this.logWindowManager.addLog('success', '✓ 电能质量运维工具 启动完成!所有服务正常运行');
|
||||
this.logWindowManager.addLog('system', `✓ MySQL 端口: ${this.mysqlPort}`);
|
||||
this.logWindowManager.addLog('system', `✓ InfluxDB 端口: ${this.influxdbPort}`);
|
||||
this.logWindowManager.addLog('system', `✓ Java 端口: ${this.javaPort}`);
|
||||
this.logWindowManager.addLog('system', `✓ WebSocket 端口: ${this.websocketPort}`);
|
||||
this.logWindowManager.addLog('system', `✓ 数据目录: ${dataPath}`);
|
||||
@@ -375,7 +408,26 @@ class Lifecycle {
|
||||
}
|
||||
}
|
||||
|
||||
// 停止 MySQL 进程(进程模式)
|
||||
// 停止数据库进程(进程模式)
|
||||
// InfluxDB 只清理当前应用记录的 PID,避免影响用户本机其他 InfluxDB 实例。
|
||||
if (this.influxdbProcessManager) {
|
||||
try {
|
||||
logger.info('[lifecycle] Stopping InfluxDB process...');
|
||||
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
||||
this.logWindowManager.addLog('system', '正在停止 InfluxDB...');
|
||||
}
|
||||
|
||||
await this.influxdbProcessManager.stopInfluxDBProcess();
|
||||
|
||||
logger.info('[lifecycle] InfluxDB process stopped');
|
||||
if (this.logWindowManager && this.logWindowManager.logWindow && !this.logWindowManager.logWindow.isDestroyed()) {
|
||||
this.logWindowManager.addLog('success', 'InfluxDB 已停止');
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('[lifecycle] Failed to stop InfluxDB:', error);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.mysqlProcessManager) {
|
||||
try {
|
||||
logger.info('[lifecycle] Stopping MySQL process...');
|
||||
@@ -427,12 +479,11 @@ class Lifecycle {
|
||||
// 启动Java应用
|
||||
this.javaRunner = new JavaRunner();
|
||||
|
||||
// 开发环境:build/extraResources/java/entrance.jar
|
||||
// 打包后:resources/extraResources/java/entrance.jar
|
||||
const isDev = !process.resourcesPath;
|
||||
const jarPath = isDev
|
||||
? path.join(__dirname, '..', 'build', 'extraResources', 'java', 'entrance.jar')
|
||||
: path.join(process.resourcesPath, 'extraResources', 'java', 'entrance.jar');
|
||||
const { resolvePackagedRuntime } = require(getScriptsPath('path-utils'));
|
||||
const runtime = resolvePackagedRuntime();
|
||||
const jarPath = runtime.isPackaged
|
||||
? path.join(runtime.resourcesPath, 'extraResources', 'java', 'entrance.jar')
|
||||
: path.join(runtime.baseDir, 'build', 'extraResources', 'java', 'entrance.jar');
|
||||
|
||||
const logPath = path.join(dataPath, 'logs');
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@ export function wrapperEnv(envConf: Recordable): ViteEnv {
|
||||
if (envName === "VITE_PROXY") {
|
||||
try {
|
||||
realName = JSON.parse(realName);
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
// Keep the original string when the proxy config is not valid JSON.
|
||||
}
|
||||
}
|
||||
ret[envName] = realName;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"axios": "^1.7.3",
|
||||
"crypto-js": "^4.2.0",
|
||||
"dayjs": "^1.11.9",
|
||||
"docx-preview": "^0.3.7",
|
||||
"driver.js": "^1.3.0",
|
||||
"echarts": "^5.4.3",
|
||||
"echarts-gl": "^2.0.9",
|
||||
|
||||
48
frontend/src/api/aireport/clientUnit/index.ts
Normal file
48
frontend/src/api/aireport/clientUnit/index.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import http from '@/api'
|
||||
import type { ClientUnit } from './interface'
|
||||
|
||||
const buildClientUnitImportFormData = (file: File) => {
|
||||
const formData = new FormData()
|
||||
|
||||
formData.append('file', file)
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
export const listClientUnitsApi = (params: ClientUnit.ClientUnitListParams) => {
|
||||
return http.post('/clientUnit/list', params)
|
||||
}
|
||||
|
||||
export const createClientUnitApi = (params: ClientUnit.ClientUnitSaveRequest) => {
|
||||
return http.post<boolean>('/clientUnit/add', params)
|
||||
}
|
||||
|
||||
export const updateClientUnitApi = (params: ClientUnit.ClientUnitSaveRequest) => {
|
||||
return http.post<boolean>('/clientUnit/update', params)
|
||||
}
|
||||
|
||||
export const getClientUnitDetailApi = (id: string) => {
|
||||
return http.get<ClientUnit.ClientUnitRecord>('/clientUnit/getById', { id })
|
||||
}
|
||||
|
||||
export const deleteClientUnitsApi = (ids: string[]) => {
|
||||
return http.post<boolean>('/clientUnit/delete', ids)
|
||||
}
|
||||
|
||||
export const exportClientUnitsApi = (params: ClientUnit.ClientUnitListParams) => {
|
||||
return http.post('/clientUnit/export', params, { responseType: 'blob' })
|
||||
}
|
||||
|
||||
export const downloadClientUnitImportTemplateApi = () => {
|
||||
return http.get('/clientUnit/importTemplate', undefined, { responseType: 'blob' })
|
||||
}
|
||||
|
||||
export const importClientUnitsApi = (file: File) => {
|
||||
return http.post<ClientUnit.ClientUnitImportResult>(
|
||||
'/clientUnit/import',
|
||||
buildClientUnitImportFormData(file),
|
||||
{
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
}
|
||||
)
|
||||
}
|
||||
36
frontend/src/api/aireport/clientUnit/interface/index.ts
Normal file
36
frontend/src/api/aireport/clientUnit/interface/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
export namespace ClientUnit {
|
||||
export interface ClientUnitRecord {
|
||||
id?: string
|
||||
name?: string | null
|
||||
contactName?: string | null
|
||||
phonenumber?: string | null
|
||||
address?: string | null
|
||||
createBy?: string | null
|
||||
createTime?: string | null
|
||||
updateBy?: string | null
|
||||
updateTime?: string | null
|
||||
}
|
||||
|
||||
export interface ClientUnitListParams {
|
||||
name?: string
|
||||
searchBeginTime?: string
|
||||
searchEndTime?: string
|
||||
timeRange?: string[]
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface ClientUnitSaveRequest {
|
||||
id?: string
|
||||
name: string
|
||||
contactName?: string | null
|
||||
phonenumber?: string | null
|
||||
address?: string | null
|
||||
}
|
||||
|
||||
export interface ClientUnitImportResult {
|
||||
successCount?: number
|
||||
failCount?: number
|
||||
failReasons?: string[]
|
||||
}
|
||||
}
|
||||
16
frontend/src/api/aireport/reportApproval/index.ts
Normal file
16
frontend/src/api/aireport/reportApproval/index.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import http from '@/api'
|
||||
import type { ReportApproval } from './interface'
|
||||
|
||||
const REPORT_APPROVAL_BASE_URL = '/api/report-approval'
|
||||
|
||||
export const listPendingReportApprovalsApi = (params: ReportApproval.PendingListParams) =>
|
||||
http.get(`${REPORT_APPROVAL_BASE_URL}/pending-page`, params)
|
||||
|
||||
export const passReportApprovalApi = (params: ReportApproval.ApprovalActionRequest) =>
|
||||
http.post<boolean>(`${REPORT_APPROVAL_BASE_URL}/pass`, params)
|
||||
|
||||
export const rejectReportApprovalApi = (params: ReportApproval.ApprovalActionRequest) =>
|
||||
http.post<boolean>(`${REPORT_APPROVAL_BASE_URL}/reject`, params)
|
||||
|
||||
export const listReportApprovalLogsApi = (params: ReportApproval.LogListParams) =>
|
||||
http.get(`${REPORT_APPROVAL_BASE_URL}/log-page`, params)
|
||||
46
frontend/src/api/aireport/reportApproval/interface/index.ts
Normal file
46
frontend/src/api/aireport/reportApproval/interface/index.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
export namespace ReportApproval {
|
||||
export type ReportType = 'REPORT_MODEL' | 'TEST_REPORT' | (string & {})
|
||||
export type ReportState = '01' | '02' | '03' | '04' | '05' | (string & {})
|
||||
export type ApprovalResult = '03' | '04' | (string & {})
|
||||
|
||||
export interface PendingRecord {
|
||||
reportType?: ReportType
|
||||
reportId?: string
|
||||
reportName?: string | null
|
||||
state?: ReportState
|
||||
submitterId?: string | null
|
||||
submitterName?: string | null
|
||||
submitTime?: string | null
|
||||
}
|
||||
|
||||
export interface PendingListParams {
|
||||
current?: number
|
||||
size?: number
|
||||
reportType?: ReportType | ''
|
||||
}
|
||||
|
||||
export interface ApprovalActionRequest {
|
||||
reportType: ReportType
|
||||
reportId: string
|
||||
approvalReason: string
|
||||
}
|
||||
|
||||
export interface LogRecord {
|
||||
id?: string
|
||||
reportType?: ReportType
|
||||
reportId?: string
|
||||
reportName?: string | null
|
||||
approvalResult?: ApprovalResult
|
||||
approvalReason?: string | null
|
||||
beforeState?: ReportState
|
||||
afterState?: ReportState
|
||||
approverName?: string | null
|
||||
approvalTime?: string | null
|
||||
}
|
||||
|
||||
export interface LogListParams {
|
||||
current?: number
|
||||
size?: number
|
||||
reportType?: ReportType | ''
|
||||
}
|
||||
}
|
||||
49
frontend/src/api/aireport/reportModel/index.ts
Normal file
49
frontend/src/api/aireport/reportModel/index.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import http from '@/api'
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import type { ReportModel } from './interface'
|
||||
|
||||
const REPORT_MODEL_BASE_URL = '/api/report-model'
|
||||
|
||||
const buildReportModelFormData = (request: ReportModel.ReportModelSaveRequest, templateFile?: File | null) => {
|
||||
const formData = new FormData()
|
||||
|
||||
// 关键业务节点:后端按 @RequestPart("request") 读取 JSON 分段,字段名不能改成普通表单字段。
|
||||
formData.append('request', new Blob([JSON.stringify(request)], { type: 'application/json' }))
|
||||
|
||||
if (templateFile) {
|
||||
formData.append('templateFile', templateFile)
|
||||
}
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
export const listReportModelsApi = (params: ReportModel.ReportModelListParams) => {
|
||||
return http.post('/api/report-model/list', params)
|
||||
}
|
||||
|
||||
export const getReportModelDetailApi = (id: string) => {
|
||||
return http.get<ReportModel.ReportModelRecord>(`${REPORT_MODEL_BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
export const createReportModelApi = (request: ReportModel.ReportModelSaveRequest, templateFile: File) => {
|
||||
return http.post<boolean>(`${REPORT_MODEL_BASE_URL}/add`, buildReportModelFormData(request, templateFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const updateReportModelApi = (request: ReportModel.ReportModelSaveRequest, templateFile?: File | null) => {
|
||||
return http.post<boolean>(`${REPORT_MODEL_BASE_URL}/update`, buildReportModelFormData(request, templateFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteReportModelsApi = (ids: string[]) => {
|
||||
return http.post<boolean>(`${REPORT_MODEL_BASE_URL}/delete`, ids)
|
||||
}
|
||||
|
||||
export const downloadReportModelApi = (id: string): Promise<AxiosResponse<Blob>> =>
|
||||
http.get(`${REPORT_MODEL_BASE_URL}/${id}/download`, undefined, { responseType: 'blob' }) as unknown as Promise<AxiosResponse<Blob>>
|
||||
|
||||
export const submitReportModelAuditApi = (params: ReportModel.ReportModelAuditRequest) => {
|
||||
return http.post<boolean>(`${REPORT_MODEL_BASE_URL}/submit-audit`, params)
|
||||
}
|
||||
43
frontend/src/api/aireport/reportModel/interface/index.ts
Normal file
43
frontend/src/api/aireport/reportModel/interface/index.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
export namespace ReportModel {
|
||||
export type ReportModelState = '01' | '02' | '03' | '04' | (string & {})
|
||||
|
||||
export interface ReportModelRecord {
|
||||
id?: string
|
||||
name?: string
|
||||
state?: ReportModelState
|
||||
checkId?: string | null
|
||||
checkerName?: string | null
|
||||
checkTime?: string | null
|
||||
checkResult?: string | null
|
||||
path?: string | null
|
||||
fileName?: string | null
|
||||
file_name?: string | null
|
||||
status?: number
|
||||
createBy?: string | null
|
||||
createTime?: string | null
|
||||
updateBy?: string | null
|
||||
editorName?: string | null
|
||||
updateTime?: string | null
|
||||
}
|
||||
|
||||
export interface ReportModelListParams {
|
||||
name?: string
|
||||
state?: ReportModelState | ''
|
||||
searchBeginTime?: string
|
||||
searchEndTime?: string
|
||||
timeRange?: string[]
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface ReportModelSaveRequest {
|
||||
id?: string
|
||||
name: string
|
||||
fileName?: string
|
||||
}
|
||||
|
||||
export interface ReportModelAuditRequest {
|
||||
id: string
|
||||
checkResult?: string
|
||||
}
|
||||
}
|
||||
77
frontend/src/api/aireport/testDevice/index.ts
Normal file
77
frontend/src/api/aireport/testDevice/index.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import http from '@/api'
|
||||
import type { TestDevice } from './interface'
|
||||
|
||||
const TEST_DEVICE_BASE_URL = '/api/test-device'
|
||||
|
||||
const buildTestDeviceFormData = (request: TestDevice.TestDeviceSaveRequest, reportFile?: File | null) => {
|
||||
const formData = new FormData()
|
||||
|
||||
// 关键业务节点:检测设备新增/编辑接口按 request JSON 分段读取业务字段,报告文件单独传 reportFile。
|
||||
formData.append('request', new Blob([JSON.stringify(request)], { type: 'application/json' }))
|
||||
|
||||
if (reportFile) {
|
||||
formData.append('reportFile', reportFile)
|
||||
}
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
const buildTestDeviceImportFormData = (file: File, reportZip: File) => {
|
||||
const formData = new FormData()
|
||||
|
||||
formData.append('file', file)
|
||||
formData.append('reportZip', reportZip)
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
export const listTestDevicesApi = (params: TestDevice.TestDeviceListParams) => {
|
||||
return http.post(`${TEST_DEVICE_BASE_URL}/list`, params)
|
||||
}
|
||||
|
||||
export const createTestDeviceApi = (request: TestDevice.TestDeviceSaveRequest, reportFile: File) => {
|
||||
return http.post<boolean>(`${TEST_DEVICE_BASE_URL}/add`, buildTestDeviceFormData(request, reportFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const updateTestDeviceApi = (request: TestDevice.TestDeviceSaveRequest, reportFile?: File | null) => {
|
||||
return http.post<boolean>(`${TEST_DEVICE_BASE_URL}/update`, buildTestDeviceFormData(request, reportFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteTestDevicesApi = (ids: string[]) => {
|
||||
return http.post<boolean>(`${TEST_DEVICE_BASE_URL}/delete`, ids)
|
||||
}
|
||||
|
||||
export const getTestDeviceDetailApi = (id: string) => {
|
||||
return http.get<TestDevice.TestDeviceRecord>(`${TEST_DEVICE_BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
export const downloadTestDeviceImportTemplateApi = () => {
|
||||
return http.get(`${TEST_DEVICE_BASE_URL}/template`, undefined, { responseType: 'blob' })
|
||||
}
|
||||
|
||||
export const importTestDevicesApi = (file: File, reportZip: File) => {
|
||||
return http.post<TestDevice.TestDeviceImportResult>(
|
||||
`${TEST_DEVICE_BASE_URL}/import`,
|
||||
buildTestDeviceImportFormData(file, reportZip),
|
||||
{
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export const exportTestDevicesApi = (params: TestDevice.TestDeviceListParams) => {
|
||||
return http.get(`${TEST_DEVICE_BASE_URL}/export`, params, { responseType: 'blob' })
|
||||
}
|
||||
|
||||
export const previewTestDeviceReportApi = (id: string) => {
|
||||
// 关键业务节点:test-device 当前仅提供 /{id}/report,预览与下载统一复用同一报告流,避免前端误调不存在的 preview 接口。
|
||||
return http.get(`${TEST_DEVICE_BASE_URL}/${id}/report`, undefined, { responseType: 'blob' })
|
||||
}
|
||||
|
||||
export const downloadTestDeviceReportApi = (id: string) => {
|
||||
return http.get(`${TEST_DEVICE_BASE_URL}/${id}/report`, undefined, { responseType: 'blob' })
|
||||
}
|
||||
45
frontend/src/api/aireport/testDevice/interface/index.ts
Normal file
45
frontend/src/api/aireport/testDevice/interface/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
export namespace TestDevice {
|
||||
export type TestDeviceState = '01' | '02' | (string & {})
|
||||
|
||||
export interface TestDeviceRecord {
|
||||
id?: string
|
||||
type?: string | null
|
||||
typeName?: string | null
|
||||
no?: string | null
|
||||
validityPeriod?: string | null
|
||||
validityReport?: string | null
|
||||
validityReportName?: string | null
|
||||
validityReportUrl?: string | null
|
||||
state?: TestDeviceState
|
||||
status?: number
|
||||
createBy?: string | null
|
||||
createByName?: string | null
|
||||
createTime?: string | null
|
||||
updateBy?: string | null
|
||||
updateByName?: string | null
|
||||
updateTime?: string | null
|
||||
}
|
||||
|
||||
export interface TestDeviceListParams {
|
||||
keyword?: string
|
||||
searchBeginTime?: string
|
||||
searchEndTime?: string
|
||||
timeRange?: string[]
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface TestDeviceSaveRequest {
|
||||
id?: string
|
||||
type: string
|
||||
no: string
|
||||
validityPeriod: string
|
||||
state?: TestDeviceState
|
||||
}
|
||||
|
||||
export interface TestDeviceImportResult {
|
||||
successCount?: number
|
||||
failCount?: number
|
||||
failReasons?: string[]
|
||||
}
|
||||
}
|
||||
47
frontend/src/api/aireport/testReport/index.ts
Normal file
47
frontend/src/api/aireport/testReport/index.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import http from '@/api'
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import type { ReportTask } from './interface'
|
||||
|
||||
const REPORT_TASK_BASE_URL = '/api/test-report'
|
||||
|
||||
export const listReportTasksApi = (params: ReportTask.ReportTaskListParams) => {
|
||||
return http.post(`${REPORT_TASK_BASE_URL}/list`, params)
|
||||
}
|
||||
|
||||
export const createReportTaskApi = (params: ReportTask.ReportTaskAddParam) => {
|
||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/add`, params)
|
||||
}
|
||||
|
||||
export const updateReportTaskApi = (params: ReportTask.ReportTaskSaveRequest) => {
|
||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/update`, params)
|
||||
}
|
||||
|
||||
export const deleteReportTasksApi = (ids: string[]) => {
|
||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/delete`, ids)
|
||||
}
|
||||
|
||||
export const getReportTaskDetailApi = (id: string) => {
|
||||
return http.get<ReportTask.ReportTaskRecord>(`${REPORT_TASK_BASE_URL}/${id}`)
|
||||
}
|
||||
|
||||
export const exportReportTasksApi = (params: ReportTask.ReportTaskListParams): Promise<AxiosResponse<Blob>> =>
|
||||
http.get(`${REPORT_TASK_BASE_URL}/export`, params, { responseType: 'blob' }) as unknown as Promise<AxiosResponse<Blob>>
|
||||
|
||||
export const submitReportTaskAuditApi = (params: ReportTask.ReportTaskAuditRequest) => {
|
||||
return http.post<boolean>(`${REPORT_TASK_BASE_URL}/submit-audit`, params)
|
||||
}
|
||||
|
||||
export const downloadReportTaskLedgerTemplateApi = (): Promise<AxiosResponse<Blob>> =>
|
||||
http.get(`${REPORT_TASK_BASE_URL}/ledger/template`, undefined, {
|
||||
responseType: 'blob'
|
||||
}) as unknown as Promise<AxiosResponse<Blob>>
|
||||
|
||||
export const validateReportTaskLedgerApi = (id: string, formData: FormData) => {
|
||||
return http.post<ReportTask.ReportTaskLedgerImportResult>(`${REPORT_TASK_BASE_URL}/${id}/ledger/validate`, formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const listReportTaskGroupReportsApi = (id: string) => {
|
||||
return http.get<ReportTask.ReportTaskGroupReportRecord[]>(`${REPORT_TASK_BASE_URL}/${id}/group-report/list`)
|
||||
}
|
||||
161
frontend/src/api/aireport/testReport/interface/index.ts
Normal file
161
frontend/src/api/aireport/testReport/interface/index.ts
Normal file
@@ -0,0 +1,161 @@
|
||||
export namespace ReportTask {
|
||||
export type ReportTaskGroupReportGenerateState = 0 | 1 | 2 | 3
|
||||
export type ReportTaskLedgerImportStage =
|
||||
| '选择文件'
|
||||
| '校验文件'
|
||||
| '文件上传'
|
||||
| '基础资料维护'
|
||||
| '完成'
|
||||
|
||||
export interface ReportTaskRecord {
|
||||
id?: string
|
||||
no?: string | null
|
||||
clientUnitId?: string | null
|
||||
clientUnitName?: string | null
|
||||
reportModelId?: string | null
|
||||
reportModelName?: string | null
|
||||
createUnit?: string | null
|
||||
contractNumber?: string | null
|
||||
standard?: string[] | string | null
|
||||
data?: string | null
|
||||
phonenumber?: string | null
|
||||
checkId?: string | null
|
||||
checkerName?: string | null
|
||||
checkTime?: string | null
|
||||
checkResult?: string | null
|
||||
status?: number
|
||||
pointCount?: number | null
|
||||
groupCount?: number | null
|
||||
reportGenerateState?: number | null
|
||||
createBy?: string | null
|
||||
createByName?: string | null
|
||||
createTime?: string | null
|
||||
updateBy?: string | null
|
||||
updateByName?: string | null
|
||||
updateTime?: string | null
|
||||
groupReports?: ReportTaskGroupReportRecord[] | null
|
||||
}
|
||||
|
||||
export interface ReportTaskListParams {
|
||||
keyword?: string
|
||||
searchBeginTime?: string
|
||||
searchEndTime?: string
|
||||
timeRange?: string[]
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface ReportTaskAddParam {
|
||||
id?: string
|
||||
no: string
|
||||
clientUnitId: string
|
||||
reportModelId: string
|
||||
createUnit: string
|
||||
contractNumber: string
|
||||
standard: string[]
|
||||
data: string
|
||||
batchId?: string
|
||||
phonenumber?: string
|
||||
}
|
||||
|
||||
export interface ReportTaskSaveRequest extends ReportTaskAddParam {}
|
||||
|
||||
export interface ReportTaskAuditRequest {
|
||||
id: string
|
||||
checkResult?: string
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportStageRecord {
|
||||
stage?: ReportTaskLedgerImportStage | string | null
|
||||
success?: boolean | null
|
||||
message?: string | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportSnapshotGroupRecord {
|
||||
groupNo?: number | null
|
||||
count?: number | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportSnapshot {
|
||||
version?: string | null
|
||||
importMode?: string | null
|
||||
summaryFileName?: string | null
|
||||
sheetSummary?: {
|
||||
pointSheet?: string | null
|
||||
deviceSheetPresent?: boolean | null
|
||||
clientSheetPresent?: boolean | null
|
||||
} | null
|
||||
rowCount?: number | null
|
||||
groupSummary?: ReportTaskLedgerImportSnapshotGroupRecord[] | null
|
||||
baseDataSummary?: {
|
||||
deviceAddedCount?: number | null
|
||||
deviceReuseCount?: number | null
|
||||
clientAddedCount?: number | null
|
||||
clientReuseCount?: number | null
|
||||
} | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerImportResult {
|
||||
batchId?: string | null
|
||||
currentStage?: ReportTaskLedgerImportStage | string | null
|
||||
success?: boolean | null
|
||||
summaryFileName?: string | null
|
||||
totalFileCount?: number
|
||||
pointCount?: number
|
||||
excelAttachmentCount?: number
|
||||
wordAttachmentCount?: number
|
||||
deviceAddedCount?: number
|
||||
deviceReuseCount?: number
|
||||
clientAddedCount?: number
|
||||
clientReuseCount?: number
|
||||
groupCount?: number
|
||||
failReasons?: string[] | null
|
||||
stages?: ReportTaskLedgerImportStageRecord[] | null
|
||||
}
|
||||
|
||||
export interface ReportTaskPointRecord {
|
||||
id?: string
|
||||
groupNo?: number | null
|
||||
substationName?: string | null
|
||||
pointName?: string | null
|
||||
monitorTime?: string | null
|
||||
voltageLevel?: string | null
|
||||
ptRatio?: string | null
|
||||
ctRatio?: string | null
|
||||
baseShortCircuitCapacity?: string | null
|
||||
minShortCircuitCapacity?: string | null
|
||||
protocolCapacity?: string | null
|
||||
powerSupplyCapacity?: string | null
|
||||
excelAttachmentName?: string | null
|
||||
}
|
||||
|
||||
export interface ReportTaskPointGroupItem {
|
||||
groupNo: number
|
||||
pointIds: string[]
|
||||
}
|
||||
|
||||
export interface ReportTaskGroupSaveRequest {
|
||||
groups: ReportTaskPointGroupItem[]
|
||||
}
|
||||
|
||||
export interface ReportTaskGroupReportRecord {
|
||||
id?: string
|
||||
groupNo?: number | null
|
||||
reportName?: string | null
|
||||
reportFileName?: string | null
|
||||
reportStoragePath?: string | null
|
||||
generateState?: ReportTaskGroupReportGenerateState | null
|
||||
generateMessage?: string | null
|
||||
generateTime?: string | null
|
||||
sortNo?: number | null
|
||||
}
|
||||
|
||||
export interface ReportTaskLedgerPreparedState {
|
||||
draftId: string
|
||||
batchId: string
|
||||
latestImportResult: ReportTaskLedgerImportResult | null
|
||||
snapshot: ReportTaskLedgerImportSnapshot | null
|
||||
hasImported: boolean
|
||||
pendingReimport: boolean
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import { EventSourcePolyfill } from 'event-source-polyfill'
|
||||
|
||||
export interface CustomAxiosRequestConfig extends InternalAxiosRequestConfig {
|
||||
loading?: boolean
|
||||
silentStatusError?: boolean
|
||||
}
|
||||
|
||||
const config = {
|
||||
@@ -109,6 +110,10 @@ class RequestHttp {
|
||||
}
|
||||
// 全局错误信息拦截(防止下载文件的时候返回数据流,没有 code 直接报错)
|
||||
if (data.code && data.code !== ResultEnum.SUCCESS) {
|
||||
if ((response.config as CustomAxiosRequestConfig).silentStatusError) {
|
||||
return Promise.reject(data)
|
||||
}
|
||||
|
||||
if (data.message.includes('&')) {
|
||||
let formattedMessage = data.message.split('&').join('<br>')
|
||||
if (data.message.includes(':')) {
|
||||
@@ -147,7 +152,9 @@ class RequestHttp {
|
||||
if (error.message.indexOf('timeout') !== -1) ElMessage.error('请求超时!请您稍后重试')
|
||||
if (error.message.indexOf('Network Error') !== -1) ElMessage.error('网络错误!请您稍后重试')
|
||||
// 根据服务器响应的错误状态码,做不同的处理
|
||||
if (response) checkStatus(response.status)
|
||||
if (response && !(error.config as CustomAxiosRequestConfig | undefined)?.silentStatusError) {
|
||||
checkStatus(response.status)
|
||||
}
|
||||
// 服务器结果都没有返回(可能服务器错误可能客户端断网),断网处理:可以跳转到断网页面
|
||||
if (!window.navigator.onLine) router.replace('/500')
|
||||
return Promise.reject(error)
|
||||
|
||||
@@ -17,8 +17,40 @@ export const querySteadyTrendDay = (params: SteadyDataView.SteadyTrendQueryParam
|
||||
return http.post<SteadyDataView.SteadyTrendQueryResult>('/steady/data-view/trend/day', params, { loading: false })
|
||||
}
|
||||
|
||||
export const querySteadyChecksquare = (params: SteadyDataView.SteadyChecksquareQueryParams) => {
|
||||
return http.post<SteadyDataView.SteadyChecksquareQueryResult>('/steady/data-view/checksquare/query', params, {
|
||||
export const querySteadyChecksquareTasks = (params: SteadyDataView.SteadyChecksquareTaskQueryParams) => {
|
||||
return http.post<SteadyDataView.PageResult<SteadyDataView.SteadyChecksquareTask>>('/steady/checksquare/query', params, {
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export const createSteadyChecksquareTask = (params: SteadyDataView.SteadyChecksquareCreateParams) => {
|
||||
return http.post<SteadyDataView.SteadyChecksquareTask>('/steady/checksquare/create', params, {
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteSteadyChecksquareTasks = (taskIds: SteadyDataView.SteadyChecksquareDeleteParams) => {
|
||||
return http.post<boolean>('/steady/checksquare/delete', taskIds, {
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export const restartSteadyChecksquareTask = (taskId: string) => {
|
||||
return http.post<SteadyDataView.SteadyChecksquareTask>(
|
||||
`/steady/checksquare/restart?taskId=${encodeURIComponent(taskId)}`,
|
||||
{},
|
||||
{
|
||||
loading: false
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
export const getSteadyChecksquareDetail = (taskId: string) => {
|
||||
return http.get<SteadyDataView.SteadyChecksquareQueryResult>('/steady/checksquare/detail', { taskId }, { loading: false })
|
||||
}
|
||||
|
||||
export const getSteadyChecksquareItemDetail = (params: SteadyDataView.SteadyChecksquareItemDetailParams) => {
|
||||
return http.get<SteadyDataView.SteadyChecksquareItemDetail>('/steady/checksquare/item-detail', params, {
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
export namespace SteadyDataView {
|
||||
export interface PageResult<T> {
|
||||
records: T[]
|
||||
current: number
|
||||
size: number
|
||||
total: number
|
||||
pages?: number
|
||||
}
|
||||
|
||||
export interface SteadyLedgerNode {
|
||||
id: string
|
||||
parentId?: string
|
||||
@@ -77,18 +85,46 @@ export namespace SteadyDataView {
|
||||
series: SteadyTrendSeries[]
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareQueryParams {
|
||||
lineId: string
|
||||
export interface SteadyChecksquareTaskQueryParams {
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
lineId?: string
|
||||
lineName?: string
|
||||
indicatorCode?: string
|
||||
timeStart?: string
|
||||
timeEnd?: string
|
||||
hasAbnormal?: boolean
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareCreateParams {
|
||||
lineIds: string[]
|
||||
indicatorCodes: string[]
|
||||
timeStart: string
|
||||
timeEnd: string
|
||||
harmonicOrders?: number[]
|
||||
}
|
||||
|
||||
export type SteadyChecksquareDeleteParams = string[]
|
||||
|
||||
export interface SteadyChecksquareTask {
|
||||
taskId: string
|
||||
taskNo?: string
|
||||
lineId?: string
|
||||
lineName?: string
|
||||
timeStart?: string
|
||||
timeEnd?: string
|
||||
intervalMinutes?: number
|
||||
taskStatus?: 'RUNNING' | 'SUCCESS' | 'FAIL' | string
|
||||
itemCount?: number
|
||||
abnormalItemCount?: number
|
||||
minDataIntegrity?: number | null
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareSegment {
|
||||
startTime: string
|
||||
endTime: string
|
||||
status: 'NORMAL' | 'MISSING' | string
|
||||
harmonicOrder?: number | null
|
||||
missingPointCount?: number
|
||||
durationMinutes?: number
|
||||
}
|
||||
@@ -100,9 +136,8 @@ export namespace SteadyDataView {
|
||||
expectedPointCount?: number
|
||||
actualPointCount?: number
|
||||
missingPointCount?: number
|
||||
missingRate?: number | null
|
||||
missingRateText?: string | null
|
||||
maxContinuousMissingMinutes?: number
|
||||
dataIntegrity?: number | null
|
||||
dataIntegrityText?: string | null
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareStatDetail {
|
||||
@@ -112,7 +147,10 @@ export namespace SteadyDataView {
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareItem {
|
||||
itemId?: string
|
||||
itemKey: string
|
||||
lineId?: string
|
||||
lineName?: string
|
||||
indicatorCode: string
|
||||
indicatorName?: string
|
||||
harmonicOrder?: number | null
|
||||
@@ -120,20 +158,74 @@ export namespace SteadyDataView {
|
||||
expectedPointCount?: number
|
||||
actualPointCount?: number
|
||||
missingPointCount?: number
|
||||
missingRate?: number | null
|
||||
missingRateText?: string | null
|
||||
maxContinuousMissingMinutes?: number
|
||||
dataIntegrity?: number | null
|
||||
dataIntegrityText?: string | null
|
||||
abnormal?: boolean
|
||||
abnormalPointCount?: number
|
||||
harmonicParityAbnormal?: boolean
|
||||
harmonicParityAbnormalPointCount?: number
|
||||
statSummaries: SteadyChecksquareStatSummary[]
|
||||
statDetails: SteadyChecksquareStatDetail[]
|
||||
children?: SteadyChecksquareItem[]
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareQueryResult {
|
||||
taskId?: string
|
||||
taskNo?: string
|
||||
lineId: string
|
||||
lineName?: string
|
||||
timeStart: string
|
||||
timeEnd: string
|
||||
intervalMinutes?: number
|
||||
taskStatus?: 'RUNNING' | 'SUCCESS' | 'FAIL' | string
|
||||
itemCount?: number
|
||||
abnormalItemCount?: number
|
||||
minDataIntegrity?: number | null
|
||||
createTime?: string
|
||||
items: SteadyChecksquareItem[]
|
||||
}
|
||||
|
||||
export type SteadyChecksquareDetailType = 'SEGMENT' | 'VALUE_ORDER' | 'HARMONIC_PARITY'
|
||||
|
||||
export interface SteadyChecksquareItemDetailParams {
|
||||
itemId: string
|
||||
detailType: SteadyChecksquareDetailType
|
||||
statType?: SteadyTrendStatType
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareValueOrderDetail {
|
||||
time: string
|
||||
phase?: string
|
||||
harmonicOrder?: number | null
|
||||
maxValue?: number | null
|
||||
minValue?: number | null
|
||||
avgValue?: number | null
|
||||
cp95Value?: number | null
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareHarmonicParityDetail {
|
||||
time: string
|
||||
phase?: string
|
||||
statType?: SteadyTrendStatType
|
||||
evenHarmonicOrder?: number
|
||||
evenValue?: number | null
|
||||
oddHarmonicOrders?: number[]
|
||||
oddValues?: number[]
|
||||
oddMedianValue?: number | null
|
||||
thresholdMultiplier?: number | null
|
||||
}
|
||||
|
||||
export interface SteadyChecksquareItemDetail {
|
||||
itemId: string
|
||||
detailType: SteadyChecksquareDetailType
|
||||
statType?: SteadyTrendStatType | null
|
||||
pageNum?: number | null
|
||||
pageSize?: number | null
|
||||
total?: number | null
|
||||
segments: SteadyChecksquareSegment[]
|
||||
valueOrderDetails: SteadyChecksquareValueOrderDetail[]
|
||||
harmonicParityDetails: SteadyChecksquareHarmonicParityDetail[]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import http from '@/api'
|
||||
import type { CustomAxiosRequestConfig } from '@/api'
|
||||
import type { Dbms } from '@/api/system/dbms/interface'
|
||||
|
||||
export const getDbmsOverview = () => {
|
||||
return http.get<Dbms.Overview>('/database/overview', {}, { loading: false })
|
||||
}
|
||||
|
||||
export const getDbmsConnectionList = (params: Dbms.ConnectionListParams) => {
|
||||
return http.post<Dbms.ConnectionPageData>('/database/connections/list', params, { loading: false })
|
||||
export const getDbmsConnectionList = (params: Dbms.ConnectionListParams, config: Partial<CustomAxiosRequestConfig> = {}) => {
|
||||
return http.post<Dbms.ConnectionPageData>('/database/connections/list', params, { loading: false, ...config })
|
||||
}
|
||||
|
||||
export const addDbmsConnection = (params: Dbms.ConnectionPayload) => {
|
||||
@@ -25,24 +26,32 @@ export const testDbmsConnection = (params: Dbms.TestConnectionParams) => {
|
||||
return http.post<Dbms.TestConnectionResult>('/database/connections/test', params)
|
||||
}
|
||||
|
||||
export const getDbmsTableList = (params: Dbms.TableListParams) => {
|
||||
return http.post<Dbms.TableRecord[]>('/database/connections/tables', params)
|
||||
export const getDbmsTableList = (params: Dbms.TableListParams, config: Partial<CustomAxiosRequestConfig> = {}) => {
|
||||
return http.post<Dbms.TableRecord[]>('/database/connections/tables', params, config)
|
||||
}
|
||||
|
||||
export const createDbmsBackupTask = (params: Dbms.CreateBackupParams) => {
|
||||
return http.post<Dbms.TaskCreateResult>('/database/backups/create', params)
|
||||
}
|
||||
|
||||
export const getDbmsBackupTaskList = (params: Dbms.TaskListParams) => {
|
||||
return http.post<Dbms.TaskPageData>('/database/backups/tasks/list', params, { loading: false })
|
||||
export const getDbmsBackupTaskList = (params: Dbms.TaskListParams, config: Partial<CustomAxiosRequestConfig> = {}) => {
|
||||
return http.post<Dbms.TaskPageData>('/database/backups/tasks/list', params, { loading: false, ...config })
|
||||
}
|
||||
|
||||
export const getDbmsBackupTaskStatus = (taskId: string) => {
|
||||
return http.get<Dbms.TaskRecord>('/database/backups/tasks/status', { taskId }, { loading: false })
|
||||
}
|
||||
|
||||
export const getDbmsBackupFileList = (params: Dbms.FileListParams) => {
|
||||
return http.post<Dbms.BackupFilePageData>('/database/backups/files/list', params, { loading: false })
|
||||
export const stopDbmsBackupTask = (params: Dbms.StopBackupTaskParams) => {
|
||||
return http.post<boolean>('/database/backups/tasks/stop', params)
|
||||
}
|
||||
|
||||
export const restartDbmsBackupTask = (params: Dbms.RestartBackupTaskParams) => {
|
||||
return http.post<Dbms.TaskCreateResult>('/database/backups/tasks/restart', params)
|
||||
}
|
||||
|
||||
export const getDbmsBackupFileList = (params: Dbms.FileListParams, config: Partial<CustomAxiosRequestConfig> = {}) => {
|
||||
return http.post<Dbms.BackupFilePageData>('/database/backups/files/list', params, { loading: false, ...config })
|
||||
}
|
||||
|
||||
export const createDbmsRestoreTask = (params: Dbms.CreateRestoreParams) => {
|
||||
@@ -53,6 +62,10 @@ export const getDbmsRestoreTaskStatus = (taskId: string) => {
|
||||
return http.get<Dbms.TaskRecord>('/database/restores/tasks/status', { taskId }, { loading: false })
|
||||
}
|
||||
|
||||
export const getDbmsRestoreTaskList = (params: Dbms.TaskListParams, config: Partial<CustomAxiosRequestConfig> = {}) => {
|
||||
return http.post<Dbms.TaskPageData>('/database/restores/tasks/list', params, { loading: false, ...config })
|
||||
}
|
||||
|
||||
export const deleteDbmsBackupFile = (params: Dbms.DeleteBackupFileParams) => {
|
||||
return http.post<boolean>('/database/delete/backup-file', params)
|
||||
}
|
||||
|
||||
@@ -29,9 +29,10 @@ export namespace Dbms {
|
||||
dbType: DbType
|
||||
host: string
|
||||
port: number
|
||||
connectType: ConnectType
|
||||
connectType?: ConnectType | null
|
||||
serviceName?: string | null
|
||||
sid?: string | null
|
||||
databaseName?: string | null
|
||||
schemaName?: string | null
|
||||
username: string
|
||||
savePassword: 0 | 1
|
||||
@@ -53,9 +54,10 @@ export namespace Dbms {
|
||||
dbType: DbType
|
||||
host: string
|
||||
port: number
|
||||
connectType: ConnectType
|
||||
connectType?: ConnectType | null
|
||||
serviceName?: string | null
|
||||
sid?: string | null
|
||||
databaseName?: string | null
|
||||
schemaName?: string | null
|
||||
username: string
|
||||
password?: string | null
|
||||
@@ -90,6 +92,11 @@ export namespace Dbms {
|
||||
export interface TableRecord {
|
||||
owner: string
|
||||
tableName: string
|
||||
autoIncrement?: number | string | null
|
||||
updateTime?: string | null
|
||||
dataLength?: number | string | null
|
||||
engine?: string | null
|
||||
tableRows?: number | string | null
|
||||
comments?: string | null
|
||||
}
|
||||
|
||||
@@ -122,6 +129,15 @@ export namespace Dbms {
|
||||
taskStatus: TaskStatus
|
||||
}
|
||||
|
||||
export interface StopBackupTaskParams {
|
||||
taskId: string
|
||||
}
|
||||
|
||||
export interface RestartBackupTaskParams {
|
||||
taskId: string
|
||||
temporaryPassword?: string
|
||||
}
|
||||
|
||||
export interface TaskListParams extends ReqPage {
|
||||
connectionId?: string
|
||||
taskStatus?: TaskStatus | ''
|
||||
@@ -134,6 +150,7 @@ export namespace Dbms {
|
||||
dbType: DbType
|
||||
operationType: OperationType
|
||||
backupStrategy?: BackupStrategy | null
|
||||
restoreMode?: RestoreMode | null
|
||||
taskStatus: TaskStatus
|
||||
schemaName?: string | null
|
||||
targetNamesJson?: string | null
|
||||
@@ -163,6 +180,7 @@ export namespace Dbms {
|
||||
backupMode?: BackupMode | null
|
||||
fileName: string
|
||||
filePath?: string | null
|
||||
metadataFilePath?: string | null
|
||||
logFileName?: string | null
|
||||
logFilePath?: string | null
|
||||
fileSize?: number | null
|
||||
|
||||
@@ -9,6 +9,86 @@ const buildIcdFormData = (icdFile: File) => {
|
||||
return formData
|
||||
}
|
||||
|
||||
const buildIcdPathFormData = (icdFile: File, request: MmsMapping.CreateIcdPathRequest | MmsMapping.UpdateIcdPathRequest) => {
|
||||
const formData = buildIcdFormData(icdFile)
|
||||
|
||||
formData.append('request', new Blob([JSON.stringify(request)], { type: 'application/json' }))
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
export const listDeviceTypesApi = () => {
|
||||
return http.get<MmsMapping.DeviceType[]>('/api/device-types')
|
||||
}
|
||||
|
||||
export const createDeviceTypeApi = (params: MmsMapping.CreateDeviceTypeRequest) => {
|
||||
return http.post<boolean>('/api/device-types/add', params)
|
||||
}
|
||||
|
||||
export const updateDeviceTypeApi = (params: MmsMapping.UpdateDeviceTypeRequest) => {
|
||||
return http.post<boolean>('/api/device-types/update', params)
|
||||
}
|
||||
|
||||
export const deleteDeviceTypesApi = (ids: string[]) => {
|
||||
return http.post<boolean>('/api/device-types/delete', ids)
|
||||
}
|
||||
|
||||
export const saveIcdCheckResultApi = (id: string, params: MmsMapping.SaveIcdCheckResultRequest) => {
|
||||
return http.post<boolean>(`/api/device-types/${id}/icd-check-result`, params)
|
||||
}
|
||||
|
||||
export const pqdifCheckApi = (id: string) => {
|
||||
return http.post<MmsMapping.PqdifCheckPlaceholder>(`/api/device-types/${id}/pqdif-check`)
|
||||
}
|
||||
|
||||
export const listIcdPathsApi = (params: MmsMapping.IcdPathListRequest) => {
|
||||
return http.post<MmsMapping.IcdPathRecord[]>('/api/mms-mapping/icd-paths/list', params)
|
||||
}
|
||||
|
||||
export const listIcdPathReferencesApi = () => {
|
||||
return http.post<MmsMapping.IcdPathReferenceOption[]>('/api/mms-mapping/icd-paths/reference-list')
|
||||
}
|
||||
|
||||
export const createIcdPathApi = (params: MmsMapping.CreateIcdPathRequest) => {
|
||||
return http.post<boolean>('/api/mms-mapping/icd-paths/add', params)
|
||||
}
|
||||
|
||||
export const createIcdPathWithFileApi = (params: MmsMapping.CreateIcdPathWithFileRequest) => {
|
||||
return http.post<boolean>('/api/mms-mapping/icd-paths/add', buildIcdPathFormData(params.icdFile, params.request), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const updateIcdPathApi = (params: MmsMapping.UpdateIcdPathRequest) => {
|
||||
return http.post<boolean>('/api/mms-mapping/icd-paths/update', params)
|
||||
}
|
||||
|
||||
export const updateIcdPathWithFileApi = (params: MmsMapping.UpdateIcdPathWithFileRequest) => {
|
||||
return http.post<boolean>('/api/mms-mapping/icd-paths/update', buildIcdPathFormData(params.icdFile, params.request), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const deleteIcdPathsApi = (ids: string[]) => {
|
||||
return http.post<boolean>('/api/mms-mapping/icd-paths/delete', ids)
|
||||
}
|
||||
|
||||
export const saveIcdPathCheckResultApi = (id: string, params: MmsMapping.SaveIcdPathCheckResultRequest) => {
|
||||
return http.post<boolean>(`/api/mms-mapping/icd-paths/${id}/icd-check-result`, params)
|
||||
}
|
||||
|
||||
export const getIcdPathCheckMsgApi = (id: string) => {
|
||||
return http.post<MmsMapping.IcdPathCheckMsgResponse>(`/api/mms-mapping/icd-paths/${id}/icd-check-msg`)
|
||||
}
|
||||
|
||||
export const getIcdPathMappingDetailApi = (id: string) => {
|
||||
return http.post<MmsMapping.IcdPathMappingDetailResponse>(`/api/mms-mapping/icd-paths/${id}/mapping-detail`)
|
||||
}
|
||||
|
||||
export const checkIcdJsonConsistencyApi = (params: MmsMapping.IcdJsonConsistencyCheckRequest) => {
|
||||
return http.post<MmsMapping.IcdJsonConsistencyCheckResponse>('/api/mms-mapping/check-icd-json-consistency', params)
|
||||
}
|
||||
|
||||
export const getIcdApi = (params: MmsMapping.GetIcdParams) => {
|
||||
const formData = buildIcdFormData(params.icdFile)
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ export namespace MmsMapping {
|
||||
|
||||
export interface GetXmlFromJsonRequestPayload {
|
||||
mappingJson: string
|
||||
configType?: number
|
||||
}
|
||||
|
||||
export interface GetXmlFromJsonParams {
|
||||
@@ -128,4 +129,144 @@ export namespace MmsMapping {
|
||||
version: string
|
||||
author: string
|
||||
}
|
||||
|
||||
export interface DeviceType {
|
||||
id?: string
|
||||
name?: string
|
||||
icdId?: string
|
||||
icdName?: string
|
||||
icdPath?: string
|
||||
icdResult?: number
|
||||
icdMsg?: string
|
||||
power?: string
|
||||
devVolt?: number
|
||||
devCurr?: number
|
||||
devChns?: number
|
||||
waveCmd?: string
|
||||
reportName?: string
|
||||
canCheckIcd?: boolean
|
||||
canCheckPqdif?: boolean
|
||||
}
|
||||
|
||||
export interface IcdCheckMsg {
|
||||
summary?: string
|
||||
details?: unknown[]
|
||||
issuesJson?: string
|
||||
correctedJson?: string
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export interface CreateDeviceTypeRequest {
|
||||
name: string
|
||||
icd?: string
|
||||
power?: string
|
||||
devVolt?: number
|
||||
devCurr?: number
|
||||
devChns?: number
|
||||
waveCmd?: string
|
||||
reportName?: string
|
||||
}
|
||||
|
||||
export interface UpdateDeviceTypeRequest extends CreateDeviceTypeRequest {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface SaveIcdCheckResultRequest {
|
||||
icd?: string
|
||||
icdDocument?: IcdDocument
|
||||
mappingJson?: string
|
||||
xml?: string
|
||||
result: number
|
||||
msg?: IcdCheckMsg
|
||||
}
|
||||
|
||||
export interface IcdPathRecord {
|
||||
id?: string
|
||||
name?: string
|
||||
angle?: number
|
||||
usePhaseIndex?: number
|
||||
state?: number
|
||||
jsonStr?: string
|
||||
xmlStr?: string
|
||||
result?: number
|
||||
msg?: IcdCheckMsg | string
|
||||
type?: number
|
||||
referenceIcdId?: string
|
||||
createBy?: string
|
||||
createTime?: string
|
||||
updateBy?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface IcdPathReferenceOption {
|
||||
id?: string
|
||||
name?: string
|
||||
}
|
||||
|
||||
export interface IcdPathMappingDetailResponse {
|
||||
id?: string
|
||||
name?: string
|
||||
jsonStr?: string
|
||||
xmlStr?: string
|
||||
icdText?: string
|
||||
}
|
||||
|
||||
export interface IcdPathListRequest {
|
||||
keyword?: string
|
||||
type?: number
|
||||
result?: number
|
||||
}
|
||||
|
||||
export interface CreateIcdPathRequest {
|
||||
name: string
|
||||
angle?: number
|
||||
usePhaseIndex?: number
|
||||
type?: number
|
||||
referenceIcdId?: string
|
||||
}
|
||||
|
||||
export interface CreateIcdPathWithFileRequest {
|
||||
icdFile: File
|
||||
request: CreateIcdPathRequest
|
||||
}
|
||||
|
||||
export interface UpdateIcdPathRequest extends CreateIcdPathRequest {
|
||||
id: string
|
||||
}
|
||||
|
||||
export interface UpdateIcdPathWithFileRequest {
|
||||
icdFile: File
|
||||
request: UpdateIcdPathRequest
|
||||
}
|
||||
|
||||
export interface SaveIcdPathCheckResultRequest {
|
||||
icd?: string
|
||||
icdDocument?: IcdDocument
|
||||
mappingJson?: string
|
||||
xml?: string
|
||||
result?: number
|
||||
msg?: IcdCheckMsg
|
||||
}
|
||||
|
||||
export type IcdPathCheckMsgResponse = IcdCheckMsg | null
|
||||
|
||||
export interface IcdJsonConsistencyCheckRequest {
|
||||
checkedJson: string
|
||||
standardJson: string
|
||||
saveToDisk?: boolean
|
||||
outputDir?: string
|
||||
}
|
||||
|
||||
export interface IcdJsonConsistencyCheckResponse {
|
||||
result?: number
|
||||
message?: string
|
||||
issues?: string[]
|
||||
issuesJson?: string
|
||||
correctedJson?: string
|
||||
}
|
||||
|
||||
export interface PqdifCheckPlaceholder {
|
||||
status?: string
|
||||
message?: string
|
||||
}
|
||||
}
|
||||
|
||||
72
frontend/src/api/tools/parsePqdif/index.ts
Normal file
72
frontend/src/api/tools/parsePqdif/index.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import http from '@/api'
|
||||
import type { ParsePqdif } from './interface'
|
||||
|
||||
const PQDIF_PATH_BASE_URL = '/api/parse-pqdif/pqdif-paths'
|
||||
|
||||
const buildPqdifPathFormData = (request: ParsePqdif.PqdifPathSaveParams, pqdifFile?: File | null) => {
|
||||
const formData = new FormData()
|
||||
|
||||
if (pqdifFile) {
|
||||
formData.append('pqdifFile', pqdifFile)
|
||||
}
|
||||
|
||||
// 关键业务节点:记录上传接口固定读取 request 这个 JSON part,字段名不能调整。
|
||||
formData.append('request', new Blob([JSON.stringify(request)], { type: 'application/json' }))
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
export const parsePqdifApi = (pqdifFile: File) => {
|
||||
const formData = new FormData()
|
||||
|
||||
// 关键业务节点:后端 @RequestPart 固定读取 pqdifFile,字段名不能与页面变量名脱钩。
|
||||
formData.append('pqdifFile', pqdifFile)
|
||||
|
||||
return http.post<ParsePqdif.ParseResponse>('/api/parse-pqdif/parse', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const listPqdifPathsApi = (params: ParsePqdif.PqdifPathListParams = {}) => {
|
||||
const request = { ...params }
|
||||
delete request.pageNum
|
||||
delete request.pageSize
|
||||
|
||||
return http.post<ParsePqdif.PqdifPathRecord[]>(`${PQDIF_PATH_BASE_URL}/list`, request)
|
||||
}
|
||||
|
||||
export const addPqdifPathApi = (params: ParsePqdif.PqdifPathSaveParams, pqdifFile?: File | null) => {
|
||||
if (pqdifFile) {
|
||||
return http.post<boolean>(`${PQDIF_PATH_BASE_URL}/add`, buildPqdifPathFormData(params, pqdifFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
return http.post<boolean>(`${PQDIF_PATH_BASE_URL}/add`, params)
|
||||
}
|
||||
|
||||
export const updatePqdifPathApi = (params: ParsePqdif.PqdifPathSaveParams, pqdifFile?: File | null) => {
|
||||
if (pqdifFile) {
|
||||
return http.post<boolean>(`${PQDIF_PATH_BASE_URL}/update`, buildPqdifPathFormData(params, pqdifFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
return http.post<boolean>(`${PQDIF_PATH_BASE_URL}/update`, params)
|
||||
}
|
||||
|
||||
export const deletePqdifPathsApi = (ids: string[]) => {
|
||||
return http.post<boolean>(`${PQDIF_PATH_BASE_URL}/delete`, ids)
|
||||
}
|
||||
|
||||
export const getPqdifParseMsgApi = (id: string) => {
|
||||
return http.post<ParsePqdif.PqdifParseMsg>(`${PQDIF_PATH_BASE_URL}/${id}/parse-msg`)
|
||||
}
|
||||
|
||||
export const getPqdifParseDetailApi = (id: string) => {
|
||||
return http.post<ParsePqdif.PqdifParseDetail>(`${PQDIF_PATH_BASE_URL}/${id}/parse-detail`)
|
||||
}
|
||||
|
||||
export const savePqdifParseResultApi = (id: string, params: ParsePqdif.SaveParseResultParams) => {
|
||||
return http.post<boolean>(`${PQDIF_PATH_BASE_URL}/${id}/parse-result`, params)
|
||||
}
|
||||
101
frontend/src/api/tools/parsePqdif/interface/index.ts
Normal file
101
frontend/src/api/tools/parsePqdif/interface/index.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
export namespace ParsePqdif {
|
||||
export type ParseStatus = 'SUCCESS' | 'FAILED' | (string & {})
|
||||
export type SeriesDataStatus = 'DATA_SUCCESS' | 'DATA_FAILED' | (string & {})
|
||||
export type ParseResultValue = 0 | 1
|
||||
|
||||
export interface RecordItem {
|
||||
recordIndex?: number
|
||||
typeGuid?: string
|
||||
typeName?: string
|
||||
observation?: boolean
|
||||
}
|
||||
|
||||
export interface SeriesItem {
|
||||
seriesIndex?: number
|
||||
quantityUnitsId?: number
|
||||
quantityCharacteristicGuid?: string
|
||||
valueTypeGuid?: string
|
||||
seriesBaseType?: number
|
||||
scale?: number
|
||||
offset?: number
|
||||
dataStatus?: SeriesDataStatus
|
||||
dataMessage?: string | null
|
||||
valueCount?: number
|
||||
firstValues?: number[]
|
||||
}
|
||||
|
||||
export interface ChannelItem {
|
||||
channelIndex?: number
|
||||
name?: string
|
||||
seriesCount?: number
|
||||
phaseId?: number
|
||||
quantityTypeGuid?: string
|
||||
quantityMeasuredId?: number
|
||||
series?: SeriesItem[]
|
||||
}
|
||||
|
||||
export interface ObservationItem {
|
||||
recordIndex?: number
|
||||
name?: string
|
||||
timeStartExcelDays?: number
|
||||
timeStartText?: string
|
||||
channelCount?: number
|
||||
channels?: ChannelItem[]
|
||||
}
|
||||
|
||||
export interface ParseResponse {
|
||||
status?: ParseStatus
|
||||
message?: string
|
||||
fileName?: string | null
|
||||
nativeVersion?: string | null
|
||||
recordCount?: number
|
||||
observationCount?: number
|
||||
sampleValueCount?: number
|
||||
records?: RecordItem[]
|
||||
observations?: ObservationItem[]
|
||||
}
|
||||
|
||||
export interface PqdifPathListParams {
|
||||
keyword?: string
|
||||
result?: ParseResultValue | ''
|
||||
pageNum?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface PqdifPathRecord {
|
||||
id?: string
|
||||
name?: string
|
||||
filePath?: string
|
||||
recordCount?: number
|
||||
observationCount?: number
|
||||
sampleValueCount?: number
|
||||
state?: number
|
||||
result?: ParseResultValue
|
||||
msg?: Record<string, unknown> | null
|
||||
createBy?: string
|
||||
createTime?: string
|
||||
updateBy?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
export interface PqdifPathSaveParams {
|
||||
id?: string
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface PqdifParseDetail {
|
||||
id?: string
|
||||
name?: string
|
||||
filePath?: string
|
||||
}
|
||||
|
||||
export type PqdifParseMsg = Record<string, unknown> | null
|
||||
|
||||
export interface SaveParseResultParams {
|
||||
recordCount?: number
|
||||
observationCount?: number
|
||||
sampleValueCount?: number
|
||||
result: ParseResultValue
|
||||
msg?: Record<string, unknown> | null
|
||||
}
|
||||
}
|
||||
@@ -20,60 +20,67 @@ export namespace Login {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 用户管理模块
|
||||
export namespace User {
|
||||
/**
|
||||
* 用户数据表格分页查询参数
|
||||
*/
|
||||
export interface ReqUserParams extends ReqPage {
|
||||
id: string // 装置序号用户ID 必填
|
||||
name?: string //用户名(别名)
|
||||
loginTime?: string //最后一次登录时间
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户数据表格分页查询参数
|
||||
*/
|
||||
export interface ReqUserParams extends ReqPage{
|
||||
id: string; // 装置序号用户ID 必填
|
||||
name?: string; //用户名(别名)
|
||||
loginTime?: string;//最后一次登录时间
|
||||
}
|
||||
// 用户接口
|
||||
export interface ResUser {
|
||||
id: string //用户ID,作为唯一标识
|
||||
name: string //用户名(别名)
|
||||
loginName: string //登录名
|
||||
deptId?: number //部门ID
|
||||
password: string //密码
|
||||
phone?: string //手机号
|
||||
email?: string //邮箱
|
||||
loginTime?: string //最后一次登录时间
|
||||
loginErrorTimes: number //登录错误次数
|
||||
lockTime?: string //用户密码错误锁定时间
|
||||
state: number //0-删除;1-正常;2-锁定;3-待审核;4-休眠;5-密码过期
|
||||
createBy?: string //创建用户
|
||||
createTime?: string //创建时间
|
||||
updateBy?: string //更新用户
|
||||
updateTime?: string //更新时间
|
||||
roleIds?: string[]
|
||||
roleNames?: string[]
|
||||
roleCodes?: string[]
|
||||
signatureFileId?: string
|
||||
signatureFileName?: string
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
// 用户接口
|
||||
export interface ResUser {
|
||||
id: string; //用户ID,作为唯一标识
|
||||
name: string; //用户名(别名)
|
||||
loginName: string;//登录名
|
||||
deptId?: number;//部门ID
|
||||
password: string; //密码
|
||||
phone?: string; //手机号
|
||||
email?: string; //邮箱
|
||||
loginTime?: string;//最后一次登录时间
|
||||
loginErrorTimes: number;//登录错误次数
|
||||
lockTime?: string; //用户密码错误锁定时间
|
||||
state:number;//0-删除;1-正常;2-锁定;3-待审核;4-休眠;5-密码过期
|
||||
createBy?: string;//创建用户
|
||||
createTime?: string;//创建时间
|
||||
updateBy?: string;//更新用户
|
||||
updateTime?: string;//更新时间
|
||||
roleIds?: string[]; //
|
||||
roleNames?:string[]; //
|
||||
roleCodes?:string[]; //
|
||||
disabled?: boolean;
|
||||
}
|
||||
export interface UserSaveRequest {
|
||||
id?: string
|
||||
name: string
|
||||
loginName?: string
|
||||
password?: string
|
||||
deptId?: string | number
|
||||
phone?: string
|
||||
email?: string
|
||||
roleIds?: string[]
|
||||
}
|
||||
|
||||
// 用户接口
|
||||
export interface ResPassWordUser {
|
||||
id: string; //用户ID,作为唯一标识
|
||||
oldPassword: string; //密码
|
||||
newPassword: string; //新密码
|
||||
surePassword:string;
|
||||
}
|
||||
// 用户接口
|
||||
export interface ResPassWordUser {
|
||||
id: string //用户ID,作为唯一标识
|
||||
oldPassword: string //密码
|
||||
newPassword: string //新密码
|
||||
surePassword: string
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResUserPage extends ResPage<ResUser> {}
|
||||
// // 用户+分页
|
||||
// export interface ReqUserParams extends ReqPage,UserBO {
|
||||
|
||||
/**
|
||||
* 用户表格查询分页返回的对象;
|
||||
*/
|
||||
export interface ResUserPage extends ResPage<ResUser> {
|
||||
|
||||
}
|
||||
// // 用户+分页
|
||||
// export interface ReqUserParams extends ReqPage,UserBO {
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -1,43 +1,65 @@
|
||||
import type { AxiosResponse } from 'axios'
|
||||
import http from '@/api'
|
||||
import type { Role } from '@/api/user/interface/role'
|
||||
import type { User } from '@/api/user/interface/user'
|
||||
import http from '@/api'
|
||||
|
||||
const buildUserFormData = (request: User.UserSaveRequest, signatureFile?: File | null) => {
|
||||
const formData = new FormData()
|
||||
|
||||
// 关键业务节点:新增和编辑用户都按 request JSON Part + signatureFile 文件分段提交,字段名必须与后端 @RequestPart 保持一致。
|
||||
formData.append('request', new Blob([JSON.stringify(request)], { type: 'application/json' }))
|
||||
|
||||
if (signatureFile) {
|
||||
formData.append('signatureFile', signatureFile)
|
||||
}
|
||||
|
||||
return formData
|
||||
}
|
||||
|
||||
/**
|
||||
* @name 用户管理模块
|
||||
*/
|
||||
// 获取用户列表
|
||||
export const getUserList = (params: User.ReqUserParams) => {
|
||||
return http.post(`/sysUser/list`, params)
|
||||
return http.post(`/sysUser/list`, params)
|
||||
}
|
||||
|
||||
|
||||
// 新增用户
|
||||
export const addUser = (params: User.ResUser) => {
|
||||
return http.post(`/sysUser/add`, params)
|
||||
export const addUser = (request: User.UserSaveRequest, signatureFile?: File | null) => {
|
||||
return http.post(`/sysUser/add`, buildUserFormData(request, signatureFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
// 编辑用户
|
||||
export const updateUser = (params: User.ResUser) => {
|
||||
return http.post(`/sysUser/update`, params)
|
||||
export const updateUser = (request: User.UserSaveRequest, signatureFile?: File | null) => {
|
||||
return http.post(`/sysUser/update`, buildUserFormData(request, signatureFile), {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
// 删除用户
|
||||
export const deleteUser = (params: string[] ) => {
|
||||
return http.post(`/sysUser/delete`, params)
|
||||
export const deleteUser = (params: string[]) => {
|
||||
return http.post(`/sysUser/delete`, params)
|
||||
}
|
||||
|
||||
|
||||
// 获取角色列表
|
||||
export const getRoleList = () => {
|
||||
return http.get<Role.RoleBO>(`/sysRole/simpleList`)
|
||||
return http.get<Role.RoleBO>(`/sysRole/simpleList`)
|
||||
}
|
||||
|
||||
//修改密码
|
||||
// 修改密码
|
||||
export const updatePassWord = (params: User.ResPassWordUser) => {
|
||||
return http.post(`/sysUser/updatePassword`,params)
|
||||
return http.post(`/sysUser/updatePassword`, params)
|
||||
}
|
||||
|
||||
// 获取所有用户
|
||||
export const getAllUser= () => {
|
||||
return http.get(`/sysUser/getAll`)
|
||||
export const getAllUser = () => {
|
||||
return http.get(`/sysUser/getAll`)
|
||||
}
|
||||
|
||||
export const previewUserSignature = (id: string): Promise<AxiosResponse<Blob>> => {
|
||||
return http.get(`/sysUser/${id}/signature`, undefined, { responseType: 'blob' }) as unknown as Promise<
|
||||
AxiosResponse<Blob>
|
||||
>
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang='ts' name='Grid'>
|
||||
import type { VNode, VNodeArrayChildren } from 'vue'
|
||||
import type { BreakPoint } from './interface/index'
|
||||
|
||||
type Props = {
|
||||
@@ -99,11 +100,12 @@ const findIndex = () => {
|
||||
}
|
||||
try {
|
||||
let find = false
|
||||
fields.reduce((prev = 0, current, index) => {
|
||||
fields.reduce((prev: number, current: unknown, index: number) => {
|
||||
prev +=
|
||||
((current as VNode)!.props![breakPoint.value]?.span ?? (current as VNode)!.props?.span ?? 1) +
|
||||
((current as VNode)!.props![breakPoint.value]?.offset ?? (current as VNode)!.props?.offset ?? 0)
|
||||
if (Number(prev) >= props.collapsedRows * gridCols.value - suffixCols) {
|
||||
// 刚好填满首行时仍应显示当前项,只有超过可用列数才进入折叠。
|
||||
if (Number(prev) > props.collapsedRows * gridCols.value - suffixCols) {
|
||||
hiddenIndex.value = index
|
||||
find = true
|
||||
throw 'find it'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<component
|
||||
v-if="!column.search?.render"
|
||||
:is="column.search?.render ?? `el-${column.search?.el}`"
|
||||
v-bind="{ ...handleSearchProps, ...placeholder, searchParam: _searchParam, clearable }"
|
||||
v-model.trim="_searchParam[column.search?.key ?? handleProp(column.prop!)]"
|
||||
@@ -20,12 +21,19 @@
|
||||
</template>
|
||||
<slot v-else></slot>
|
||||
</component>
|
||||
<component
|
||||
v-else
|
||||
:is="column.search.render"
|
||||
v-bind="{ ...handleSearchProps, ...placeholder, searchParam: _searchParam, clearable }"
|
||||
:data="column.search?.el === 'tree-select' ? columnEnum : []"
|
||||
:options="['cascader', 'select-v2'].includes(column.search?.el!) ? columnEnum : []"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="SearchFormItem">
|
||||
import { computed, inject, ref } from "vue";
|
||||
import { handleProp } from "@/utils";
|
||||
import { ColumnProps } from "@/components/ProTable/interface";
|
||||
import type { ColumnProps } from "@/components/ProTable/interface";
|
||||
|
||||
interface SearchFormItem {
|
||||
column: ColumnProps;
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang='ts' name='SearchForm'>
|
||||
import { ColumnProps } from '@/components/ProTable/interface'
|
||||
import { BreakPoint } from '@/components/Grid/interface'
|
||||
import type { ColumnProps } from '@/components/ProTable/interface'
|
||||
import type { BreakPoint } from '@/components/Grid/interface'
|
||||
import { Delete, Search, ArrowDown, ArrowUp } from '@element-plus/icons-vue'
|
||||
import SearchFormItem from './components/SearchFormItem.vue'
|
||||
import Grid from '@/components/Grid/index.vue'
|
||||
@@ -80,15 +80,15 @@ const breakPoint = computed<BreakPoint>(() => gridRef.value?.breakPoint)
|
||||
// 判断是否显示 展开/合并 按钮
|
||||
const showCollapse = computed(() => {
|
||||
let show = false
|
||||
const searchColCount =
|
||||
typeof props.searchCol !== 'number' ? props.searchCol[breakPoint.value] : props.searchCol
|
||||
const firstRowSearchCols = Math.max(searchColCount - 1, 1)
|
||||
|
||||
props.columns.reduce((prev, current) => {
|
||||
prev +=
|
||||
(current.search![breakPoint.value]?.span ?? current.search?.span ?? 1) +
|
||||
(current.search![breakPoint.value]?.offset ?? current.search?.offset ?? 0)
|
||||
if (typeof props.searchCol !== 'number') {
|
||||
if (prev >= props.searchCol[breakPoint.value]) show = true
|
||||
} else {
|
||||
if (prev >= props.searchCol) show = true
|
||||
}
|
||||
if (prev > firstRowSearchCols) show = true
|
||||
return prev
|
||||
}, 0)
|
||||
return show
|
||||
|
||||
@@ -138,7 +138,7 @@ const getSeriesTimeRange = () => {
|
||||
let maxTime = Number.NEGATIVE_INFINITY
|
||||
|
||||
seriesList.forEach((series: { data?: unknown[] }) => {
|
||||
;(series.data || []).forEach(point => {
|
||||
(series.data || []).forEach(point => {
|
||||
const timestamp = resolveTimeValue(point)
|
||||
|
||||
if (timestamp === undefined) return
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
export const DICT_CODES = {
|
||||
USER_STATE: 'state',
|
||||
EVENT_TYPE: 'event_type',
|
||||
TEST_REPORT_COMPANY: 'test_report_company',
|
||||
TEST_REPORT_STANDARD: 'test_report_standard',
|
||||
LEDGER_DEVICE_TYPE: 'ledger_device_type',
|
||||
LEDGER_DEVICE_MODEL: 'Ex-factory_Dev_Type',
|
||||
LEDGER_TERMINAL_MODEL: 'Dev_Type'
|
||||
LEDGER_TERMINAL_MODEL: 'Dev_Type',
|
||||
DEVICE_TYPE_WORK_POWER: 'Dev_Power',
|
||||
DEVICE_TYPE_CHANNEL_COUNT: 'Dev_Chns',
|
||||
DEVICE_TYPE_RATED_VOLTAGE: 'Dev_Volt',
|
||||
DEVICE_TYPE_RATED_CURRENT: 'Dev_Curr'
|
||||
} as const
|
||||
|
||||
export type DictCode = (typeof DICT_CODES)[keyof typeof DICT_CODES]
|
||||
|
||||
@@ -17,8 +17,8 @@ const routeContracts = [
|
||||
['toolAddData', 'src/views/tools/addData/index.vue'],
|
||||
['toolAddLedger', 'src/views/tools/addLedger/index.vue'],
|
||||
['eventList', 'src/views/event/eventList/index.vue'],
|
||||
['systemMonitor', 'src/views/systemMonitor/index.vue'],
|
||||
['diskMonitor', 'src/views/systemMonitor/diskMonitor/index.vue']
|
||||
['system-monitor', 'src/views/system-monitor/index.vue'],
|
||||
['diskMonitor', 'src/views/system-monitor/diskMonitor/index.vue']
|
||||
]
|
||||
|
||||
const extractRouteBlock = routeName => {
|
||||
|
||||
@@ -89,12 +89,6 @@ router.beforeEach(async (to, from, next) => {
|
||||
}
|
||||
}
|
||||
|
||||
syncHomeStateWithMenus()
|
||||
logRouterPerf('before-each-menu-sync', guardStart, {
|
||||
path: to.path,
|
||||
from: from.path,
|
||||
hasActivateInfo: authStore.activateInfoLoadedGet
|
||||
})
|
||||
await authStore.setRouteName(to.name as string)
|
||||
|
||||
if (!authStore.activateInfoLoadedGet) {
|
||||
|
||||
@@ -9,12 +9,19 @@ const staticRouterSource = read('routers/modules/staticRouter.ts')
|
||||
const authStoreSource = read('stores/modules/auth.ts')
|
||||
|
||||
const expectedPaths = [
|
||||
'/system-monitor/dbms',
|
||||
'/system-monitor/dbms/index',
|
||||
'/system-monitor/databaseMonitor',
|
||||
'/system-monitor/databaseMonitor/index',
|
||||
'/system-monitor/database-monitor',
|
||||
'/system-monitor/database-monitor/index',
|
||||
'/systemMonitor/dbms',
|
||||
'/systemMonitor/dbms/index',
|
||||
'/systemMonitor/databaseMonitor',
|
||||
'/systemMonitor/databaseMonitor/index',
|
||||
'/systemMonitor/database-monitor',
|
||||
'/systemMonitor/database-monitor/index',
|
||||
'/system-ops/dbms/index',
|
||||
'/system-ops/database-monitor',
|
||||
'/system-ops/database-monitor/index'
|
||||
]
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
const srcRoot = path.resolve(currentDir, '../..')
|
||||
|
||||
const files = {
|
||||
router: path.resolve(srcRoot, 'routers/index.ts'),
|
||||
authStore: path.resolve(srcRoot, 'stores/modules/auth.ts'),
|
||||
utils: path.resolve(srcRoot, 'utils/index.ts')
|
||||
}
|
||||
|
||||
const read = file => fs.readFileSync(file, 'utf8')
|
||||
|
||||
const routerSource = read(files.router)
|
||||
const authStoreSource = read(files.authStore)
|
||||
const utilsSource = read(files.utils)
|
||||
|
||||
const expectations = [
|
||||
{
|
||||
name: 'auth store owns cached flat/show/breadcrumb menu state',
|
||||
pass:
|
||||
/flatMenuList:\s*\[\]/.test(authStoreSource) &&
|
||||
/showMenuList:\s*\[\]/.test(authStoreSource) &&
|
||||
/breadcrumbList:\s*\{\}/.test(authStoreSource)
|
||||
},
|
||||
{
|
||||
name: 'auth store refreshes derived menus when auth menu list changes',
|
||||
pass: /refreshDerivedMenus\(\)/.test(authStoreSource) && /this\.refreshDerivedMenus\(\)/.test(authStoreSource)
|
||||
},
|
||||
{
|
||||
name: 'menu derivation helpers avoid JSON stringify deep clone',
|
||||
pass:
|
||||
!/getFlatMenuList[\s\S]*JSON\.parse\(JSON\.stringify/.test(utilsSource) &&
|
||||
!/getShowMenuList[\s\S]*JSON\.parse\(JSON\.stringify/.test(utilsSource)
|
||||
},
|
||||
{
|
||||
name: 'router beforeEach does not sync home state on every navigation',
|
||||
pass: !/before-each-menu-sync/.test(routerSource)
|
||||
},
|
||||
{
|
||||
name: 'router syncs home state after dynamic menu initialization',
|
||||
pass: /syncHomeStateWithMenus\(\)/.test(routerSource) && /first-sync-home-state/.test(routerSource)
|
||||
}
|
||||
]
|
||||
|
||||
const failures = expectations.filter(item => !item.pass)
|
||||
|
||||
if (failures.length) {
|
||||
console.error('Menu navigation performance contract failed:')
|
||||
failures.forEach(item => console.error(`- ${item.name}`))
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log('Menu navigation performance contract passed')
|
||||
@@ -27,6 +27,12 @@ const COMPONENT_PATH_ALIASES: Record<string, string> = {
|
||||
'/steady/check-square': '/steady/checksquare',
|
||||
'/steady/check-square/index': '/steady/checksquare/index',
|
||||
// 数据库监控菜单统一落到 system-ops/dbms 页面,兼容后端菜单常见 component 写法。
|
||||
'/system-monitor/dbms': '/system-ops/dbms',
|
||||
'/system-monitor/dbms/index': '/system-ops/dbms/index',
|
||||
'/system-monitor/databaseMonitor': '/system-ops/dbms',
|
||||
'/system-monitor/databaseMonitor/index': '/system-ops/dbms/index',
|
||||
'/system-monitor/database-monitor': '/system-ops/dbms',
|
||||
'/system-monitor/database-monitor/index': '/system-ops/dbms/index',
|
||||
'/systemMonitor/dbms': '/system-ops/dbms',
|
||||
'/systemMonitor/dbms/index': '/system-ops/dbms/index',
|
||||
'/systemMonitor/databaseMonitor': '/system-ops/dbms',
|
||||
@@ -34,7 +40,20 @@ const COMPONENT_PATH_ALIASES: Record<string, string> = {
|
||||
'/systemMonitor/database-monitor': '/system-ops/dbms',
|
||||
'/systemMonitor/database-monitor/index': '/system-ops/dbms/index',
|
||||
'/system-ops/database-monitor': '/system-ops/dbms',
|
||||
'/system-ops/database-monitor/index': '/system-ops/dbms/index'
|
||||
'/system-ops/database-monitor/index': '/system-ops/dbms/index',
|
||||
// 报告菜单后端使用 aiReport,前端目录沿用既有 aireport 命名。
|
||||
'/aiReport/reportTask': '/aireport/testReport',
|
||||
'/aiReport/reportTask/index': '/aireport/testReport/index',
|
||||
'/aiReport/testReport': '/aireport/testReport',
|
||||
'/aiReport/testReport/index': '/aireport/testReport/index',
|
||||
'/aiReport/reportModel': '/aireport/reportModel',
|
||||
'/aiReport/reportModel/index': '/aireport/reportModel/index',
|
||||
'/aiReport/clientUnit': '/aireport/clientUnit',
|
||||
'/aiReport/clientUnit/index': '/aireport/clientUnit/index',
|
||||
'/aiReport/testDevice': '/aireport/testDevice',
|
||||
'/aiReport/testDevice/index': '/aireport/testDevice/index',
|
||||
'/aiReport/reportApproval': '/aireport/reportApproval',
|
||||
'/aiReport/reportApproval/index': '/aireport/reportApproval/index'
|
||||
}
|
||||
const STATIC_ROUTE_NAMES = new Set([
|
||||
'layout',
|
||||
@@ -43,12 +62,15 @@ const STATIC_ROUTE_NAMES = new Set([
|
||||
'tools',
|
||||
'toolWaveform',
|
||||
'toolMmsMapping',
|
||||
'toolParsePqdif',
|
||||
'deviceTypes',
|
||||
'toolAddData',
|
||||
'toolAddLedger',
|
||||
'eventList',
|
||||
'steadyDataView',
|
||||
'steadyTrend',
|
||||
'checksquare',
|
||||
'system-monitor',
|
||||
'systemMonitor',
|
||||
'diskMonitor',
|
||||
'systemOpsDbms',
|
||||
|
||||
@@ -60,7 +60,25 @@ export const staticRouter: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/tools/mmsMapping/index.vue'),
|
||||
meta: {
|
||||
cacheName: 'MmsMappingView',
|
||||
title: 'MMS 映射'
|
||||
title: '模型映射管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/tools/parsePqdif',
|
||||
name: 'toolParsePqdif',
|
||||
component: () => import('@/views/tools/parsePqdif/index.vue'),
|
||||
meta: {
|
||||
cacheName: 'ParsePqdifView',
|
||||
title: 'PQDIF解析'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/tools/deviceTypes',
|
||||
name: 'deviceTypes',
|
||||
component: () => import('@/views/tools/deviceTypes/index.vue'),
|
||||
meta: {
|
||||
cacheName: 'MmsDeviceTypesView',
|
||||
title: '设备类型管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -149,7 +167,7 @@ export const staticRouter: RouteRecordRaw[] = [
|
||||
component: () => import('@/views/steady/checksquare/index.vue'),
|
||||
meta: {
|
||||
cacheName: 'ChecksquareView',
|
||||
title: '数据验证入库'
|
||||
title: '数据验证'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -177,24 +195,26 @@ export const staticRouter: RouteRecordRaw[] = [
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/systemMonitor',
|
||||
name: 'systemMonitor',
|
||||
component: () => import('@/views/systemMonitor/index.vue'),
|
||||
path: '/system-monitor',
|
||||
name: 'system-monitor',
|
||||
alias: ['/systemMonitor'],
|
||||
component: () => import('@/views/system-monitor/index.vue'),
|
||||
meta: {
|
||||
cacheName: 'SystemMonitorPage',
|
||||
title: '系统监控'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/systemMonitor/diskMonitor',
|
||||
path: '/system-monitor/diskMonitor',
|
||||
name: 'diskMonitor',
|
||||
component: () => import('@/views/systemMonitor/diskMonitor/index.vue'),
|
||||
alias: ['/systemMonitor/diskMonitor'],
|
||||
component: () => import('@/views/system-monitor/diskMonitor/index.vue'),
|
||||
meta: {
|
||||
cacheName: 'DiskMonitorPage',
|
||||
// 磁盘监控页复用系统监控主标签
|
||||
activeMenu: '/systemMonitor',
|
||||
activeMenu: '/system-monitor',
|
||||
hideTab: true,
|
||||
parentPath: '/systemMonitor',
|
||||
parentPath: '/system-monitor',
|
||||
title: '磁盘监控'
|
||||
}
|
||||
},
|
||||
@@ -202,12 +222,19 @@ export const staticRouter: RouteRecordRaw[] = [
|
||||
path: '/system-ops/dbms',
|
||||
name: 'systemOpsDbms',
|
||||
alias: [
|
||||
'/system-monitor/dbms',
|
||||
'/system-monitor/dbms/index',
|
||||
'/system-monitor/databaseMonitor',
|
||||
'/system-monitor/databaseMonitor/index',
|
||||
'/system-monitor/database-monitor',
|
||||
'/system-monitor/database-monitor/index',
|
||||
'/systemMonitor/dbms',
|
||||
'/systemMonitor/dbms/index',
|
||||
'/systemMonitor/databaseMonitor',
|
||||
'/systemMonitor/databaseMonitor/index',
|
||||
'/systemMonitor/database-monitor',
|
||||
'/systemMonitor/database-monitor/index',
|
||||
'/system-ops/dbms/index',
|
||||
'/system-ops/database-monitor',
|
||||
'/system-ops/database-monitor/index'
|
||||
],
|
||||
|
||||
@@ -60,6 +60,9 @@ export interface AuthState {
|
||||
[key: string]: string[]
|
||||
}
|
||||
authMenuList: Menu.MenuOptions[]
|
||||
showMenuList: Menu.MenuOptions[]
|
||||
flatMenuList: Menu.MenuOptions[]
|
||||
breadcrumbList: { [key: string]: Menu.MenuOptions[] }
|
||||
showMenuFlag: boolean
|
||||
activateInfo: Activate.ActivationCodePlaintext
|
||||
activateInfoLoaded: boolean
|
||||
|
||||
@@ -10,6 +10,9 @@ export const useAuthStore = defineStore(AUTH_STORE_KEY, {
|
||||
state: (): AuthState => ({
|
||||
authButtonList: {},
|
||||
authMenuList: [],
|
||||
showMenuList: [],
|
||||
flatMenuList: [],
|
||||
breadcrumbList: {},
|
||||
routeName: '',
|
||||
showMenuFlag: localStorage.getItem('showMenuFlag') === 'true',
|
||||
activateInfo: {} as Activate.ActivationCodePlaintext,
|
||||
@@ -18,9 +21,9 @@ export const useAuthStore = defineStore(AUTH_STORE_KEY, {
|
||||
getters: {
|
||||
authButtonListGet: state => state.authButtonList,
|
||||
authMenuListGet: state => state.authMenuList,
|
||||
showMenuListGet: state => getShowMenuList(state.authMenuList),
|
||||
flatMenuListGet: state => getFlatMenuList(state.authMenuList),
|
||||
breadcrumbListGet: state => getAllBreadcrumbList(state.authMenuList),
|
||||
showMenuListGet: state => state.showMenuList,
|
||||
flatMenuListGet: state => state.flatMenuList,
|
||||
breadcrumbListGet: state => state.breadcrumbList,
|
||||
showMenuFlagGet: state => state.showMenuFlag,
|
||||
activateInfoGet: state => state.activateInfo,
|
||||
activateInfoLoadedGet: state => state.activateInfoLoaded
|
||||
@@ -33,6 +36,13 @@ export const useAuthStore = defineStore(AUTH_STORE_KEY, {
|
||||
async getAuthMenuList() {
|
||||
const { data: menuData } = await getAuthMenuListApi()
|
||||
this.authMenuList = normalizeBusinessMenus(filterBusinessMenus(menuData))
|
||||
// 菜单派生数据只在菜单源数据变化时重算,避免每次路由跳转都深拷贝整棵菜单。
|
||||
this.refreshDerivedMenus()
|
||||
},
|
||||
refreshDerivedMenus() {
|
||||
this.showMenuList = getShowMenuList(this.authMenuList)
|
||||
this.flatMenuList = getFlatMenuList(this.authMenuList)
|
||||
this.breadcrumbList = getAllBreadcrumbList(this.authMenuList)
|
||||
},
|
||||
async setRouteName(name: string) {
|
||||
this.routeName = name
|
||||
@@ -40,6 +50,9 @@ export const useAuthStore = defineStore(AUTH_STORE_KEY, {
|
||||
async resetAuthStore() {
|
||||
this.authButtonList = {}
|
||||
this.authMenuList = []
|
||||
this.showMenuList = []
|
||||
this.flatMenuList = []
|
||||
this.breadcrumbList = {}
|
||||
this.routeName = ''
|
||||
this.showMenuFlag = false
|
||||
this.activateInfo = {}
|
||||
|
||||
7
frontend/src/types/vite-plugin-eslint.d.ts
vendored
Normal file
7
frontend/src/types/vite-plugin-eslint.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
declare module 'vite-plugin-eslint' {
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
const eslintPlugin: (options?: Record<string, unknown>) => Plugin
|
||||
|
||||
export default eslintPlugin
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isArray, isNumber } from '@/utils/is'
|
||||
import { FieldNamesProps } from '@/components/ProTable/interface'
|
||||
import type { FieldNamesProps } from '@/components/ProTable/interface'
|
||||
|
||||
const mode = import.meta.env.VITE_ROUTER_MODE
|
||||
|
||||
@@ -152,8 +152,7 @@ export function getUrlWithParams() {
|
||||
* @returns {Array}
|
||||
*/
|
||||
export function getFlatMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[] {
|
||||
const newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList))
|
||||
return newMenuList.flatMap(item => [item, ...(item.children ? getFlatMenuList(item.children) : [])])
|
||||
return menuList.flatMap(item => [item, ...(item.children?.length ? getFlatMenuList(item.children) : [])])
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,12 +160,13 @@ export function getFlatMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[
|
||||
* @param {Array} menuList 菜单列表
|
||||
* @returns {Array}
|
||||
* */
|
||||
export function getShowMenuList(menuList: Menu.MenuOptions[]) {
|
||||
const newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList))
|
||||
return newMenuList.filter(item => {
|
||||
item.children?.length && (item.children = getShowMenuList(item.children))
|
||||
return !item.meta?.isHide
|
||||
})
|
||||
export function getShowMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[] {
|
||||
return menuList
|
||||
.filter(item => !item.meta?.isHide)
|
||||
.map(item => ({
|
||||
...item,
|
||||
children: item.children?.length ? getShowMenuList(item.children) : item.children
|
||||
}))
|
||||
}
|
||||
|
||||
export function getFirstMenuPath(menuList: Menu.MenuOptions[]): string {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<el-dialog v-model="visibleProxy" title="委托单位详情" width="720px" append-to-body destroy-on-close>
|
||||
<div v-loading="loading" class="client-unit-detail-dialog">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="单位名称">{{ resolveClientUnitText(detail?.name) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="联系人">{{ resolveClientUnitText(detail?.contactName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="联系方式">{{ resolveClientUnitText(detail?.phonenumber) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="地址">{{ resolveClientUnitText(detail?.address) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人">{{ resolveClientUnitText(detail?.createBy) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ resolveClientUnitText(detail?.createTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新人">{{ resolveClientUnitText(detail?.updateBy) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ resolveClientUnitText(detail?.updateTime) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { ClientUnit } from '@/api/aireport/clientUnit/interface'
|
||||
import { resolveClientUnitText } from '../utils/clientUnit'
|
||||
|
||||
defineOptions({
|
||||
name: 'ClientUnitDetailDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
loading: boolean
|
||||
detail: ClientUnit.ClientUnitRecord | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
}>()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.client-unit-detail-dialog {
|
||||
min-height: 180px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,135 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
:title="mode === 'create' ? '新增委托单位' : '编辑委托单位'"
|
||||
width="620px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@closed="resetForm"
|
||||
>
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="96px">
|
||||
<el-form-item label="单位名称" prop="name">
|
||||
<el-input v-model="formModel.name" maxlength="32" show-word-limit placeholder="请输入单位名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系人" prop="contactName">
|
||||
<el-input v-model="formModel.contactName" maxlength="200" show-word-limit placeholder="请输入联系人" />
|
||||
</el-form-item>
|
||||
<el-form-item label="联系方式" prop="phonenumber">
|
||||
<el-input v-model="formModel.phonenumber" maxlength="32" show-word-limit placeholder="请输入联系方式" />
|
||||
</el-form-item>
|
||||
<el-form-item label="地址" prop="address">
|
||||
<el-input
|
||||
v-model="formModel.address"
|
||||
type="textarea"
|
||||
maxlength="128"
|
||||
show-word-limit
|
||||
:rows="3"
|
||||
placeholder="请输入地址"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submitForm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormItemRule, type FormRules } from 'element-plus'
|
||||
import type { ClientUnit } from '@/api/aireport/clientUnit/interface'
|
||||
import { sanitizeClientUnitFormText } from '../utils/clientUnit'
|
||||
|
||||
defineOptions({
|
||||
name: 'ClientUnitFormDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
record: ClientUnit.ClientUnitRecord | null
|
||||
saving: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: ClientUnit.ClientUnitSaveRequest): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const formModel = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
contactName: '',
|
||||
phonenumber: '',
|
||||
address: ''
|
||||
})
|
||||
|
||||
const MOBILE_PHONE_REGEXP = /^1[3-9]\d{9}$/
|
||||
|
||||
const validatePhoneNumber: FormItemRule['validator'] = (_rule, value, callback) => {
|
||||
const normalizedValue = String(value || '').trim()
|
||||
|
||||
if (!normalizedValue || MOBILE_PHONE_REGEXP.test(normalizedValue)) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
|
||||
callback(new Error('请输入正确的手机号'))
|
||||
}
|
||||
|
||||
const formRules: FormRules = {
|
||||
name: [{ required: true, message: '请输入单位名称', trigger: 'blur' }],
|
||||
phonenumber: [{ validator: validatePhoneNumber, trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value?.clearValidate()
|
||||
formModel.id = ''
|
||||
formModel.name = ''
|
||||
formModel.contactName = ''
|
||||
formModel.phonenumber = ''
|
||||
formModel.address = ''
|
||||
}
|
||||
|
||||
const fillForm = () => {
|
||||
formModel.id = props.record?.id || ''
|
||||
formModel.name = sanitizeClientUnitFormText(props.record?.name)
|
||||
formModel.contactName = sanitizeClientUnitFormText(props.record?.contactName)
|
||||
formModel.phonenumber = sanitizeClientUnitFormText(props.record?.phonenumber)
|
||||
formModel.address = sanitizeClientUnitFormText(props.record?.address)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.mode, props.record?.id],
|
||||
([visible]) => {
|
||||
if (visible) fillForm()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const submitForm = async () => {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
|
||||
if (!valid) return
|
||||
|
||||
if (props.mode === 'edit' && !formModel.id) {
|
||||
ElMessage.warning('当前委托单位缺少 ID,无法保存编辑')
|
||||
return
|
||||
}
|
||||
|
||||
emit('submit', {
|
||||
id: formModel.id || undefined,
|
||||
name: formModel.name.trim(),
|
||||
contactName: formModel.contactName.trim() || null,
|
||||
phonenumber: formModel.phonenumber.trim() || null,
|
||||
address: formModel.address.trim() || null
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<el-dialog v-model="visibleProxy" title="导入委托单位" width="640px" append-to-body destroy-on-close @closed="resetImport">
|
||||
<div class="client-unit-import-dialog">
|
||||
<div class="file-select-row">
|
||||
<el-input :model-value="selectedFileName" readonly placeholder="请选择 .xlsx 文件" />
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="importing" @click="openFilePicker">
|
||||
选择文件
|
||||
</el-button>
|
||||
<input ref="fileInputRef" class="hidden-file-input" type="file" accept=".xlsx" @change="handleFileChange" />
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="result"
|
||||
class="import-result"
|
||||
:title="`导入完成:成功 ${result.successCount || 0} 条,失败 ${result.failCount || 0} 条`"
|
||||
:type="result.failCount ? 'warning' : 'success'"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<el-table v-if="result?.failReasons?.length" class="fail-reason-table" :data="failReasonRows" border>
|
||||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||||
<el-table-column prop="reason" label="失败原因" min-width="220" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button :disabled="importing" @click="visibleProxy = false">取消</el-button>
|
||||
<el-button type="primary" :loading="importing" @click="submitImport">开始导入</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { FolderOpened } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { ClientUnit } from '@/api/aireport/clientUnit/interface'
|
||||
|
||||
defineOptions({
|
||||
name: 'ClientUnitImportDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
importing: boolean
|
||||
result: ClientUnit.ClientUnitImportResult | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: File): void
|
||||
}>()
|
||||
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const selectedFile = ref<File | null>(null)
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const selectedFileName = computed(() => selectedFile.value?.name || '')
|
||||
const failReasonRows = computed(() => (props.result?.failReasons || []).map(reason => ({ reason })))
|
||||
|
||||
const openFilePicker = () => {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const handleFileChange = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0] || null
|
||||
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
|
||||
selectedFile.value = file
|
||||
}
|
||||
|
||||
const resetImport = () => {
|
||||
selectedFile.value = null
|
||||
}
|
||||
|
||||
const submitImport = () => {
|
||||
if (!selectedFile.value) {
|
||||
ElMessage.warning('请选择要导入的文件')
|
||||
return
|
||||
}
|
||||
|
||||
emit('submit', selectedFile.value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.client-unit-import-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.file-select-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fail-reason-table {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,102 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const rootDir = path.resolve(process.cwd(), 'frontend/src')
|
||||
const pageFile = path.resolve(rootDir, 'views/aireport/clientUnit/index.vue')
|
||||
const apiFile = path.resolve(rootDir, 'api/aireport/clientUnit/index.ts')
|
||||
const formDialogFile = path.resolve(rootDir, 'views/aireport/clientUnit/components/ClientUnitFormDialog.vue')
|
||||
const detailDialogFile = path.resolve(rootDir, 'views/aireport/clientUnit/components/ClientUnitDetailDialog.vue')
|
||||
const importDialogFile = path.resolve(rootDir, 'views/aireport/clientUnit/components/ClientUnitImportDialog.vue')
|
||||
|
||||
const read = file => (fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '')
|
||||
|
||||
const pageSource = read(pageFile)
|
||||
const apiSource = read(apiFile)
|
||||
const formDialogSource = read(formDialogFile)
|
||||
const detailDialogSource = read(detailDialogFile)
|
||||
const importDialogSource = read(importDialogFile)
|
||||
|
||||
const checks = [
|
||||
['clientUnit page imports ProTable', () => /import\s+ProTable\s+from\s+'@\/components\/ProTable\/index\.vue'/.test(pageSource)],
|
||||
['clientUnit page uses ProTable request API', () => /<ProTable[\s\S]*:request-api="getTableList"/.test(pageSource)],
|
||||
[
|
||||
'clientUnit page has create batch delete export template and import header actions',
|
||||
() =>
|
||||
/<template\s+#tableHeader="scope">[\s\S]*openCreateDialog[\s\S]*handleBatchDelete\(scope\.selectedListIds\)[\s\S]*handleExport[\s\S]*handleDownloadTemplate[\s\S]*openImportDialog/.test(
|
||||
pageSource
|
||||
)
|
||||
],
|
||||
[
|
||||
'clientUnit page uses form detail and import dialogs',
|
||||
() => /<ClientUnitFormDialog[\s\S]*<ClientUnitDetailDialog[\s\S]*<ClientUnitImportDialog/.test(pageSource)
|
||||
],
|
||||
[
|
||||
'clientUnit row actions include detail edit and delete',
|
||||
() =>
|
||||
/<template\s+#operation="\{\s*row\s*\}">[\s\S]*openDetailDialog\(row\)[\s\S]*openEditDialog\(row\)[\s\S]*handleDelete\(row\)/.test(
|
||||
pageSource
|
||||
)
|
||||
],
|
||||
[
|
||||
'clientUnit search uses unit name and update time range',
|
||||
() =>
|
||||
/prop:\s*'name'[\s\S]*search:\s*\{[\s\S]*el:\s*'input'/.test(pageSource) &&
|
||||
/prop:\s*'timeRange'[\s\S]*label:\s*'更新时间'[\s\S]*el:\s*'date-picker'/.test(pageSource)
|
||||
],
|
||||
[
|
||||
'clientUnit page normalizes table params and empty text',
|
||||
() => /normalizeClientUnitListParams/.test(pageSource) && /resolveClientUnitText/.test(pageSource)
|
||||
],
|
||||
[
|
||||
'clientUnit api uses list add update getById delete export importTemplate and import endpoints',
|
||||
() =>
|
||||
/clientUnit\/list/.test(apiSource) &&
|
||||
/clientUnit\/add/.test(apiSource) &&
|
||||
/clientUnit\/update/.test(apiSource) &&
|
||||
/clientUnit\/getById/.test(apiSource) &&
|
||||
/clientUnit\/delete/.test(apiSource) &&
|
||||
/clientUnit\/export/.test(apiSource) &&
|
||||
/clientUnit\/importTemplate/.test(apiSource) &&
|
||||
/clientUnit\/import/.test(apiSource)
|
||||
],
|
||||
[
|
||||
'clientUnit form dialog validates required fields',
|
||||
() =>
|
||||
/prop="name"/.test(formDialogSource) &&
|
||||
/prop="contactName"/.test(formDialogSource) &&
|
||||
/prop="phonenumber"/.test(formDialogSource) &&
|
||||
/formRules/.test(formDialogSource)
|
||||
],
|
||||
[
|
||||
'clientUnit form dialog sanitizes placeholder dash when filling edit form',
|
||||
() => /sanitizeClientUnitFormText/.test(formDialogSource) && /fillForm[\s\S]*sanitizeClientUnitFormText/.test(formDialogSource)
|
||||
],
|
||||
[
|
||||
'clientUnit detail dialog displays core fields',
|
||||
() =>
|
||||
/单位名称/.test(detailDialogSource) &&
|
||||
/联系人/.test(detailDialogSource) &&
|
||||
/联系方式/.test(detailDialogSource) &&
|
||||
/地址/.test(detailDialogSource)
|
||||
],
|
||||
[
|
||||
'clientUnit import dialog selects file and displays import result',
|
||||
() =>
|
||||
/type="file"/.test(importDialogSource) &&
|
||||
/successCount/.test(importDialogSource) &&
|
||||
/failCount/.test(importDialogSource) &&
|
||||
/failReasons/.test(importDialogSource)
|
||||
]
|
||||
]
|
||||
|
||||
const failedChecks = checks.filter(([, predicate]) => !predicate())
|
||||
|
||||
if (failedChecks.length) {
|
||||
console.error('clientUnit page contract failed:')
|
||||
failedChecks.forEach(([label]) => {
|
||||
console.error(`- ${label}`)
|
||||
})
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log('clientUnit page contract passed')
|
||||
311
frontend/src/views/aireport/clientUnit/index.vue
Normal file
311
frontend/src/views/aireport/clientUnit/index.vue
Normal file
@@ -0,0 +1,311 @@
|
||||
<template>
|
||||
<div class="table-box client-unit-page">
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
:request-error="handleTableRequestError"
|
||||
:search-col="{ xs: 1, sm: 2, md: 2, lg: 4, xl: 4 }"
|
||||
:tool-button="['refresh', 'setting']"
|
||||
row-key="id"
|
||||
>
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="Plus" @click="openCreateDialog">新增</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
:icon="Delete"
|
||||
:disabled="!scope.isSelected"
|
||||
@click="handleBatchDelete(scope.selectedListIds)"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
<el-button type="primary" plain :icon="Download" @click="handleExport">导出</el-button>
|
||||
<el-button type="primary" plain :icon="Document" @click="handleDownloadTemplate">下载模板</el-button>
|
||||
<el-button type="primary" plain :icon="Upload" @click="openImportDialog">导入</el-button>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<el-button link type="primary" :icon="View" @click="openDetailDialog(row)">详情</el-button>
|
||||
<el-button link type="primary" :icon="Edit" @click="openEditDialog(row)">编辑</el-button>
|
||||
<el-button link type="danger" :icon="Delete" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<ClientUnitFormDialog
|
||||
v-model:visible="formDialogVisible"
|
||||
:mode="formMode"
|
||||
:record="currentRecord"
|
||||
:saving="formSaving"
|
||||
@submit="handleSaveClientUnit"
|
||||
/>
|
||||
|
||||
<ClientUnitDetailDialog
|
||||
v-model:visible="detailDialogVisible"
|
||||
:loading="detailLoading"
|
||||
:detail="detailRecord"
|
||||
/>
|
||||
|
||||
<ClientUnitImportDialog
|
||||
v-model:visible="importDialogVisible"
|
||||
:importing="importing"
|
||||
:result="importResult"
|
||||
@submit="handleImportClientUnits"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { Delete, Document, Download, Edit, Plus, Upload, View } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import type { ResPage } from '@/api/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import {
|
||||
createClientUnitApi,
|
||||
deleteClientUnitsApi,
|
||||
downloadClientUnitImportTemplateApi,
|
||||
exportClientUnitsApi,
|
||||
getClientUnitDetailApi,
|
||||
importClientUnitsApi,
|
||||
listClientUnitsApi,
|
||||
updateClientUnitApi
|
||||
} from '@/api/aireport/clientUnit'
|
||||
import type { ClientUnit } from '@/api/aireport/clientUnit/interface'
|
||||
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||
import ClientUnitDetailDialog from './components/ClientUnitDetailDialog.vue'
|
||||
import ClientUnitFormDialog from './components/ClientUnitFormDialog.vue'
|
||||
import ClientUnitImportDialog from './components/ClientUnitImportDialog.vue'
|
||||
import {
|
||||
getClientUnitErrorMessage,
|
||||
normalizeClientUnitListParams,
|
||||
normalizeClientUnitPage,
|
||||
resolveClientUnitText,
|
||||
unwrapClientUnitPayload
|
||||
} from './utils/clientUnit'
|
||||
|
||||
defineOptions({
|
||||
name: 'ClientUnitPage'
|
||||
})
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const formDialogVisible = ref(false)
|
||||
const detailDialogVisible = ref(false)
|
||||
const importDialogVisible = ref(false)
|
||||
const formSaving = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const importing = ref(false)
|
||||
const formMode = ref<'create' | 'edit'>('create')
|
||||
const currentRecord = ref<ClientUnit.ClientUnitRecord | null>(null)
|
||||
const detailRecord = ref<ClientUnit.ClientUnitRecord | null>(null)
|
||||
const importResult = ref<ClientUnit.ClientUnitImportResult | null>(null)
|
||||
|
||||
const currentSearchParams = computed(() =>
|
||||
normalizeClientUnitListParams((proTable.value?.searchParam || {}) as ClientUnit.ClientUnitListParams)
|
||||
)
|
||||
|
||||
const columns = reactive<ColumnProps<ClientUnit.ClientUnitRecord>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '单位名称',
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true,
|
||||
search: {
|
||||
el: 'input',
|
||||
order: 1,
|
||||
props: {
|
||||
placeholder: '请输入单位名称'
|
||||
}
|
||||
},
|
||||
render: ({ row }) => resolveClientUnitText(row.name)
|
||||
},
|
||||
{
|
||||
prop: 'timeRange',
|
||||
label: '更新时间',
|
||||
minWidth: 220,
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'date-picker',
|
||||
order: 2,
|
||||
key: 'timeRange',
|
||||
props: {
|
||||
type: 'datetimerange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
startPlaceholder: '开始更新时间',
|
||||
endPlaceholder: '结束更新时间'
|
||||
}
|
||||
}
|
||||
},
|
||||
{ prop: 'contactName', label: '联系人', minWidth: 130, render: ({ row }) => resolveClientUnitText(row.contactName) },
|
||||
{ prop: 'phonenumber', label: '联系方式', minWidth: 150, render: ({ row }) => resolveClientUnitText(row.phonenumber) },
|
||||
{
|
||||
prop: 'address',
|
||||
label: '地址',
|
||||
minWidth: 220,
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => resolveClientUnitText(row.address)
|
||||
},
|
||||
{ prop: 'createBy', label: '创建人', width: 120, render: ({ row }) => resolveClientUnitText(row.createBy) },
|
||||
{ prop: 'createTime', label: '创建时间', minWidth: 170, render: ({ row }) => resolveClientUnitText(row.createTime) },
|
||||
{ prop: 'updateBy', label: '更新人', width: 120, render: ({ row }) => resolveClientUnitText(row.updateBy) },
|
||||
{ prop: 'updateTime', label: '更新时间', minWidth: 170, render: ({ row }) => resolveClientUnitText(row.updateTime) },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 260 }
|
||||
])
|
||||
|
||||
const getTableList = async (params: ClientUnit.ClientUnitListParams = {}) => {
|
||||
const response = await listClientUnitsApi(normalizeClientUnitListParams(params))
|
||||
const pageData = normalizeClientUnitPage<ClientUnit.ClientUnitRecord>(
|
||||
response as unknown as ResPage<ClientUnit.ClientUnitRecord>
|
||||
)
|
||||
|
||||
return {
|
||||
data: pageData
|
||||
}
|
||||
}
|
||||
|
||||
const refreshClientUnits = () => {
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const handleTableRequestError = (error: unknown) => {
|
||||
ElMessage.error(getClientUnitErrorMessage(error, '委托单位列表查询失败'))
|
||||
}
|
||||
|
||||
const openCreateDialog = () => {
|
||||
formMode.value = 'create'
|
||||
currentRecord.value = null
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openEditDialog = (row: ClientUnit.ClientUnitRecord) => {
|
||||
formMode.value = 'edit'
|
||||
currentRecord.value = row
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openDetailDialog = async (row: ClientUnit.ClientUnitRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前委托单位缺少 ID,无法查看详情')
|
||||
return
|
||||
}
|
||||
|
||||
detailRecord.value = null
|
||||
detailDialogVisible.value = true
|
||||
detailLoading.value = true
|
||||
|
||||
try {
|
||||
// 详情字段以 getById 为准,避免列表字段缺失时展示不完整。
|
||||
const response = await getClientUnitDetailApi(row.id)
|
||||
detailRecord.value = unwrapClientUnitPayload<ClientUnit.ClientUnitRecord>(response)
|
||||
} catch (error) {
|
||||
ElMessage.error(getClientUnitErrorMessage(error, '委托单位详情查询失败'))
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const openImportDialog = () => {
|
||||
importResult.value = null
|
||||
importDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleSaveClientUnit = async (params: ClientUnit.ClientUnitSaveRequest) => {
|
||||
formSaving.value = true
|
||||
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
await createClientUnitApi(params)
|
||||
ElMessage.success('委托单位新增成功')
|
||||
} else {
|
||||
await updateClientUnitApi(params)
|
||||
ElMessage.success('委托单位编辑成功')
|
||||
}
|
||||
|
||||
formDialogVisible.value = false
|
||||
refreshClientUnits()
|
||||
} catch (error) {
|
||||
ElMessage.error(getClientUnitErrorMessage(error, '委托单位保存失败'))
|
||||
} finally {
|
||||
formSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const deleteClientUnits = async (ids: string[], successMessage: string) => {
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('请选择要删除的委托单位')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm('删除后委托单位将不可见,是否继续?', '删除委托单位', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await deleteClientUnitsApi(ids)
|
||||
ElMessage.success(successMessage)
|
||||
refreshClientUnits()
|
||||
} catch (error) {
|
||||
ElMessage.error(getClientUnitErrorMessage(error, '委托单位删除失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleDelete = async (row: ClientUnit.ClientUnitRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前委托单位缺少 ID,无法删除')
|
||||
return
|
||||
}
|
||||
|
||||
await deleteClientUnits([row.id], '委托单位删除成功')
|
||||
}
|
||||
|
||||
const handleBatchDelete = async (ids: string[]) => {
|
||||
await deleteClientUnits(ids, '委托单位批量删除成功')
|
||||
}
|
||||
|
||||
const handleExport = async () => {
|
||||
await useDownloadWithServerFileName(exportClientUnitsApi, '委托单位列表', currentSearchParams.value, false, '.xlsx')
|
||||
}
|
||||
|
||||
const handleDownloadTemplate = async () => {
|
||||
await useDownloadWithServerFileName(
|
||||
() => downloadClientUnitImportTemplateApi(),
|
||||
'委托单位导入模板',
|
||||
undefined,
|
||||
false,
|
||||
'.xlsx'
|
||||
)
|
||||
}
|
||||
|
||||
const handleImportClientUnits = async (file: File) => {
|
||||
importing.value = true
|
||||
|
||||
try {
|
||||
// 导入接口支持部分成功,结果保留在弹窗内供用户核对失败原因。
|
||||
const response = await importClientUnitsApi(file)
|
||||
importResult.value = unwrapClientUnitPayload<ClientUnit.ClientUnitImportResult>(response)
|
||||
ElMessage.success('委托单位导入完成')
|
||||
refreshClientUnits()
|
||||
} catch (error) {
|
||||
ElMessage.error(getClientUnitErrorMessage(error, '委托单位导入失败'))
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.client-unit-page {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
61
frontend/src/views/aireport/clientUnit/utils/clientUnit.ts
Normal file
61
frontend/src/views/aireport/clientUnit/utils/clientUnit.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import type { ResultData, ResPage } from '@/api/interface'
|
||||
import type { ClientUnit } from '@/api/aireport/clientUnit/interface'
|
||||
|
||||
export const resolveClientUnitText = (value: unknown) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
const text = String(value).trim()
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
export const sanitizeClientUnitFormText = (value: unknown) => {
|
||||
if (value === null || value === undefined) return ''
|
||||
|
||||
const text = String(value).trim()
|
||||
return text === '-' ? '' : text
|
||||
}
|
||||
|
||||
export const normalizeClientUnitListParams = (
|
||||
params: ClientUnit.ClientUnitListParams = {}
|
||||
): ClientUnit.ClientUnitListParams => {
|
||||
const timeRange = Array.isArray(params.timeRange) ? params.timeRange : []
|
||||
const [searchBeginTime = '', searchEndTime = ''] = timeRange
|
||||
|
||||
return {
|
||||
name: String(params.name || '').trim() || undefined,
|
||||
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
||||
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
||||
pageNum: params.pageNum || 1,
|
||||
pageSize: params.pageSize || 10
|
||||
}
|
||||
}
|
||||
|
||||
export const unwrapClientUnitPayload = <T>(response: ResultData<T> | T): T => {
|
||||
if (response && typeof response === 'object' && 'data' in response) {
|
||||
return (response as ResultData<T>).data
|
||||
}
|
||||
|
||||
return response as T
|
||||
}
|
||||
|
||||
export const normalizeClientUnitPage = <T>(
|
||||
response: ResultData<ResPage<T>> | ResPage<T> | null | undefined
|
||||
): ResPage<T> => {
|
||||
const payload = unwrapClientUnitPayload<ResPage<T> | null | undefined>(response as ResultData<ResPage<T>>)
|
||||
|
||||
return {
|
||||
records: payload?.records || [],
|
||||
current: payload?.current || 1,
|
||||
size: payload?.size || 10,
|
||||
total: payload?.total || 0
|
||||
}
|
||||
}
|
||||
|
||||
export const getClientUnitErrorMessage = (error: unknown, fallback: string) => {
|
||||
if (error instanceof Error && error.message) return error.message
|
||||
if (error && typeof error === 'object' && 'message' in error) {
|
||||
return String((error as { message?: unknown }).message || fallback)
|
||||
}
|
||||
|
||||
return fallback
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
:title="dialogTitle"
|
||||
width="560px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@close="handleClose"
|
||||
>
|
||||
<el-form ref="formRef" :model="formState" :rules="formRules" label-width="88px">
|
||||
<el-form-item label="报告名称">
|
||||
<div class="report-approval-action-dialog__text">{{ resolveReportApprovalText(record?.reportName) }}</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="报告类型">
|
||||
<div class="report-approval-action-dialog__text">{{ getReportApprovalTypeText(record?.reportType) }}</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="审批原因" prop="approvalReason">
|
||||
<el-input
|
||||
v-model="formState.approvalReason"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
maxlength="128"
|
||||
show-word-limit
|
||||
placeholder="请输入审批原因"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleClose">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="handleSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import type { ReportApproval } from '@/api/aireport/reportApproval/interface'
|
||||
import {
|
||||
getReportApprovalTypeText,
|
||||
resolveReportApprovalText,
|
||||
validateReportApprovalReason
|
||||
} from '../utils/reportApproval'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportApprovalActionDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'pass' | 'reject'
|
||||
record: ReportApproval.PendingRecord | null
|
||||
saving?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
submit: [payload: ReportApproval.ApprovalActionRequest]
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const formState = reactive({
|
||||
approvalReason: ''
|
||||
})
|
||||
|
||||
const dialogTitle = computed(() => (props.mode === 'pass' ? '审批通过' : '审批退回'))
|
||||
|
||||
const formRules: FormRules = {
|
||||
approvalReason: [
|
||||
{
|
||||
validator: (_rule, value: string, callback) => {
|
||||
const errorMessage = validateReportApprovalReason(String(value || ''))
|
||||
callback(errorMessage ? new Error(errorMessage) : undefined)
|
||||
},
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
visible => {
|
||||
if (!visible) {
|
||||
formState.approvalReason = ''
|
||||
formRef.value?.clearValidate()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const handleClose = () => {
|
||||
emit('update:visible', false)
|
||||
}
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!props.record?.reportId || !props.record.reportType) return
|
||||
|
||||
await formRef.value?.validate()
|
||||
|
||||
emit('submit', {
|
||||
reportId: props.record.reportId,
|
||||
reportType: props.record.reportType,
|
||||
approvalReason: formState.approvalReason.trim()
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-approval-action-dialog__text {
|
||||
min-height: 32px;
|
||||
color: var(--el-text-color-regular);
|
||||
line-height: 32px;
|
||||
word-break: break-all;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,149 @@
|
||||
<template>
|
||||
<div class="table-box report-approval-log-table">
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
:request-error="handleTableRequestError"
|
||||
:search-col="{ xs: 1, sm: 2, md: 2, lg: 4, xl: 4 }"
|
||||
:tool-button="['refresh', 'setting']"
|
||||
row-key="id"
|
||||
>
|
||||
<template #tableHeader>
|
||||
<el-button type="primary" plain :icon="Refresh" @click="refreshLogs">刷新</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { Refresh } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type TagProps } from 'element-plus'
|
||||
import { reactive, ref } from 'vue'
|
||||
import type { ResPage } from '@/api/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import { listReportApprovalLogsApi } from '@/api/aireport/reportApproval'
|
||||
import type { ReportApproval } from '@/api/aireport/reportApproval/interface'
|
||||
import {
|
||||
REPORT_APPROVAL_TYPE_OPTIONS,
|
||||
getReportApprovalErrorMessage,
|
||||
getReportApprovalResultText,
|
||||
getReportApprovalStateTagType,
|
||||
getReportApprovalStateText,
|
||||
getReportApprovalTypeText,
|
||||
normalizeReportApprovalLogListParams,
|
||||
normalizeReportApprovalPage,
|
||||
resolveReportApprovalText
|
||||
} from '../utils/reportApproval'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportApprovalLogTable'
|
||||
})
|
||||
|
||||
type TagType = TagProps['type']
|
||||
|
||||
const RESULT_OPTIONS: Array<{ label: string; value: ReportApproval.ApprovalResult; tagType: TagType }> = [
|
||||
{ label: '通过', value: '03', tagType: 'success' },
|
||||
{ label: '退回', value: '04', tagType: 'danger' }
|
||||
]
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
const columns = reactive<ColumnProps<ReportApproval.LogRecord>[]>([
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'reportType',
|
||||
label: '报告类型',
|
||||
width: 140,
|
||||
enum: REPORT_APPROVAL_TYPE_OPTIONS,
|
||||
isFilterEnum: false,
|
||||
render: ({ row }) => getReportApprovalTypeText(row.reportType),
|
||||
search: {
|
||||
el: 'select',
|
||||
order: 1,
|
||||
props: {
|
||||
placeholder: '请选择报告类型'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'reportName',
|
||||
label: '报告名称',
|
||||
minWidth: 220,
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => resolveReportApprovalText(row.reportName)
|
||||
},
|
||||
{
|
||||
prop: 'approvalResult',
|
||||
label: '审批结果',
|
||||
width: 120,
|
||||
enum: RESULT_OPTIONS,
|
||||
isFilterEnum: false,
|
||||
render: ({ row }) => (
|
||||
<el-tag type={getReportApprovalStateTagType(row.approvalResult)} effect="light">
|
||||
{getReportApprovalResultText(row.approvalResult)}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'approvalReason',
|
||||
label: '审批原因',
|
||||
minWidth: 260,
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => resolveReportApprovalText(row.approvalReason)
|
||||
},
|
||||
{
|
||||
prop: 'beforeState',
|
||||
label: '审批前状态',
|
||||
width: 120,
|
||||
render: ({ row }) => (
|
||||
<el-tag type={getReportApprovalStateTagType(row.beforeState)} effect="light">
|
||||
{getReportApprovalStateText(row.beforeState)}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'afterState',
|
||||
label: '审批后状态',
|
||||
width: 120,
|
||||
render: ({ row }) => (
|
||||
<el-tag type={getReportApprovalStateTagType(row.afterState)} effect="light">
|
||||
{getReportApprovalStateText(row.afterState)}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{ prop: 'approverName', label: '审批人', width: 140, render: ({ row }) => resolveReportApprovalText(row.approverName) },
|
||||
{ prop: 'approvalTime', label: '审批时间', minWidth: 180, render: ({ row }) => resolveReportApprovalText(row.approvalTime) }
|
||||
])
|
||||
|
||||
const getTableList = async (params: ReportApproval.LogListParams = {}) => {
|
||||
const response = await listReportApprovalLogsApi(normalizeReportApprovalLogListParams(params))
|
||||
const pageData = normalizeReportApprovalPage<ReportApproval.LogRecord>(response as unknown as ResPage<ReportApproval.LogRecord>)
|
||||
|
||||
return {
|
||||
data: pageData
|
||||
}
|
||||
}
|
||||
|
||||
const handleTableRequestError = (error: unknown) => {
|
||||
ElMessage.error(getReportApprovalErrorMessage(error, '审批日志查询失败'))
|
||||
}
|
||||
|
||||
const refreshLogs = () => {
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
refreshLogs
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-approval-log-table {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,140 @@
|
||||
<template>
|
||||
<div class="table-box report-approval-pending-table">
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
:request-error="handleTableRequestError"
|
||||
:search-col="{ xs: 1, sm: 2, md: 2, lg: 4, xl: 4 }"
|
||||
:tool-button="['refresh', 'setting']"
|
||||
row-key="reportId"
|
||||
>
|
||||
<template #tableHeader>
|
||||
<el-button type="primary" plain :icon="Refresh" @click="refreshPendingReports">刷新</el-button>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<el-button link type="primary" :icon="CircleCheck" @click="handlePass(row)">通过</el-button>
|
||||
<el-button link type="danger" :icon="RefreshLeft" @click="handleReject(row)">退回</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { CircleCheck, Refresh, RefreshLeft } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type TagProps } from 'element-plus'
|
||||
import { reactive, ref } from 'vue'
|
||||
import type { ResPage } from '@/api/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import { listPendingReportApprovalsApi } from '@/api/aireport/reportApproval'
|
||||
import type { ReportApproval } from '@/api/aireport/reportApproval/interface'
|
||||
import {
|
||||
REPORT_APPROVAL_TYPE_OPTIONS,
|
||||
getReportApprovalErrorMessage,
|
||||
getReportApprovalStateTagType,
|
||||
getReportApprovalStateText,
|
||||
getReportApprovalTypeText,
|
||||
normalizePendingReportApprovalListParams,
|
||||
normalizeReportApprovalPage,
|
||||
resolveReportApprovalText
|
||||
} from '../utils/reportApproval'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportApprovalPendingTable'
|
||||
})
|
||||
|
||||
type TagType = TagProps['type']
|
||||
|
||||
const emit = defineEmits<{
|
||||
pass: [record: ReportApproval.PendingRecord]
|
||||
reject: [record: ReportApproval.PendingRecord]
|
||||
}>()
|
||||
|
||||
const STATE_OPTIONS: Array<{ label: string; value: ReportApproval.ReportState; tagType: TagType }> = [
|
||||
{ label: '待审', value: '02', tagType: 'warning' }
|
||||
]
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
const columns = reactive<ColumnProps<ReportApproval.PendingRecord>[]>([
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'reportType',
|
||||
label: '报告类型',
|
||||
width: 140,
|
||||
enum: REPORT_APPROVAL_TYPE_OPTIONS,
|
||||
isFilterEnum: false,
|
||||
render: ({ row }) => getReportApprovalTypeText(row.reportType),
|
||||
search: {
|
||||
el: 'select',
|
||||
order: 1,
|
||||
props: {
|
||||
placeholder: '请选择报告类型'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'reportName',
|
||||
label: '报告名称',
|
||||
minWidth: 220,
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => resolveReportApprovalText(row.reportName)
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '当前状态',
|
||||
width: 120,
|
||||
enum: STATE_OPTIONS,
|
||||
isFilterEnum: false,
|
||||
render: ({ row }) => (
|
||||
<el-tag type={getReportApprovalStateTagType(row.state)} effect="light">
|
||||
{getReportApprovalStateText(row.state)}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{ prop: 'submitterName', label: '提交人', width: 140, render: ({ row }) => resolveReportApprovalText(row.submitterName) },
|
||||
{ prop: 'submitTime', label: '提交时间', minWidth: 180, render: ({ row }) => resolveReportApprovalText(row.submitTime) },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 180 }
|
||||
])
|
||||
|
||||
const getTableList = async (params: ReportApproval.PendingListParams = {}) => {
|
||||
const response = await listPendingReportApprovalsApi(normalizePendingReportApprovalListParams(params))
|
||||
const pageData = normalizeReportApprovalPage<ReportApproval.PendingRecord>(
|
||||
response as unknown as ResPage<ReportApproval.PendingRecord>
|
||||
)
|
||||
|
||||
return {
|
||||
data: pageData
|
||||
}
|
||||
}
|
||||
|
||||
const handleTableRequestError = (error: unknown) => {
|
||||
ElMessage.error(getReportApprovalErrorMessage(error, '待审批报告查询失败'))
|
||||
}
|
||||
|
||||
const refreshPendingReports = () => {
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const handlePass = (row: ReportApproval.PendingRecord) => {
|
||||
emit('pass', row)
|
||||
}
|
||||
|
||||
const handleReject = (row: ReportApproval.PendingRecord) => {
|
||||
emit('reject', row)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
refreshPendingReports
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-approval-pending-table {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,89 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const pageDir = path.resolve(__dirname, '..')
|
||||
const srcDir = path.resolve(pageDir, '../../..')
|
||||
const routerFile = path.resolve(srcDir, 'routers/modules/dynamicRouter.ts')
|
||||
const pageFile = path.resolve(pageDir, 'index.vue')
|
||||
const pendingTableFile = path.resolve(pageDir, 'components/ReportApprovalPendingTable.vue')
|
||||
const logTableFile = path.resolve(pageDir, 'components/ReportApprovalLogTable.vue')
|
||||
const actionDialogFile = path.resolve(pageDir, 'components/ReportApprovalActionDialog.vue')
|
||||
const utilsFile = path.resolve(pageDir, 'utils/reportApproval.ts')
|
||||
const apiFile = path.resolve(srcDir, 'api/aireport/reportApproval/index.ts')
|
||||
const apiInterfaceFile = path.resolve(srcDir, 'api/aireport/reportApproval/interface/index.ts')
|
||||
|
||||
const read = file => fs.readFileSync(file, 'utf8')
|
||||
const assertFileIncludes = (file, snippets) => {
|
||||
const content = read(file)
|
||||
const missing = snippets.filter(snippet => !content.includes(snippet))
|
||||
|
||||
if (missing.length) {
|
||||
throw new Error(`${path.relative(srcDir, file)} missing: ${missing.join(', ')}`)
|
||||
}
|
||||
}
|
||||
|
||||
assertFileIncludes(routerFile, [
|
||||
"'/aiReport/reportApproval': '/aireport/reportApproval'",
|
||||
"'/aiReport/reportApproval/index': '/aireport/reportApproval/index'"
|
||||
])
|
||||
|
||||
assertFileIncludes(apiFile, [
|
||||
"const REPORT_APPROVAL_BASE_URL = '/api/report-approval'",
|
||||
'listPendingReportApprovalsApi',
|
||||
'passReportApprovalApi',
|
||||
'rejectReportApprovalApi',
|
||||
'listReportApprovalLogsApi'
|
||||
])
|
||||
|
||||
assertFileIncludes(apiInterfaceFile, [
|
||||
'export namespace ReportApproval',
|
||||
'PendingRecord',
|
||||
'PendingListParams',
|
||||
'ApprovalActionRequest',
|
||||
'LogRecord',
|
||||
'LogListParams'
|
||||
])
|
||||
|
||||
assertFileIncludes(utilsFile, [
|
||||
'REPORT_APPROVAL_TYPE_OPTIONS',
|
||||
'getReportApprovalStateText',
|
||||
'getReportApprovalResultText',
|
||||
'normalizePendingReportApprovalListParams',
|
||||
'normalizeReportApprovalLogListParams',
|
||||
'validateReportApprovalReason'
|
||||
])
|
||||
|
||||
assertFileIncludes(actionDialogFile, [
|
||||
"name: 'ReportApprovalActionDialog'",
|
||||
'approvalReason',
|
||||
'validateReportApprovalReason'
|
||||
])
|
||||
|
||||
assertFileIncludes(pendingTableFile, [
|
||||
"name: 'ReportApprovalPendingTable'",
|
||||
'<ProTable',
|
||||
'tableHeader',
|
||||
'handlePass(row)',
|
||||
'handleReject(row)'
|
||||
])
|
||||
|
||||
assertFileIncludes(logTableFile, [
|
||||
"name: 'ReportApprovalLogTable'",
|
||||
'<ProTable',
|
||||
'tableHeader',
|
||||
'listReportApprovalLogsApi'
|
||||
])
|
||||
|
||||
assertFileIncludes(pageFile, [
|
||||
"name: 'ReportApprovalPage'",
|
||||
'el-tabs',
|
||||
'ReportApprovalPendingTable',
|
||||
'ReportApprovalLogTable',
|
||||
'ReportApprovalActionDialog',
|
||||
'passReportApprovalApi',
|
||||
'rejectReportApprovalApi'
|
||||
])
|
||||
|
||||
console.log('reportApproval page contract passed')
|
||||
108
frontend/src/views/aireport/reportApproval/index.vue
Normal file
108
frontend/src/views/aireport/reportApproval/index.vue
Normal file
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<div class="table-box report-approval-page">
|
||||
<el-tabs v-model="activeTab" class="report-approval-page__tabs">
|
||||
<el-tab-pane label="待审批报告" name="pending">
|
||||
<ReportApprovalPendingTable ref="pendingTableRef" @pass="openPassDialog" @reject="openRejectDialog" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="审批日志" name="logs">
|
||||
<ReportApprovalLogTable ref="logTableRef" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
<ReportApprovalActionDialog
|
||||
:visible="actionDialogVisible"
|
||||
:mode="actionMode"
|
||||
:record="currentRecord"
|
||||
:saving="actionSaving"
|
||||
@update:visible="handleDialogVisibleChange"
|
||||
@submit="handleSubmitAction"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { passReportApprovalApi, rejectReportApprovalApi } from '@/api/aireport/reportApproval'
|
||||
import type { ReportApproval } from '@/api/aireport/reportApproval/interface'
|
||||
import ReportApprovalActionDialog from './components/ReportApprovalActionDialog.vue'
|
||||
import ReportApprovalLogTable from './components/ReportApprovalLogTable.vue'
|
||||
import ReportApprovalPendingTable from './components/ReportApprovalPendingTable.vue'
|
||||
import { getReportApprovalErrorMessage } from './utils/reportApproval'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportApprovalPage'
|
||||
})
|
||||
|
||||
const activeTab = ref<'pending' | 'logs'>('pending')
|
||||
const pendingTableRef = ref<InstanceType<typeof ReportApprovalPendingTable>>()
|
||||
const logTableRef = ref<InstanceType<typeof ReportApprovalLogTable>>()
|
||||
const actionDialogVisible = ref(false)
|
||||
const actionSaving = ref(false)
|
||||
const actionMode = ref<'pass' | 'reject'>('pass')
|
||||
const currentRecord = ref<ReportApproval.PendingRecord | null>(null)
|
||||
|
||||
const openPassDialog = (record: ReportApproval.PendingRecord) => {
|
||||
currentRecord.value = record
|
||||
actionMode.value = 'pass'
|
||||
actionDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openRejectDialog = (record: ReportApproval.PendingRecord) => {
|
||||
currentRecord.value = record
|
||||
actionMode.value = 'reject'
|
||||
actionDialogVisible.value = true
|
||||
}
|
||||
|
||||
const refreshTables = () => {
|
||||
pendingTableRef.value?.refreshPendingReports()
|
||||
logTableRef.value?.refreshLogs()
|
||||
}
|
||||
|
||||
const handleDialogVisibleChange = (visible: boolean) => {
|
||||
actionDialogVisible.value = visible
|
||||
|
||||
if (!visible) {
|
||||
currentRecord.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmitAction = async (payload: ReportApproval.ApprovalActionRequest) => {
|
||||
actionSaving.value = true
|
||||
|
||||
try {
|
||||
// 关键业务节点:审批通过和审批退回共用同一弹窗收集原因,但必须按当前操作调用不同后端接口。
|
||||
if (actionMode.value === 'pass') {
|
||||
await passReportApprovalApi(payload)
|
||||
ElMessage.success('报告审批通过成功')
|
||||
} else {
|
||||
await rejectReportApprovalApi(payload)
|
||||
ElMessage.success('报告审批退回成功')
|
||||
}
|
||||
|
||||
activeTab.value = 'logs'
|
||||
handleDialogVisibleChange(false)
|
||||
refreshTables()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportApprovalErrorMessage(error, actionMode.value === 'pass' ? '报告审批通过失败' : '报告审批退回失败'))
|
||||
} finally {
|
||||
actionSaving.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-approval-page {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-approval-page__tabs {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.report-approval-page__tabs :deep(.el-tabs__content) {
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,103 @@
|
||||
import type { TagProps } from 'element-plus'
|
||||
import type { ResultData, ResPage } from '@/api/interface'
|
||||
import type { ReportApproval } from '@/api/aireport/reportApproval/interface'
|
||||
|
||||
type TagType = TagProps['type']
|
||||
|
||||
const REPORT_APPROVAL_STATE_MAP: Record<string, { text: string; tagType: TagType }> = {
|
||||
'01': { text: '编制', tagType: 'info' },
|
||||
'02': { text: '待审', tagType: 'warning' },
|
||||
'03': { text: '通过', tagType: 'success' },
|
||||
'04': { text: '退回', tagType: 'danger' },
|
||||
'05': { text: '删除', tagType: 'info' }
|
||||
}
|
||||
|
||||
const REPORT_APPROVAL_TYPE_MAP: Record<string, string> = {
|
||||
REPORT_MODEL: '报告模板',
|
||||
TEST_REPORT: '普测报告'
|
||||
}
|
||||
|
||||
const REPORT_APPROVAL_RESULT_MAP: Record<string, string> = {
|
||||
'03': '通过',
|
||||
'04': '退回'
|
||||
}
|
||||
|
||||
export const REPORT_APPROVAL_REASON_MAX_LENGTH = 128
|
||||
|
||||
export const REPORT_APPROVAL_TYPE_OPTIONS: Array<{ label: string; value: ReportApproval.ReportType }> = [
|
||||
{ label: '报告模板', value: 'REPORT_MODEL' },
|
||||
{ label: '普测报告', value: 'TEST_REPORT' }
|
||||
]
|
||||
|
||||
export const resolveReportApprovalText = (value: unknown) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
const text = String(value).trim()
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
export const getReportApprovalStateText = (state?: string) => REPORT_APPROVAL_STATE_MAP[state || '']?.text || '未知状态'
|
||||
|
||||
export const getReportApprovalStateTagType = (state?: string): TagType =>
|
||||
REPORT_APPROVAL_STATE_MAP[state || '']?.tagType || 'info'
|
||||
|
||||
export const getReportApprovalTypeText = (reportType?: string) => REPORT_APPROVAL_TYPE_MAP[reportType || ''] || reportType || '-'
|
||||
|
||||
export const getReportApprovalResultText = (result?: string) => REPORT_APPROVAL_RESULT_MAP[result || ''] || result || '-'
|
||||
|
||||
export const normalizePendingReportApprovalListParams = (
|
||||
params: ReportApproval.PendingListParams = {}
|
||||
): ReportApproval.PendingListParams => ({
|
||||
current: params.current || 1,
|
||||
size: params.size || 10,
|
||||
reportType: params.reportType || undefined
|
||||
})
|
||||
|
||||
export const normalizeReportApprovalLogListParams = (
|
||||
params: ReportApproval.LogListParams = {}
|
||||
): ReportApproval.LogListParams => ({
|
||||
current: params.current || 1,
|
||||
size: params.size || 10,
|
||||
reportType: params.reportType || undefined
|
||||
})
|
||||
|
||||
export const unwrapReportApprovalPayload = <T>(response: ResultData<T> | T): T => {
|
||||
if (response && typeof response === 'object' && 'data' in response) {
|
||||
return (response as ResultData<T>).data
|
||||
}
|
||||
|
||||
return response as T
|
||||
}
|
||||
|
||||
export const normalizeReportApprovalPage = <T>(
|
||||
response: ResultData<ResPage<T>> | ResPage<T> | null | undefined
|
||||
): ResPage<T> => {
|
||||
const payload = unwrapReportApprovalPayload<ResPage<T> | null | undefined>(response as ResultData<ResPage<T>>)
|
||||
|
||||
return {
|
||||
records: payload?.records || [],
|
||||
current: payload?.current || 1,
|
||||
size: payload?.size || 10,
|
||||
total: payload?.total || 0
|
||||
}
|
||||
}
|
||||
|
||||
export const validateReportApprovalReason = (value: string) => {
|
||||
const text = value.trim()
|
||||
|
||||
if (!text) return '请输入审批原因'
|
||||
if (text.length > REPORT_APPROVAL_REASON_MAX_LENGTH) {
|
||||
return `审批原因不能超过 ${REPORT_APPROVAL_REASON_MAX_LENGTH} 个字符`
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
export const getReportApprovalErrorMessage = (error: unknown, fallback: string) => {
|
||||
if (error instanceof Error && error.message) return error.message
|
||||
if (error && typeof error === 'object' && 'message' in error) {
|
||||
return String((error as { message?: unknown }).message || fallback)
|
||||
}
|
||||
|
||||
return fallback
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
title="模板详情"
|
||||
width="720px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
>
|
||||
<div v-loading="loading" class="report-model-detail-dialog">
|
||||
<el-descriptions class="detail-descriptions" :column="2" border>
|
||||
<el-descriptions-item label="模板名称">{{ detail?.name || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="模板状态">
|
||||
<el-tag :type="getReportModelStateTagType(detail?.state)" effect="light">
|
||||
{{ getReportModelStateText(detail?.state) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="审核人">{{ detail?.checkerName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核时间">{{ detail?.checkTime || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="编辑人">{{ detail?.editorName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ detail?.updateTime || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人">{{ detail?.createBy || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ detail?.createTime || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="模板文件" :span="2">{{ resolveReportModelFileName(detail) || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="模板路径" :span="2">{{ detail?.path || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核意见" :span="2">{{ detail?.checkResult || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { ReportModel } from '@/api/aireport/reportModel/interface'
|
||||
import { getReportModelStateTagType, getReportModelStateText, resolveReportModelFileName } from '../utils/reportModel'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportModelDetailDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
loading: boolean
|
||||
detail: ReportModel.ReportModelRecord | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
}>()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-model-detail-dialog {
|
||||
min-height: 180px;
|
||||
}
|
||||
|
||||
.report-model-detail-dialog :deep(.detail-descriptions .el-descriptions__table) {
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.report-model-detail-dialog :deep(.detail-descriptions .el-descriptions__label.el-descriptions__cell.is-bordered-label) {
|
||||
width: 112px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
:title="mode === 'create' ? '新增模板' : '编辑模板'"
|
||||
width="560px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@closed="resetForm"
|
||||
>
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="96px">
|
||||
<el-form-item label="模板名称" prop="name">
|
||||
<el-input
|
||||
v-model="formModel.name"
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
placeholder="请输入模板名称"
|
||||
:disabled="mode === 'edit'"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="模板文件" :required="mode === 'create'">
|
||||
<div class="file-select-row">
|
||||
<el-input :model-value="selectedFileName" readonly placeholder="请选择 Word 模板文件" />
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="saving" @click="openFilePicker">
|
||||
选择文件
|
||||
</el-button>
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
class="hidden-file-input"
|
||||
type="file"
|
||||
accept=".doc,.docx"
|
||||
@change="handleFileChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="file-select-tip">
|
||||
{{
|
||||
mode === 'create'
|
||||
? '新增模板时必须上传 Word 模板文件,支持 .doc/.docx'
|
||||
: '编辑时不上传则保留原文件,新上传文件仅支持 .doc/.docx'
|
||||
}}
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submitForm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { FolderOpened } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { ReportModel } from '@/api/aireport/reportModel/interface'
|
||||
import { resolveReportModelFileName, validateReportModelTemplateFile } from '../utils/reportModel'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportModelFormDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
record: ReportModel.ReportModelRecord | null
|
||||
saving: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: { request: ReportModel.ReportModelSaveRequest; file: File | null }): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const selectedFile = ref<File | null>(null)
|
||||
const formModel = reactive({
|
||||
id: '',
|
||||
name: ''
|
||||
})
|
||||
|
||||
const formRules: FormRules = {
|
||||
name: [{ required: true, message: '请输入模板名称', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const selectedFileName = computed(() => selectedFile.value?.name || resolveReportModelFileName(props.record))
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value?.clearValidate()
|
||||
selectedFile.value = null
|
||||
formModel.id = ''
|
||||
formModel.name = ''
|
||||
}
|
||||
|
||||
const fillForm = () => {
|
||||
formModel.id = props.record?.id || ''
|
||||
formModel.name = props.record?.name || ''
|
||||
selectedFile.value = null
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.mode, props.record?.id, props.record?.name, props.record?.path, props.record?.fileName, props.record?.file_name],
|
||||
([visible]) => {
|
||||
if (visible) fillForm()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const openFilePicker = () => {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const handleFileChange = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0] || null
|
||||
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
|
||||
const validationMessage = validateReportModelTemplateFile(file)
|
||||
if (validationMessage) {
|
||||
ElMessage.warning(validationMessage)
|
||||
return
|
||||
}
|
||||
|
||||
selectedFile.value = file
|
||||
}
|
||||
|
||||
const submitForm = async () => {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
|
||||
if (!valid) return
|
||||
|
||||
if (props.mode === 'create' && !selectedFile.value) {
|
||||
ElMessage.warning('新增模板时必须上传 Word 模板文件')
|
||||
return
|
||||
}
|
||||
|
||||
if (props.mode === 'edit' && !formModel.id) {
|
||||
ElMessage.warning('当前模板缺少 ID,无法保存编辑')
|
||||
return
|
||||
}
|
||||
|
||||
emit('submit', {
|
||||
request: {
|
||||
id: formModel.id || undefined,
|
||||
name: formModel.name.trim(),
|
||||
// 关键业务节点:新增/编辑都需要把模板文件框当前展示的文件名同步给后端 request.fileName。
|
||||
fileName: selectedFileName.value || undefined
|
||||
},
|
||||
file: selectedFile.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.file-select-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.file-select-tip {
|
||||
margin-top: 8px;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
:title="previewTitle"
|
||||
width="960px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@closed="clearPreview"
|
||||
>
|
||||
<div v-loading="loading" class="report-model-preview-dialog">
|
||||
<div v-if="activeErrorMessage" class="preview-error-wrapper">
|
||||
<el-alert :title="activeErrorMessage" type="warning" :closable="false" show-icon />
|
||||
</div>
|
||||
<div v-else ref="previewContainer" class="preview-container"></div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { renderAsync } from 'docx-preview'
|
||||
import { computed, nextTick, ref, watch } from 'vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportModelPreviewDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
loading: boolean
|
||||
fileBlob: Blob | null
|
||||
fileName: string
|
||||
errorMessage: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
}>()
|
||||
|
||||
const previewContainer = ref<HTMLDivElement | null>(null)
|
||||
const renderErrorMessage = ref('')
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const previewTitle = computed(() => (props.fileName ? `模板预览 - ${props.fileName}` : '模板预览'))
|
||||
const activeErrorMessage = computed(() => props.errorMessage || renderErrorMessage.value)
|
||||
|
||||
const clearPreview = () => {
|
||||
renderErrorMessage.value = ''
|
||||
if (previewContainer.value) {
|
||||
previewContainer.value.innerHTML = ''
|
||||
}
|
||||
}
|
||||
|
||||
const renderPreview = async () => {
|
||||
if (!props.visible || props.loading || !props.fileBlob || props.errorMessage || !previewContainer.value) return
|
||||
|
||||
clearPreview()
|
||||
|
||||
try {
|
||||
// 关键业务节点:仅对可预览的 docx 内容执行页面内渲染,渲染失败时保留明确提示,避免弹窗空白无反馈。
|
||||
await renderAsync(props.fileBlob, previewContainer.value, undefined, {
|
||||
className: 'report-model-docx-preview',
|
||||
ignoreWidth: false,
|
||||
ignoreHeight: true,
|
||||
renderHeaders: true,
|
||||
renderFooters: true,
|
||||
useBase64URL: true
|
||||
})
|
||||
} catch (error) {
|
||||
renderErrorMessage.value = error instanceof Error ? error.message : '模板预览失败,请稍后重试'
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.loading, props.fileBlob, props.errorMessage],
|
||||
async () => {
|
||||
if (!props.visible) {
|
||||
clearPreview()
|
||||
return
|
||||
}
|
||||
|
||||
renderErrorMessage.value = ''
|
||||
await nextTick()
|
||||
await renderPreview()
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-model-preview-dialog {
|
||||
min-height: 520px;
|
||||
max-height: 70vh;
|
||||
overflow: auto;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.preview-error-wrapper {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.preview-container {
|
||||
min-height: 520px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.preview-container:deep(.report-model-docx-preview-wrapper) {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.preview-container:deep(section.docx) {
|
||||
margin: 0 auto 24px;
|
||||
box-shadow: 0 8px 24px rgb(15 23 42 / 10%);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,51 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
const rootDir = path.resolve(process.cwd(), 'frontend/src')
|
||||
const pageFile = path.resolve(rootDir, 'views/aireport/reportModel/index.vue')
|
||||
const apiFile = path.resolve(rootDir, 'api/aireport/reportModel/index.ts')
|
||||
const formFile = path.resolve(rootDir, 'views/aireport/reportModel/components/ReportModelFormDialog.vue')
|
||||
|
||||
const pageSource = fs.readFileSync(pageFile, 'utf8')
|
||||
const apiSource = fs.readFileSync(apiFile, 'utf8')
|
||||
const formSource = fs.readFileSync(formFile, 'utf8')
|
||||
|
||||
const checks = [
|
||||
['reportModel page imports ProTable', () => /import\s+ProTable\s+from\s+'@\/components\/ProTable\/index\.vue'/.test(pageSource)],
|
||||
['reportModel page uses ProTable request API', () => /<ProTable[\s\S]*:request-api="getTableList"/.test(pageSource)],
|
||||
['reportModel page has create and batch delete header actions', () => /<template\s+#tableHeader="scope">[\s\S]*openCreateDialog[\s\S]*handleBatchDelete\(scope\.selectedListIds\)/.test(pageSource)],
|
||||
['reportModel page uses form detail and preview dialogs', () => /<ReportModelFormDialog[\s\S]*<ReportModelDetailDialog[\s\S]*<ReportModelPreviewDialog/.test(pageSource)],
|
||||
['reportModel row actions include detail edit download submit audit and delete', () => /<template\s+#operation="\{\s*row\s*\}">[\s\S]*openDetailDialog\(row\)[\s\S]*openEditDialog\(row\)[\s\S]*handleDownload\(row\)[\s\S]*openAuditDialog\(row\)[\s\S]*handleDelete\(row\)/.test(pageSource)],
|
||||
['reportModel search uses update time label', () => /prop:\s*'timeRange'[\s\S]*label:\s*'更新时间'/.test(pageSource) && /startPlaceholder:\s*'开始更新时间'/.test(pageSource) && /endPlaceholder:\s*'结束更新时间'/.test(pageSource)],
|
||||
[
|
||||
'reportModel list shows template file after name and supports file-name preview',
|
||||
() =>
|
||||
/prop:\s*'name'[\s\S]*prop:\s*'path'[\s\S]*label:\s*'模版文件'[\s\S]*resolveReportModelFileName\(row\)[\s\S]*openPreviewDialog\(row\)/.test(
|
||||
pageSource
|
||||
)
|
||||
],
|
||||
[
|
||||
'reportModel list columns keep index name path state editor update checker check-time check-result order',
|
||||
() =>
|
||||
/type:\s*'index'[\s\S]*prop:\s*'name'[\s\S]*prop:\s*'path'[\s\S]*prop:\s*'state'[\s\S]*prop:\s*'editorName'[\s\S]*prop:\s*'updateTime'[\s\S]*prop:\s*'checkerName'[\s\S]*prop:\s*'checkTime'[\s\S]*prop:\s*'checkResult'/.test(
|
||||
pageSource
|
||||
)
|
||||
],
|
||||
['reportModel list hides create time and keeps update time empty fallback', () => /prop:\s*'updateTime'[\s\S]*render:\s*\(\{\s*row\s*\}\)\s*=>\s*resolveReportModelText\(row\.updateTime\)/.test(pageSource) && !/prop:\s*'createTime'/.test(pageSource)],
|
||||
['reportModel api uses list add update delete detail download submit-audit endpoints', () => /report-model\/list/.test(apiSource) && /\/add/.test(apiSource) && /\/update/.test(apiSource) && /\/delete/.test(apiSource) && /submit-audit/.test(apiSource) && /\/download/.test(apiSource)],
|
||||
['reportModel api keeps multipart request part name', () => /formData\.append\('request'/.test(apiSource) && /formData\.append\('templateFile'/.test(apiSource)],
|
||||
['reportModel form only accepts Word documents', () => /accept="\.doc,\.docx"/.test(formSource)],
|
||||
['reportModel form keeps template name disabled while editing', () => /:disabled="mode === 'edit'"/.test(formSource)]
|
||||
]
|
||||
|
||||
const failedChecks = checks.filter(([, predicate]) => !predicate())
|
||||
|
||||
if (failedChecks.length) {
|
||||
console.error('reportModel page contract failed:')
|
||||
failedChecks.forEach(([label]) => {
|
||||
console.error(`- ${label}`)
|
||||
})
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log('reportModel page contract passed')
|
||||
400
frontend/src/views/aireport/reportModel/index.vue
Normal file
400
frontend/src/views/aireport/reportModel/index.vue
Normal file
@@ -0,0 +1,400 @@
|
||||
<template>
|
||||
<div class="table-box report-model-page">
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
:request-error="handleTableRequestError"
|
||||
:search-col="{ xs: 1, sm: 2, md: 2, lg: 4, xl: 4 }"
|
||||
:tool-button="['refresh', 'setting']"
|
||||
row-key="id"
|
||||
>
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="Plus" @click="openCreateDialog">新增</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
:icon="Delete"
|
||||
:disabled="!scope.isSelected"
|
||||
@click="handleBatchDelete(scope.selectedListIds)"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<el-button link type="primary" :icon="View" @click="openDetailDialog(row)">详情</el-button>
|
||||
<el-button link type="primary" :icon="Edit" :disabled="!isDraftReportModel(row)" @click="openEditDialog(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button link type="primary" :icon="Download" :disabled="!row.id" @click="handleDownload(row)">下载</el-button>
|
||||
<el-button link type="primary" :icon="Upload" :disabled="!isDraftReportModel(row)" @click="openAuditDialog(row)">
|
||||
提交审核
|
||||
</el-button>
|
||||
<el-button link type="danger" :icon="Delete" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<ReportModelFormDialog
|
||||
v-model:visible="formDialogVisible"
|
||||
:mode="formMode"
|
||||
:record="currentRecord"
|
||||
:saving="formSaving"
|
||||
@submit="handleSaveReportModel"
|
||||
/>
|
||||
|
||||
<ReportModelDetailDialog v-model:visible="detailDialogVisible" :loading="detailLoading" :detail="detailRecord" />
|
||||
|
||||
<ReportModelPreviewDialog
|
||||
v-model:visible="previewDialogVisible"
|
||||
:loading="previewLoading"
|
||||
:file-name="previewFileName"
|
||||
:file-blob="previewFileBlob"
|
||||
:error-message="previewErrorMessage"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { Delete, Download, Edit, Plus, Upload, View } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox, type TagProps } from 'element-plus'
|
||||
import { reactive, ref } from 'vue'
|
||||
import type { ResPage } from '@/api/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import {
|
||||
createReportModelApi,
|
||||
deleteReportModelsApi,
|
||||
downloadReportModelApi,
|
||||
getReportModelDetailApi,
|
||||
listReportModelsApi,
|
||||
submitReportModelAuditApi,
|
||||
updateReportModelApi
|
||||
} from '@/api/aireport/reportModel'
|
||||
import type { ReportModel } from '@/api/aireport/reportModel/interface'
|
||||
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||
import ReportModelDetailDialog from './components/ReportModelDetailDialog.vue'
|
||||
import ReportModelFormDialog from './components/ReportModelFormDialog.vue'
|
||||
import ReportModelPreviewDialog from './components/ReportModelPreviewDialog.vue'
|
||||
import {
|
||||
canPreviewReportModelFile,
|
||||
getReportModelErrorMessage,
|
||||
getReportModelStateTagType,
|
||||
getReportModelStateText,
|
||||
isDraftReportModel,
|
||||
normalizeReportModelListParams,
|
||||
normalizeReportModelPage,
|
||||
resolveReportModelDownloadFileName,
|
||||
resolveReportModelFileName,
|
||||
resolveReportModelText,
|
||||
unwrapApiPayload
|
||||
} from './utils/reportModel'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportModelPage'
|
||||
})
|
||||
|
||||
type TagType = TagProps['type']
|
||||
|
||||
const STATE_OPTIONS: Array<{ label: string; value: ReportModel.ReportModelState; tagType: TagType }> = [
|
||||
{ label: '编制', value: '01', tagType: 'info' },
|
||||
{ label: '审核中', value: '02', tagType: 'warning' },
|
||||
{ label: '已发布', value: '03', tagType: 'success' },
|
||||
{ label: '已删除', value: '04', tagType: 'danger' }
|
||||
]
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const formDialogVisible = ref(false)
|
||||
const detailDialogVisible = ref(false)
|
||||
const previewDialogVisible = ref(false)
|
||||
const formSaving = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const auditSaving = ref(false)
|
||||
const previewLoading = ref(false)
|
||||
const formMode = ref<'create' | 'edit'>('create')
|
||||
const currentRecord = ref<ReportModel.ReportModelRecord | null>(null)
|
||||
const detailRecord = ref<ReportModel.ReportModelRecord | null>(null)
|
||||
const previewFileBlob = ref<Blob | null>(null)
|
||||
const previewFileName = ref('')
|
||||
const previewErrorMessage = ref('')
|
||||
|
||||
const columns = reactive<ColumnProps<ReportModel.ReportModelRecord>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '模板名称',
|
||||
minWidth: 180,
|
||||
search: {
|
||||
el: 'input',
|
||||
order: 1,
|
||||
props: {
|
||||
placeholder: '请输入模板名称'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'path',
|
||||
label: '模版文件',
|
||||
minWidth: 260,
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) =>
|
||||
resolveReportModelFileName(row) ? (
|
||||
<el-button link type="primary" onClick={() => openPreviewDialog(row)}>
|
||||
{resolveReportModelFileName(row)}
|
||||
</el-button>
|
||||
) : (
|
||||
resolveReportModelText(resolveReportModelFileName(row))
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '模板状态',
|
||||
width: 120,
|
||||
enum: STATE_OPTIONS,
|
||||
isFilterEnum: false,
|
||||
render: scope => (
|
||||
<el-tag type={getReportModelStateTagType(scope.row.state)} effect="light">
|
||||
{getReportModelStateText(scope.row.state)}
|
||||
</el-tag>
|
||||
),
|
||||
search: {
|
||||
el: 'select',
|
||||
order: 2,
|
||||
props: {
|
||||
placeholder: '请选择模板状态'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'timeRange',
|
||||
label: '更新时间',
|
||||
minWidth: 220,
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'date-picker',
|
||||
order: 3,
|
||||
key: 'timeRange',
|
||||
props: {
|
||||
type: 'datetimerange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
startPlaceholder: '开始更新时间',
|
||||
endPlaceholder: '结束更新时间'
|
||||
}
|
||||
}
|
||||
},
|
||||
{ prop: 'editorName', label: '编辑人', width: 120, render: ({ row }) => resolveReportModelText(row.editorName) },
|
||||
{ prop: 'updateTime', label: '更新时间', minWidth: 170, render: ({ row }) => resolveReportModelText(row.updateTime) },
|
||||
{ prop: 'checkerName', label: '审核人', width: 120 },
|
||||
{ prop: 'checkTime', label: '审核时间', minWidth: 170, render: ({ row }) => resolveReportModelText(row.checkTime) },
|
||||
{ prop: 'checkResult', label: '审核意见', minWidth: 220, showOverflowTooltip: true, render: ({ row }) => resolveReportModelText(row.checkResult) },
|
||||
{ prop: 'createBy', label: '创建人', width: 120, isShow: false },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 380 }
|
||||
])
|
||||
|
||||
const getTableList = async (params: ReportModel.ReportModelListParams = {}) => {
|
||||
const response = await listReportModelsApi(normalizeReportModelListParams(params))
|
||||
const pageData = normalizeReportModelPage<ReportModel.ReportModelRecord>(response as unknown as ResPage<ReportModel.ReportModelRecord>)
|
||||
|
||||
return {
|
||||
data: pageData
|
||||
}
|
||||
}
|
||||
|
||||
const refreshReportModels = () => {
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const handleTableRequestError = (error: unknown) => {
|
||||
ElMessage.error(getReportModelErrorMessage(error, '模板列表查询失败'))
|
||||
}
|
||||
|
||||
const resetPreviewState = () => {
|
||||
previewLoading.value = false
|
||||
previewFileBlob.value = null
|
||||
previewFileName.value = ''
|
||||
previewErrorMessage.value = ''
|
||||
}
|
||||
|
||||
const openCreateDialog = () => {
|
||||
formMode.value = 'create'
|
||||
currentRecord.value = null
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openEditDialog = (row: ReportModel.ReportModelRecord) => {
|
||||
formMode.value = 'edit'
|
||||
currentRecord.value = row
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openDetailDialog = async (row: ReportModel.ReportModelRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前模板缺少 ID,无法查看详情')
|
||||
return
|
||||
}
|
||||
|
||||
detailRecord.value = null
|
||||
detailDialogVisible.value = true
|
||||
detailLoading.value = true
|
||||
|
||||
try {
|
||||
// 关键业务节点:详情字段单独走 GET /{id},列表页不假设审核意见和模板路径一定完整返回。
|
||||
const response = await getReportModelDetailApi(row.id)
|
||||
detailRecord.value = unwrapApiPayload<ReportModel.ReportModelRecord>(response)
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportModelErrorMessage(error, '模板详情查询失败'))
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const openPreviewDialog = async (row: ReportModel.ReportModelRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前模板缺少 ID,无法预览')
|
||||
return
|
||||
}
|
||||
|
||||
resetPreviewState()
|
||||
previewDialogVisible.value = true
|
||||
previewLoading.value = true
|
||||
|
||||
try {
|
||||
// 关键业务节点:页面内预览复用现有下载接口,优先从响应头解析真实文件名,再决定是否可进入 docx 渲染。
|
||||
const response = await downloadReportModelApi(row.id)
|
||||
const fallbackExtension = row.path?.toLowerCase().endsWith('.doc') ? '.doc' : '.docx'
|
||||
const fileName = resolveReportModelDownloadFileName(response.headers, row.name || 'report-model', fallbackExtension)
|
||||
|
||||
previewFileName.value = fileName
|
||||
|
||||
if (!canPreviewReportModelFile(fileName) && !canPreviewReportModelFile(resolveReportModelFileName(row))) {
|
||||
previewErrorMessage.value = '当前仅支持 .docx 模板页面内预览,请下载 .doc 文件后查看'
|
||||
return
|
||||
}
|
||||
|
||||
previewFileBlob.value = response.data
|
||||
} catch (error) {
|
||||
previewErrorMessage.value = getReportModelErrorMessage(error, '模板预览加载失败')
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const openAuditDialog = async (row: ReportModel.ReportModelRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前模板缺少 ID,无法提交审核')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm(`确认提交模板“${row.name || '-'}”进入审核中状态吗?`, '提交审核', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
auditSaving.value = true
|
||||
|
||||
try {
|
||||
// 关键业务节点:提交审核只允许编制态记录调用,前端在按钮态和提交前都保持同一约束。
|
||||
await submitReportModelAuditApi({ id: row.id })
|
||||
ElMessage.success('模板提交审核成功')
|
||||
refreshReportModels()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportModelErrorMessage(error, '模板提交审核失败'))
|
||||
} finally {
|
||||
auditSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSaveReportModel = async ({
|
||||
request,
|
||||
file
|
||||
}: {
|
||||
request: ReportModel.ReportModelSaveRequest
|
||||
file: File | null
|
||||
}) => {
|
||||
formSaving.value = true
|
||||
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (!file) {
|
||||
ElMessage.warning('新增模板时必须上传 Word 模板文件')
|
||||
return
|
||||
}
|
||||
|
||||
await createReportModelApi(request, file)
|
||||
ElMessage.success('模板新增成功')
|
||||
} else {
|
||||
await updateReportModelApi(request, file)
|
||||
ElMessage.success('模板编辑成功')
|
||||
}
|
||||
|
||||
formDialogVisible.value = false
|
||||
refreshReportModels()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportModelErrorMessage(error, '模板保存失败'))
|
||||
} finally {
|
||||
formSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const deleteReportModels = async (ids: string[], successMessage: string) => {
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('请选择要删除的模板')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm('删除后模板将不可见,是否继续?', '删除模板', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await deleteReportModelsApi(ids)
|
||||
ElMessage.success(successMessage)
|
||||
refreshReportModels()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportModelErrorMessage(error, '模板删除失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleDelete = async (row: ReportModel.ReportModelRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前模板缺少 ID,无法删除')
|
||||
return
|
||||
}
|
||||
|
||||
await deleteReportModels([row.id], '模板删除成功')
|
||||
}
|
||||
|
||||
const handleBatchDelete = async (ids: string[]) => {
|
||||
await deleteReportModels(ids, '模板批量删除成功')
|
||||
}
|
||||
|
||||
const handleDownload = async (row: ReportModel.ReportModelRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前模板缺少 ID,无法下载')
|
||||
return
|
||||
}
|
||||
|
||||
await useDownloadWithServerFileName(() => downloadReportModelApi(row.id!), row.name || 'report-model', undefined, false, '.docx')
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-model-page {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
125
frontend/src/views/aireport/reportModel/utils/reportModel.ts
Normal file
125
frontend/src/views/aireport/reportModel/utils/reportModel.ts
Normal file
@@ -0,0 +1,125 @@
|
||||
import type { TagProps } from 'element-plus'
|
||||
import type { ResultData, ResPage } from '@/api/interface'
|
||||
import type { ReportModel } from '@/api/aireport/reportModel/interface'
|
||||
|
||||
type TagType = TagProps['type']
|
||||
type ResponseHeaders = Record<string, unknown>
|
||||
|
||||
const REPORT_MODEL_STATE_MAP: Record<string, { text: string; tagType: TagType }> = {
|
||||
'01': { text: '编制', tagType: 'info' },
|
||||
'02': { text: '审核中', tagType: 'warning' },
|
||||
'03': { text: '已发布', tagType: 'success' },
|
||||
'04': { text: '已删除', tagType: 'danger' }
|
||||
}
|
||||
|
||||
const REPORT_MODEL_WORD_EXTENSIONS = ['doc', 'docx']
|
||||
|
||||
export const REPORT_MODEL_TEMPLATE_ACCEPT = '.doc,.docx'
|
||||
|
||||
export const getReportModelStateText = (state?: string) => REPORT_MODEL_STATE_MAP[state || '']?.text || '未知状态'
|
||||
|
||||
export const getReportModelStateTagType = (state?: string): TagType => REPORT_MODEL_STATE_MAP[state || '']?.tagType || 'info'
|
||||
|
||||
export const isDraftReportModel = (row?: ReportModel.ReportModelRecord | null) => row?.state === '01'
|
||||
|
||||
export const resolveReportModelFileName = (row?: ReportModel.ReportModelRecord | null) =>
|
||||
row?.fileName || row?.file_name || row?.path || ''
|
||||
|
||||
export const resolveReportModelText = (value: unknown) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
const text = String(value).trim()
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
export const getReportModelFileExtension = (fileName?: string | null) => {
|
||||
if (!fileName) return ''
|
||||
|
||||
const segments = fileName.split('.')
|
||||
return segments.length > 1 ? segments.pop()!.toLowerCase() : ''
|
||||
}
|
||||
|
||||
export const validateReportModelTemplateFile = (file: File) => {
|
||||
if (!REPORT_MODEL_WORD_EXTENSIONS.includes(getReportModelFileExtension(file.name))) {
|
||||
return '报告模板仅支持 Word 文档(.doc/.docx)'
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
const decodeReportModelFileName = (value: string) => {
|
||||
try {
|
||||
return decodeURIComponent(value)
|
||||
} catch {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
export const resolveReportModelDownloadFileName = (
|
||||
headers?: ResponseHeaders | null,
|
||||
fallbackName = 'report-model',
|
||||
fallbackExtension = '.docx'
|
||||
) => {
|
||||
const contentDisposition = String(headers?.['content-disposition'] || headers?.['Content-Disposition'] || '')
|
||||
const utf8Match = /filename\*\s*=\s*UTF-8''([^;]+)/i.exec(contentDisposition)
|
||||
|
||||
if (utf8Match?.[1]) {
|
||||
return decodeReportModelFileName(utf8Match[1].trim())
|
||||
}
|
||||
|
||||
const fallbackMatch = /filename\s*=\s*([^;]+)/i.exec(contentDisposition)
|
||||
|
||||
if (fallbackMatch?.[1]) {
|
||||
return decodeReportModelFileName(fallbackMatch[1].trim().replace(/^["']|["']$/g, ''))
|
||||
}
|
||||
|
||||
return `${fallbackName}${fallbackExtension}`
|
||||
}
|
||||
|
||||
export const canPreviewReportModelFile = (fileName?: string | null) => getReportModelFileExtension(fileName) === 'docx'
|
||||
|
||||
export const normalizeReportModelListParams = (
|
||||
params: ReportModel.ReportModelListParams = {}
|
||||
): ReportModel.ReportModelListParams => {
|
||||
const timeRange = Array.isArray(params.timeRange) ? params.timeRange : []
|
||||
const [searchBeginTime = '', searchEndTime = ''] = timeRange
|
||||
|
||||
return {
|
||||
name: String(params.name || '').trim() || undefined,
|
||||
state: params.state || undefined,
|
||||
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
||||
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
||||
pageNum: params.pageNum || 1,
|
||||
pageSize: params.pageSize || 10
|
||||
}
|
||||
}
|
||||
|
||||
export const unwrapApiPayload = <T>(response: ResultData<T> | T): T => {
|
||||
if (response && typeof response === 'object' && 'data' in response) {
|
||||
return (response as ResultData<T>).data
|
||||
}
|
||||
|
||||
return response as T
|
||||
}
|
||||
|
||||
export const normalizeReportModelPage = <T>(
|
||||
response: ResultData<ResPage<T>> | ResPage<T> | null | undefined
|
||||
): ResPage<T> => {
|
||||
const payload = unwrapApiPayload<ResPage<T> | null | undefined>(response as ResultData<ResPage<T>>)
|
||||
|
||||
return {
|
||||
records: payload?.records || [],
|
||||
current: payload?.current || 1,
|
||||
size: payload?.size || 10,
|
||||
total: payload?.total || 0
|
||||
}
|
||||
}
|
||||
|
||||
export const getReportModelErrorMessage = (error: unknown, fallback: string) => {
|
||||
if (error instanceof Error && error.message) return error.message
|
||||
if (error && typeof error === 'object' && 'message' in error) {
|
||||
return String((error as { message?: unknown }).message || fallback)
|
||||
}
|
||||
|
||||
return fallback
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<el-dialog v-model="visibleProxy" title="检测设备详情" width="720px" append-to-body destroy-on-close>
|
||||
<div v-loading="loading" class="test-device-detail-dialog">
|
||||
<el-descriptions class="detail-descriptions" :column="2" border>
|
||||
<el-descriptions-item label="设备型号">{{ resolveTestDeviceText(detail?.typeName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="设备编号">{{ resolveTestDeviceText(detail?.no) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="设备状态">
|
||||
<el-tag :type="getTestDeviceStateTagType(detail?.state)" effect="light">
|
||||
{{ getTestDeviceStateText(detail?.state) }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="校准有效期">
|
||||
{{ resolveTestDeviceText(detail?.validityPeriod) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="校准报告" :span="2">
|
||||
{{ resolveTestDeviceText(detail?.validityReportName || detail?.validityReport) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人">
|
||||
{{ resolveTestDeviceText(detail?.createByName || detail?.createBy) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ resolveTestDeviceText(detail?.createTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新人">
|
||||
{{ resolveTestDeviceText(detail?.updateByName || detail?.updateBy) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ resolveTestDeviceText(detail?.updateTime) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { TestDevice } from '@/api/aireport/testDevice/interface'
|
||||
import { getTestDeviceStateTagType, getTestDeviceStateText, resolveTestDeviceText } from '../utils/testDevice'
|
||||
|
||||
defineOptions({
|
||||
name: 'TestDeviceDetailDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
loading: boolean
|
||||
detail: TestDevice.TestDeviceRecord | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
}>()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.test-device-detail-dialog {
|
||||
min-height: 160px;
|
||||
}
|
||||
|
||||
.test-device-detail-dialog :deep(.detail-descriptions .el-descriptions__table) {
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.test-device-detail-dialog :deep(.detail-descriptions .el-descriptions__label.el-descriptions__cell.is-bordered-label) {
|
||||
width: 112px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,228 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
:title="mode === 'create' ? '新增检测设备' : '编辑检测设备'"
|
||||
width="640px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@closed="resetForm"
|
||||
>
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px">
|
||||
<el-form-item label="设备型号" prop="type">
|
||||
<el-select v-model="formModel.type" filterable clearable placeholder="请选择设备型号">
|
||||
<el-option
|
||||
v-for="option in deviceTypeSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备编号" prop="no">
|
||||
<el-input v-model="formModel.no" maxlength="64" clearable placeholder="请输入设备编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="校准有效期" prop="validityPeriod">
|
||||
<el-date-picker
|
||||
v-model="formModel.validityPeriod"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择校准有效期"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="校准报告" :required="mode === 'create'">
|
||||
<div class="file-select-row">
|
||||
<el-input :model-value="selectedFileName" readonly placeholder="请选择 PDF 校准报告" />
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="saving" @click="openFilePicker">
|
||||
选择文件
|
||||
</el-button>
|
||||
<input ref="fileInputRef" class="hidden-file-input" type="file" accept=".pdf" @change="handleFileChange" />
|
||||
</div>
|
||||
<div class="file-select-tip">
|
||||
{{
|
||||
mode === 'create'
|
||||
? `新增检测设备时必须上传 PDF 校准报告,文件大小不能超过 ${TEST_DEVICE_REPORT_MAX_SIZE_TEXT}`
|
||||
: `编辑时不上传则保留原报告,新上传文件需为 PDF 且不能超过 ${TEST_DEVICE_REPORT_MAX_SIZE_TEXT}`
|
||||
}}
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备状态" prop="state">
|
||||
<el-select v-model="formModel.state" placeholder="请选择设备状态">
|
||||
<el-option
|
||||
v-for="option in TEST_DEVICE_STATE_OPTIONS"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submitForm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { FolderOpened } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { TestDevice } from '@/api/aireport/testDevice/interface'
|
||||
import {
|
||||
TEST_DEVICE_REPORT_MAX_SIZE_TEXT,
|
||||
TEST_DEVICE_STATE_OPTIONS,
|
||||
validateTestDeviceReportFile
|
||||
} from '../utils/testDevice'
|
||||
|
||||
defineOptions({
|
||||
name: 'TestDeviceFormDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
record: TestDevice.TestDeviceRecord | null
|
||||
saving: boolean
|
||||
deviceTypeOptions: Array<{ label: string; value: string }>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: { request: TestDevice.TestDeviceSaveRequest; reportFile: File | null }): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const selectedFile = ref<File | null>(null)
|
||||
const formModel = reactive({
|
||||
id: '',
|
||||
type: '',
|
||||
no: '',
|
||||
validityPeriod: '',
|
||||
state: '01'
|
||||
})
|
||||
|
||||
const formRules: FormRules = {
|
||||
type: [{ required: true, message: '请选择设备型号', trigger: 'change' }],
|
||||
no: [{ required: true, message: '请输入设备编号', trigger: 'blur' }],
|
||||
validityPeriod: [{ required: true, message: '请选择校准有效期', trigger: 'change' }],
|
||||
state: [{ required: true, message: '请选择设备状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
const selectedFileName = computed(() => selectedFile.value?.name || props.record?.validityReportName || '')
|
||||
const deviceTypeSelectOptions = computed(() => {
|
||||
if (!formModel.type || props.deviceTypeOptions.some(option => option.value === formModel.type)) {
|
||||
return props.deviceTypeOptions
|
||||
}
|
||||
|
||||
return [
|
||||
...props.deviceTypeOptions,
|
||||
{
|
||||
label: props.record?.typeName || formModel.type,
|
||||
value: formModel.type
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value?.clearValidate()
|
||||
selectedFile.value = null
|
||||
formModel.id = ''
|
||||
formModel.type = ''
|
||||
formModel.no = ''
|
||||
formModel.validityPeriod = ''
|
||||
formModel.state = '01'
|
||||
}
|
||||
|
||||
const fillForm = () => {
|
||||
formModel.id = props.record?.id || ''
|
||||
formModel.type = props.record?.type || ''
|
||||
formModel.no = props.record?.no || ''
|
||||
formModel.validityPeriod = props.record?.validityPeriod || ''
|
||||
formModel.state = props.record?.state || '01'
|
||||
selectedFile.value = null
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.mode, props.record?.id],
|
||||
([visible]) => {
|
||||
if (visible) fillForm()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const openFilePicker = () => {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const handleFileChange = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const reportFile = input.files?.[0] || null
|
||||
|
||||
input.value = ''
|
||||
if (!reportFile) return
|
||||
|
||||
const validationMessage = validateTestDeviceReportFile(reportFile)
|
||||
if (validationMessage) {
|
||||
ElMessage.warning(validationMessage)
|
||||
return
|
||||
}
|
||||
|
||||
selectedFile.value = reportFile
|
||||
}
|
||||
|
||||
const submitForm = async () => {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
|
||||
if (!valid) return
|
||||
|
||||
if (props.mode === 'create' && !selectedFile.value) {
|
||||
ElMessage.warning('新增检测设备时必须上传 PDF 校准报告')
|
||||
return
|
||||
}
|
||||
|
||||
if (props.mode === 'edit' && !formModel.id) {
|
||||
ElMessage.warning('当前检测设备缺少 ID,无法保存编辑')
|
||||
return
|
||||
}
|
||||
|
||||
emit('submit', {
|
||||
request: {
|
||||
id: formModel.id || undefined,
|
||||
type: formModel.type.trim(),
|
||||
no: formModel.no.trim(),
|
||||
validityPeriod: formModel.validityPeriod,
|
||||
state: formModel.state
|
||||
},
|
||||
reportFile: selectedFile.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.file-select-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.file-select-tip {
|
||||
margin-top: 8px;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-date-editor.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,157 @@
|
||||
<template>
|
||||
<el-dialog v-model="visibleProxy" title="导入检测设备" width="680px" append-to-body destroy-on-close @closed="resetImport">
|
||||
<div class="test-device-import-dialog">
|
||||
<div class="file-select-row">
|
||||
<el-input :model-value="selectedFileName" readonly placeholder="请选择检测设备 Excel 文件" />
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="importing" @click="openFilePicker">
|
||||
选择Excel
|
||||
</el-button>
|
||||
<input ref="fileInputRef" class="hidden-file-input" type="file" accept=".xlsx,.xls" @change="handleFileChange" />
|
||||
</div>
|
||||
<div class="file-select-row">
|
||||
<el-input :model-value="selectedZipName" readonly placeholder="请选择校准报告 ZIP" />
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="importing" @click="openZipPicker">
|
||||
选择ZIP
|
||||
</el-button>
|
||||
<input ref="zipInputRef" class="hidden-file-input" type="file" accept=".zip" @change="handleZipChange" />
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="result"
|
||||
class="import-result"
|
||||
:title="`导入完成:成功 ${result.successCount || 0} 条,失败 ${result.failCount || 0} 条`"
|
||||
:type="result.failCount ? 'warning' : 'success'"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
|
||||
<el-table v-if="result?.failReasons?.length" class="fail-reason-table" :data="failReasonRows" border>
|
||||
<el-table-column type="index" label="序号" width="70" align="center" />
|
||||
<el-table-column prop="reason" label="失败原因" min-width="260" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button :disabled="importing" @click="visibleProxy = false">取消</el-button>
|
||||
<el-button type="primary" :loading="importing" @click="submitImport">开始导入</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { FolderOpened } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { computed, ref } from 'vue'
|
||||
import type { TestDevice } from '@/api/aireport/testDevice/interface'
|
||||
import { validateTestDeviceImportExcelFile, validateTestDeviceImportZipFile } from '../utils/testDevice'
|
||||
|
||||
defineOptions({
|
||||
name: 'TestDeviceImportDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
importing: boolean
|
||||
result: TestDevice.TestDeviceImportResult | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: { file: File; reportZip: File }): void
|
||||
}>()
|
||||
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const zipInputRef = ref<HTMLInputElement | null>(null)
|
||||
const selectedFile = ref<File | null>(null)
|
||||
const reportZip = ref<File | null>(null)
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
const selectedFileName = computed(() => selectedFile.value?.name || '')
|
||||
const selectedZipName = computed(() => reportZip.value?.name || '')
|
||||
const failReasonRows = computed(() => (props.result?.failReasons || []).map(reason => ({ reason })))
|
||||
|
||||
const openFilePicker = () => {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const openZipPicker = () => {
|
||||
zipInputRef.value?.click()
|
||||
}
|
||||
|
||||
const handleFileChange = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0] || null
|
||||
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
|
||||
const validationMessage = validateTestDeviceImportExcelFile(file)
|
||||
if (validationMessage) {
|
||||
ElMessage.warning(validationMessage)
|
||||
return
|
||||
}
|
||||
|
||||
selectedFile.value = file
|
||||
}
|
||||
|
||||
const handleZipChange = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0] || null
|
||||
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
|
||||
const validationMessage = validateTestDeviceImportZipFile(file)
|
||||
if (validationMessage) {
|
||||
ElMessage.warning(validationMessage)
|
||||
return
|
||||
}
|
||||
|
||||
reportZip.value = file
|
||||
}
|
||||
|
||||
const resetImport = () => {
|
||||
selectedFile.value = null
|
||||
reportZip.value = null
|
||||
}
|
||||
|
||||
const submitImport = () => {
|
||||
if (!selectedFile.value) {
|
||||
ElMessage.warning('请选择检测设备 Excel 文件')
|
||||
return
|
||||
}
|
||||
if (!reportZip.value) {
|
||||
ElMessage.warning('请选择校准报告 ZIP')
|
||||
return
|
||||
}
|
||||
|
||||
emit('submit', {
|
||||
file: selectedFile.value,
|
||||
reportZip: reportZip.value
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.test-device-import-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.file-select-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.fail-reason-table {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
:title="previewTitle"
|
||||
width="960px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@closed="clearPreview"
|
||||
>
|
||||
<div v-loading="loading" class="test-device-report-preview-dialog">
|
||||
<div v-if="errorMessage" class="preview-error-wrapper">
|
||||
<el-alert :title="errorMessage" type="warning" :closable="false" show-icon />
|
||||
</div>
|
||||
<iframe
|
||||
v-else-if="previewUrl"
|
||||
:src="previewUrl"
|
||||
class="preview-frame"
|
||||
frameborder="0"
|
||||
title="校准报告预览"
|
||||
/>
|
||||
<div v-else class="preview-empty-wrapper">
|
||||
<el-empty description="暂无可预览的校准报告" />
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'TestDeviceReportPreviewDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
loading: boolean
|
||||
fileBlob: Blob | null
|
||||
fileName: string
|
||||
errorMessage: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
}>()
|
||||
|
||||
const previewUrl = ref('')
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const previewTitle = computed(() => (props.fileName ? `校准报告预览 - ${props.fileName}` : '校准报告预览'))
|
||||
|
||||
const revokePreviewUrl = () => {
|
||||
if (!previewUrl.value) return
|
||||
|
||||
URL.revokeObjectURL(previewUrl.value)
|
||||
previewUrl.value = ''
|
||||
}
|
||||
|
||||
const clearPreview = () => {
|
||||
revokePreviewUrl()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.fileBlob],
|
||||
() => {
|
||||
revokePreviewUrl()
|
||||
|
||||
if (!props.visible || !props.fileBlob) return
|
||||
|
||||
// 关键业务节点:PDF 预览必须为当前 blob 重新创建对象地址,并在弹窗关闭或文件切换时立即释放,避免旧报告串页或内存泄漏。
|
||||
previewUrl.value = URL.createObjectURL(props.fileBlob)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.test-device-report-preview-dialog {
|
||||
min-height: 520px;
|
||||
height: 70vh;
|
||||
background: #f5f7fa;
|
||||
}
|
||||
|
||||
.preview-error-wrapper,
|
||||
.preview-empty-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.preview-frame {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-height: 520px;
|
||||
border: 0;
|
||||
background: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,119 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const pageDir = path.resolve(__dirname, '..')
|
||||
const srcDir = path.resolve(pageDir, '../../..')
|
||||
const apiDir = path.resolve(srcDir, 'api/aireport/testDevice')
|
||||
|
||||
const read = file => fs.readFileSync(file, 'utf8')
|
||||
const assertFileIncludes = (file, snippets) => {
|
||||
const content = read(file)
|
||||
const missing = snippets.filter(snippet => !content.includes(snippet))
|
||||
|
||||
if (missing.length) {
|
||||
throw new Error(`${path.relative(srcDir, file)} missing: ${missing.join(', ')}`)
|
||||
}
|
||||
}
|
||||
|
||||
assertFileIncludes(path.join(apiDir, 'index.ts'), [
|
||||
"const TEST_DEVICE_BASE_URL = '/api/test-device'",
|
||||
'listTestDevicesApi',
|
||||
'createTestDeviceApi',
|
||||
'updateTestDeviceApi',
|
||||
'deleteTestDevicesApi',
|
||||
'getTestDeviceDetailApi',
|
||||
'downloadTestDeviceImportTemplateApi',
|
||||
'importTestDevicesApi',
|
||||
'exportTestDevicesApi',
|
||||
'downloadTestDeviceReportApi',
|
||||
'previewTestDeviceReportApi',
|
||||
"return http.get(`${TEST_DEVICE_BASE_URL}/${id}/report`, undefined, { responseType: 'blob' })",
|
||||
"formData.append('request'",
|
||||
"formData.append('reportFile'",
|
||||
"formData.append('reportZip'"
|
||||
])
|
||||
|
||||
const apiIndexContent = read(path.join(apiDir, 'index.ts'))
|
||||
if (apiIndexContent.includes('/api/test-report/')) {
|
||||
throw new Error('api/aireport/testDevice/index.ts should not reference /api/test-report preview endpoint')
|
||||
}
|
||||
|
||||
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
||||
'export namespace TestDevice',
|
||||
'TestDeviceRecord',
|
||||
'TestDeviceListParams',
|
||||
'TestDeviceSaveRequest',
|
||||
'TestDeviceImportResult',
|
||||
"export type TestDeviceState = '01' | '02' | (string & {})"
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'utils/testDevice.ts'), [
|
||||
'normalizeTestDeviceListParams',
|
||||
'normalizeTestDevicePage',
|
||||
'getTestDeviceStateText',
|
||||
'getTestDeviceStateTagType',
|
||||
'unwrapTestDevicePayload'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/TestDeviceFormDialog.vue'), [
|
||||
"name: 'TestDeviceFormDialog'",
|
||||
'reportFile',
|
||||
'validityPeriod',
|
||||
'新增检测设备时必须上传 PDF 校准报告'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/TestDeviceImportDialog.vue'), [
|
||||
"name: 'TestDeviceImportDialog'",
|
||||
'reportZip',
|
||||
'failReasons',
|
||||
'请选择校准报告 ZIP'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/TestDeviceDetailDialog.vue'), [
|
||||
"name: 'TestDeviceDetailDialog'",
|
||||
'设备型号',
|
||||
'校准报告',
|
||||
"detail?.updateByName || detail?.updateBy",
|
||||
':span="2"',
|
||||
'table-layout: fixed',
|
||||
'width: 112px'
|
||||
])
|
||||
|
||||
const detailDialogContent = read(path.join(pageDir, 'components/TestDeviceDetailDialog.vue'))
|
||||
if (detailDialogContent.includes('设备型号ID')) {
|
||||
throw new Error('views/aireport/testDevice/components/TestDeviceDetailDialog.vue should not display 设备型号ID')
|
||||
}
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
||||
"name: 'TestDevicePage'",
|
||||
'<ProTable',
|
||||
'TestDeviceFormDialog',
|
||||
'TestDeviceDetailDialog',
|
||||
'TestDeviceImportDialog',
|
||||
'TestDeviceReportPreviewDialog',
|
||||
'handleDownloadReport',
|
||||
'openPreviewDialog',
|
||||
'previewTestDeviceReportApi',
|
||||
'handleDownloadTemplate',
|
||||
'handleImportTestDevices',
|
||||
'type="primary" :icon="Plus"',
|
||||
'type="danger"',
|
||||
'type="primary" plain'
|
||||
])
|
||||
|
||||
const pageSource = read(path.join(pageDir, 'index.vue'))
|
||||
if (!/prop:\s*'timeRange'[\s\S]*label:\s*'更新时间'[\s\S]*startPlaceholder:\s*'开始更新时间'[\s\S]*endPlaceholder:\s*'结束更新时间'/.test(pageSource)) {
|
||||
throw new Error('views/aireport/testDevice/index.vue should use 更新时间 as the search time range label')
|
||||
}
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/TestDeviceReportPreviewDialog.vue'), [
|
||||
"name: 'TestDeviceReportPreviewDialog'",
|
||||
'fileBlob',
|
||||
'fileName',
|
||||
'errorMessage',
|
||||
'URL.createObjectURL'
|
||||
])
|
||||
|
||||
console.log('testDevice page contract passed')
|
||||
449
frontend/src/views/aireport/testDevice/index.vue
Normal file
449
frontend/src/views/aireport/testDevice/index.vue
Normal file
@@ -0,0 +1,449 @@
|
||||
<template>
|
||||
<div class="table-box test-device-page">
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
:request-error="handleTableRequestError"
|
||||
:search-col="{ xs: 1, sm: 2, md: 2, lg: 4, xl: 4 }"
|
||||
:tool-button="['refresh', 'setting']"
|
||||
row-key="id"
|
||||
>
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="Plus" @click="openCreateDialog">新增</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
:icon="Delete"
|
||||
:disabled="!scope.isSelected"
|
||||
@click="handleBatchDelete(scope.selectedListIds)"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
<el-button type="primary" plain :icon="Download" @click="handleExport">导出</el-button>
|
||||
<el-button type="primary" plain :icon="Document" @click="handleDownloadTemplate">下载模板</el-button>
|
||||
<el-button type="primary" plain :icon="Upload" @click="openImportDialog">导入</el-button>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<el-button link type="primary" :icon="View" @click="openDetailDialog(row)">详情</el-button>
|
||||
<el-button link type="primary" :icon="Edit" @click="openEditDialog(row)">编辑</el-button>
|
||||
<el-button link type="primary" :icon="Download" :disabled="!row.id" @click="handleDownloadReport(row)">
|
||||
报告
|
||||
</el-button>
|
||||
<el-button link type="danger" :icon="Delete" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<TestDeviceFormDialog
|
||||
v-model:visible="formDialogVisible"
|
||||
:mode="formMode"
|
||||
:record="currentRecord"
|
||||
:saving="formSaving"
|
||||
:device-type-options="deviceTypeOptions"
|
||||
@submit="handleSaveTestDevice"
|
||||
/>
|
||||
|
||||
<TestDeviceDetailDialog
|
||||
v-model:visible="detailDialogVisible"
|
||||
:loading="detailLoading"
|
||||
:detail="detailRecord"
|
||||
/>
|
||||
|
||||
<TestDeviceImportDialog
|
||||
v-model:visible="importDialogVisible"
|
||||
:importing="importing"
|
||||
:result="importResult"
|
||||
@submit="handleImportTestDevices"
|
||||
/>
|
||||
|
||||
<TestDeviceReportPreviewDialog
|
||||
v-model:visible="previewDialogVisible"
|
||||
:loading="previewLoading"
|
||||
:file-name="previewFileName"
|
||||
:file-blob="previewFileBlob"
|
||||
:error-message="previewErrorMessage"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { Delete, Document, Download, Edit, Plus, Upload, View } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, reactive, ref } from 'vue'
|
||||
import type { ResPage } from '@/api/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import {
|
||||
createTestDeviceApi,
|
||||
deleteTestDevicesApi,
|
||||
downloadTestDeviceImportTemplateApi,
|
||||
downloadTestDeviceReportApi,
|
||||
exportTestDevicesApi,
|
||||
getTestDeviceDetailApi,
|
||||
importTestDevicesApi,
|
||||
listTestDevicesApi,
|
||||
previewTestDeviceReportApi,
|
||||
updateTestDeviceApi
|
||||
} from '@/api/aireport/testDevice'
|
||||
import type { TestDevice } from '@/api/aireport/testDevice/interface'
|
||||
import { listDeviceTypesApi } from '@/api/tools/mmsmapping'
|
||||
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||
import TestDeviceDetailDialog from './components/TestDeviceDetailDialog.vue'
|
||||
import TestDeviceFormDialog from './components/TestDeviceFormDialog.vue'
|
||||
import TestDeviceImportDialog from './components/TestDeviceImportDialog.vue'
|
||||
import TestDeviceReportPreviewDialog from './components/TestDeviceReportPreviewDialog.vue'
|
||||
import {
|
||||
TEST_DEVICE_STATE_OPTIONS,
|
||||
getTestDeviceErrorMessage,
|
||||
getTestDeviceImportResultMessage,
|
||||
getTestDeviceStateTagType,
|
||||
getTestDeviceStateText,
|
||||
normalizeTestDeviceListParams,
|
||||
normalizeTestDevicePage,
|
||||
resolveTestDeviceText,
|
||||
unwrapTestDevicePayload
|
||||
} from './utils/testDevice'
|
||||
|
||||
defineOptions({
|
||||
name: 'TestDevicePage'
|
||||
})
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const formDialogVisible = ref(false)
|
||||
const detailDialogVisible = ref(false)
|
||||
const importDialogVisible = ref(false)
|
||||
const previewDialogVisible = ref(false)
|
||||
const formSaving = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const importing = ref(false)
|
||||
const previewLoading = ref(false)
|
||||
const formMode = ref<'create' | 'edit'>('create')
|
||||
const currentRecord = ref<TestDevice.TestDeviceRecord | null>(null)
|
||||
const detailRecord = ref<TestDevice.TestDeviceRecord | null>(null)
|
||||
const importResult = ref<TestDevice.TestDeviceImportResult | null>(null)
|
||||
const deviceTypeOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const previewFileBlob = ref<Blob | null>(null)
|
||||
const previewFileName = ref('')
|
||||
const previewErrorMessage = ref('')
|
||||
|
||||
const currentSearchParams = computed(() =>
|
||||
normalizeTestDeviceListParams((proTable.value?.searchParam || {}) as TestDevice.TestDeviceListParams)
|
||||
)
|
||||
|
||||
const columns = reactive<ColumnProps<TestDevice.TestDeviceRecord>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'keyword',
|
||||
label: '关键字',
|
||||
minWidth: 180,
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'input',
|
||||
order: 1,
|
||||
props: {
|
||||
placeholder: '请输入设备型号或设备编号'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'timeRange',
|
||||
label: '更新时间',
|
||||
minWidth: 220,
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'date-picker',
|
||||
order: 2,
|
||||
key: 'timeRange',
|
||||
props: {
|
||||
type: 'datetimerange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
startPlaceholder: '开始更新时间',
|
||||
endPlaceholder: '结束更新时间'
|
||||
}
|
||||
}
|
||||
},
|
||||
{ prop: 'typeName', label: '设备型号', minWidth: 180, fixed: 'left', render: ({ row }) => resolveTestDeviceText(row.typeName) },
|
||||
{ prop: 'no', label: '设备编号', minWidth: 170, showOverflowTooltip: true, render: ({ row }) => resolveTestDeviceText(row.no) },
|
||||
{ prop: 'validityPeriod', label: '校准有效期', width: 130, render: ({ row }) => resolveTestDeviceText(row.validityPeriod) },
|
||||
{
|
||||
prop: 'validityReportName',
|
||||
label: '校准报告',
|
||||
minWidth: 180,
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => {
|
||||
const reportName = row.validityReportName || row.validityReport
|
||||
|
||||
return row.id && reportName ? (
|
||||
<el-button link type="primary" onClick={() => openPreviewDialog(row)}>
|
||||
{reportName}
|
||||
</el-button>
|
||||
) : (
|
||||
resolveTestDeviceText(reportName)
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '设备状态',
|
||||
width: 110,
|
||||
enum: TEST_DEVICE_STATE_OPTIONS,
|
||||
isFilterEnum: false,
|
||||
render: scope => (
|
||||
<el-tag type={getTestDeviceStateTagType(scope.row.state)} effect="light">
|
||||
{getTestDeviceStateText(scope.row.state)}
|
||||
</el-tag>
|
||||
)
|
||||
},
|
||||
{ prop: 'createByName', label: '创建人', width: 120, render: ({ row }) => resolveTestDeviceText(row.createByName || row.createBy) },
|
||||
{ prop: 'createTime', label: '创建时间', minWidth: 170, render: ({ row }) => resolveTestDeviceText(row.createTime) },
|
||||
{ prop: 'updateByName', label: '更新人', width: 120, render: ({ row }) => resolveTestDeviceText(row.updateByName || row.updateBy) },
|
||||
{ prop: 'updateTime', label: '更新时间', minWidth: 170, render: ({ row }) => resolveTestDeviceText(row.updateTime) },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 300 }
|
||||
])
|
||||
|
||||
const getTableList = async (params: TestDevice.TestDeviceListParams = {}) => {
|
||||
const response = await listTestDevicesApi(normalizeTestDeviceListParams(params))
|
||||
const pageData = normalizeTestDevicePage<TestDevice.TestDeviceRecord>(
|
||||
response as unknown as ResPage<TestDevice.TestDeviceRecord>
|
||||
)
|
||||
|
||||
return {
|
||||
data: pageData
|
||||
}
|
||||
}
|
||||
|
||||
const refreshTestDevices = () => {
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const handleTableRequestError = (error: unknown) => {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备列表查询失败'))
|
||||
}
|
||||
|
||||
const resetPreviewState = () => {
|
||||
previewLoading.value = false
|
||||
previewFileBlob.value = null
|
||||
previewFileName.value = ''
|
||||
previewErrorMessage.value = ''
|
||||
}
|
||||
|
||||
const loadDeviceTypeOptions = async () => {
|
||||
try {
|
||||
const response = await listDeviceTypesApi()
|
||||
const records = unwrapTestDevicePayload<Array<{ id?: string; name?: string }>>(response) || []
|
||||
|
||||
deviceTypeOptions.value = records
|
||||
.filter(record => record.id && record.name)
|
||||
.map(record => ({
|
||||
label: record.name!,
|
||||
value: record.id!
|
||||
}))
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '设备型号列表查询失败'))
|
||||
deviceTypeOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const openCreateDialog = () => {
|
||||
formMode.value = 'create'
|
||||
currentRecord.value = null
|
||||
loadDeviceTypeOptions()
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openEditDialog = (row: TestDevice.TestDeviceRecord) => {
|
||||
formMode.value = 'edit'
|
||||
currentRecord.value = row
|
||||
loadDeviceTypeOptions()
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openDetailDialog = async (row: TestDevice.TestDeviceRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前检测设备缺少 ID,无法查看详情')
|
||||
return
|
||||
}
|
||||
|
||||
detailRecord.value = null
|
||||
detailDialogVisible.value = true
|
||||
detailLoading.value = true
|
||||
|
||||
try {
|
||||
// 详情以 GET /{id} 为准,避免列表缺失报告名称或创建人等回显字段。
|
||||
const response = await getTestDeviceDetailApi(row.id)
|
||||
detailRecord.value = unwrapTestDevicePayload<TestDevice.TestDeviceRecord>(response)
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备详情查询失败'))
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const openImportDialog = () => {
|
||||
importResult.value = null
|
||||
importDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openPreviewDialog = async (row: TestDevice.TestDeviceRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前检测设备缺少 ID,无法预览校准报告')
|
||||
return
|
||||
}
|
||||
|
||||
resetPreviewState()
|
||||
previewDialogVisible.value = true
|
||||
previewLoading.value = true
|
||||
|
||||
try {
|
||||
// 关键业务节点:test-device 当前仅提供 /{id}/report,报告名预览与“报告”下载统一复用同一报告流。
|
||||
const response = await previewTestDeviceReportApi(row.id)
|
||||
previewFileBlob.value = response.data as Blob
|
||||
previewFileName.value = row.validityReportName || row.validityReport || `${row.no || 'test-device-report'}.pdf`
|
||||
} catch (error) {
|
||||
previewErrorMessage.value = getTestDeviceErrorMessage(error, '检测设备校准报告预览加载失败')
|
||||
} finally {
|
||||
previewLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSaveTestDevice = async ({
|
||||
request,
|
||||
reportFile
|
||||
}: {
|
||||
request: TestDevice.TestDeviceSaveRequest
|
||||
reportFile: File | null
|
||||
}) => {
|
||||
formSaving.value = true
|
||||
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (!reportFile) {
|
||||
ElMessage.warning('新增检测设备时必须上传 PDF 校准报告')
|
||||
return
|
||||
}
|
||||
|
||||
await createTestDeviceApi(request, reportFile)
|
||||
ElMessage.success('检测设备新增成功')
|
||||
} else {
|
||||
await updateTestDeviceApi(request, reportFile)
|
||||
ElMessage.success('检测设备编辑成功')
|
||||
}
|
||||
|
||||
formDialogVisible.value = false
|
||||
refreshTestDevices()
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备保存失败'))
|
||||
} finally {
|
||||
formSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const deleteTestDevices = async (ids: string[], successMessage: string) => {
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('请选择要删除的检测设备')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm('删除后检测设备将不可见,是否继续?', '删除检测设备', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await deleteTestDevicesApi(ids)
|
||||
ElMessage.success(successMessage)
|
||||
refreshTestDevices()
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备删除失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleDelete = async (row: TestDevice.TestDeviceRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前检测设备缺少 ID,无法删除')
|
||||
return
|
||||
}
|
||||
|
||||
await deleteTestDevices([row.id], '检测设备删除成功')
|
||||
}
|
||||
|
||||
const handleBatchDelete = async (ids: string[]) => {
|
||||
await deleteTestDevices(ids, '检测设备批量删除成功')
|
||||
}
|
||||
|
||||
const handleDownloadTemplate = async () => {
|
||||
try {
|
||||
await useDownloadWithServerFileName(
|
||||
() => downloadTestDeviceImportTemplateApi(),
|
||||
'检测设备导入模板',
|
||||
undefined,
|
||||
false,
|
||||
'.xlsx'
|
||||
)
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备导入模板下载失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await useDownloadWithServerFileName(exportTestDevicesApi, '检测设备列表', currentSearchParams.value, false, '.xlsx')
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备导出失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleDownloadReport = async (row: TestDevice.TestDeviceRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前检测设备缺少 ID,无法下载报告')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await useDownloadWithServerFileName(
|
||||
() => downloadTestDeviceReportApi(row.id!),
|
||||
row.validityReportName || row.no || '检测设备校准报告',
|
||||
undefined,
|
||||
false,
|
||||
'.pdf'
|
||||
)
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备校准报告下载失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleImportTestDevices = async ({ file, reportZip }: { file: File; reportZip: File }) => {
|
||||
importing.value = true
|
||||
|
||||
try {
|
||||
// 导入接口按整批校验返回成功/失败明细,结果保留在弹窗内便于核对。
|
||||
const response = await importTestDevicesApi(file, reportZip)
|
||||
importResult.value = unwrapTestDevicePayload<TestDevice.TestDeviceImportResult>(response)
|
||||
const importFeedback = getTestDeviceImportResultMessage(importResult.value)
|
||||
ElMessage({
|
||||
type: importFeedback.type,
|
||||
message: importFeedback.message
|
||||
})
|
||||
refreshTestDevices()
|
||||
} catch (error) {
|
||||
ElMessage.error(getTestDeviceErrorMessage(error, '检测设备导入失败'))
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.test-device-page {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
138
frontend/src/views/aireport/testDevice/utils/testDevice.ts
Normal file
138
frontend/src/views/aireport/testDevice/utils/testDevice.ts
Normal file
@@ -0,0 +1,138 @@
|
||||
import type { TagProps } from 'element-plus'
|
||||
import type { ResultData, ResPage } from '@/api/interface'
|
||||
import type { TestDevice } from '@/api/aireport/testDevice/interface'
|
||||
|
||||
type TagType = TagProps['type']
|
||||
const TEST_DEVICE_REPORT_MAX_SIZE = 10 * 1024 * 1024
|
||||
const TEST_DEVICE_REPORT_EXTENSIONS = ['pdf']
|
||||
const TEST_DEVICE_IMPORT_EXCEL_EXTENSIONS = ['xls', 'xlsx']
|
||||
const TEST_DEVICE_IMPORT_ZIP_EXTENSIONS = ['zip']
|
||||
|
||||
const TEST_DEVICE_STATE_MAP: Record<string, { text: string; tagType: TagType }> = {
|
||||
'01': { text: '在运', tagType: 'success' },
|
||||
'02': { text: '退运', tagType: 'info' }
|
||||
}
|
||||
|
||||
export const TEST_DEVICE_STATE_OPTIONS = [
|
||||
{ label: '在运', value: '01', tagType: 'success' },
|
||||
{ label: '退运', value: '02', tagType: 'info' }
|
||||
]
|
||||
|
||||
export const TEST_DEVICE_REPORT_MAX_SIZE_TEXT = '10MB'
|
||||
|
||||
export const getTestDeviceStateText = (state?: string) => TEST_DEVICE_STATE_MAP[state || '']?.text || '未知状态'
|
||||
|
||||
export const getTestDeviceStateTagType = (state?: string): TagType => TEST_DEVICE_STATE_MAP[state || '']?.tagType || 'info'
|
||||
|
||||
const getFileExtension = (fileName?: string | null) => {
|
||||
if (!fileName) return ''
|
||||
|
||||
const segments = fileName.split('.')
|
||||
return segments.length > 1 ? segments.pop()!.toLowerCase() : ''
|
||||
}
|
||||
|
||||
const isFileExtensionAllowed = (fileName: string, extensions: string[]) => extensions.includes(getFileExtension(fileName))
|
||||
|
||||
export const validateTestDeviceReportFile = (file: File) => {
|
||||
if (!isFileExtensionAllowed(file.name, TEST_DEVICE_REPORT_EXTENSIONS)) {
|
||||
return '校准报告仅支持PDF文件'
|
||||
}
|
||||
|
||||
if (file.size > TEST_DEVICE_REPORT_MAX_SIZE) {
|
||||
return `校准报告不能超过${TEST_DEVICE_REPORT_MAX_SIZE_TEXT}`
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
export const validateTestDeviceImportExcelFile = (file: File) => {
|
||||
if (!isFileExtensionAllowed(file.name, TEST_DEVICE_IMPORT_EXCEL_EXTENSIONS)) {
|
||||
return '请选择 Excel 文件(.xls 或 .xlsx)'
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
export const validateTestDeviceImportZipFile = (file: File) => {
|
||||
if (!isFileExtensionAllowed(file.name, TEST_DEVICE_IMPORT_ZIP_EXTENSIONS)) {
|
||||
return '请选择 ZIP 压缩包'
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
export const getTestDeviceImportResultMessage = (result?: TestDevice.TestDeviceImportResult | null) => {
|
||||
const successCount = result?.successCount || 0
|
||||
const failCount = result?.failCount || 0
|
||||
|
||||
if (failCount > 0 && successCount > 0) {
|
||||
return {
|
||||
type: 'warning' as const,
|
||||
message: `检测设备导入完成,成功 ${successCount} 条,失败 ${failCount} 条`
|
||||
}
|
||||
}
|
||||
|
||||
if (failCount > 0) {
|
||||
return {
|
||||
type: 'warning' as const,
|
||||
message: `检测设备导入失败,共 ${failCount} 条,请根据失败原因修正后重试`
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'success' as const,
|
||||
message: `检测设备导入完成,成功 ${successCount} 条`
|
||||
}
|
||||
}
|
||||
|
||||
export const resolveTestDeviceText = (value: unknown) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
const text = String(value).trim()
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
export const normalizeTestDeviceListParams = (
|
||||
params: TestDevice.TestDeviceListParams = {}
|
||||
): TestDevice.TestDeviceListParams => {
|
||||
const timeRange = Array.isArray(params.timeRange) ? params.timeRange : []
|
||||
const [searchBeginTime = '', searchEndTime = ''] = timeRange
|
||||
|
||||
return {
|
||||
keyword: String(params.keyword || '').trim() || undefined,
|
||||
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
||||
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
||||
pageNum: params.pageNum || 1,
|
||||
pageSize: params.pageSize || 10
|
||||
}
|
||||
}
|
||||
|
||||
export const unwrapTestDevicePayload = <T>(response: ResultData<T> | T): T => {
|
||||
if (response && typeof response === 'object' && 'data' in response) {
|
||||
return (response as ResultData<T>).data
|
||||
}
|
||||
|
||||
return response as T
|
||||
}
|
||||
|
||||
export const normalizeTestDevicePage = <T>(
|
||||
response: ResultData<ResPage<T>> | ResPage<T> | null | undefined
|
||||
): ResPage<T> => {
|
||||
const payload = unwrapTestDevicePayload<ResPage<T> | null | undefined>(response as ResultData<ResPage<T>>)
|
||||
|
||||
return {
|
||||
records: payload?.records || [],
|
||||
current: payload?.current || 1,
|
||||
size: payload?.size || 10,
|
||||
total: payload?.total || 0
|
||||
}
|
||||
}
|
||||
|
||||
export const getTestDeviceErrorMessage = (error: unknown, fallback: string) => {
|
||||
if (error instanceof Error && error.message) return error.message
|
||||
if (error && typeof error === 'object' && 'message' in error) {
|
||||
return String((error as { message?: unknown }).message || fallback)
|
||||
}
|
||||
|
||||
return fallback
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
title="提交审核"
|
||||
width="560px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
@closed="resetForm"
|
||||
>
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="96px">
|
||||
<el-form-item label="审核意见" prop="checkResult">
|
||||
<el-input
|
||||
v-model="formModel.checkResult"
|
||||
type="textarea"
|
||||
:rows="4"
|
||||
maxlength="128"
|
||||
show-word-limit
|
||||
placeholder="请输入审核意见,可为空"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submitForm">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { type FormInstance, type FormRules } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskAuditDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
saving: boolean
|
||||
record: ReportTask.ReportTaskRecord | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: ReportTask.ReportTaskAuditRequest): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const formModel = reactive({
|
||||
id: '',
|
||||
checkResult: ''
|
||||
})
|
||||
|
||||
const formRules: FormRules = {}
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value?.clearValidate()
|
||||
formModel.id = ''
|
||||
formModel.checkResult = ''
|
||||
}
|
||||
|
||||
const fillForm = () => {
|
||||
formModel.id = props.record?.id || ''
|
||||
formModel.checkResult = props.record?.checkResult || ''
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.record?.id],
|
||||
([visible]) => {
|
||||
if (visible) fillForm()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const submitForm = async () => {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
|
||||
if (!valid) return
|
||||
|
||||
emit('submit', {
|
||||
id: formModel.id,
|
||||
checkResult: formModel.checkResult.trim() || undefined
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,221 @@
|
||||
<template>
|
||||
<div class="form-panel">
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告编号" prop="no">
|
||||
<el-input v-model="localFormModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="委托单位" prop="clientUnitId">
|
||||
<el-select v-model="localFormModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
||||
<el-option v-for="option in clientUnitSelectOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告模板" prop="reportModelId">
|
||||
<el-select v-model="localFormModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
||||
<el-option v-for="option in reportModelSelectOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="检测公司" prop="createUnit">
|
||||
<el-select v-model="localFormModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
||||
<el-option v-for="option in companySelectOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="合同编号" prop="contractNumber">
|
||||
<el-input v-model="localFormModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="测试依据" prop="standardIds">
|
||||
<el-select v-model="localFormModel.standardIds" multiple filterable clearable collapse-tags placeholder="请选择测试依据">
|
||||
<el-option v-for="option in standardSelectOptions" :key="option.value" :label="option.label" :value="option.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="联系电话" prop="phonenumber">
|
||||
<el-input v-model="localFormModel.phonenumber" maxlength="32" clearable placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<div class="summary-strip">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">导入状态</span>
|
||||
<el-tag :type="canSubmit ? 'success' : 'warning'">
|
||||
{{ canSubmit ? '已准备提交' : '待完成正式导入' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">监测点数</span>
|
||||
<span class="summary-value">{{ importSummary.pointCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">分组数</span>
|
||||
<span class="summary-value">{{ importSummary.groupCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">汇总文件</span>
|
||||
<span class="summary-value">{{ importSummary.summaryFileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { checkReportTaskLedgerPrepared } from '../utils/testReport'
|
||||
import type { ReportTaskFormModel } from '../utils/testReportForm'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskBaseInfoStep'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
formModel: ReportTaskFormModel
|
||||
record: ReportTask.ReportTaskRecord | null
|
||||
clientUnitOptions: Array<{ label: string; value: string }>
|
||||
reportModelOptions: Array<{ label: string; value: string }>
|
||||
companyOptions: Array<{ label: string; value: string }>
|
||||
standardOptions: Array<{ label: string; value: string }>
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'register-form', value: FormInstance | undefined): void
|
||||
(event: 'update:form-model', value: ReportTaskFormModel): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const localFormModel = reactive<ReportTaskFormModel>({ ...props.formModel })
|
||||
|
||||
const formRules: FormRules = {
|
||||
no: [{ required: true, message: '请输入报告编号', trigger: 'blur' }],
|
||||
clientUnitId: [{ required: true, message: '请选择委托单位', trigger: 'change' }],
|
||||
reportModelId: [{ required: true, message: '请选择报告模板', trigger: 'change' }],
|
||||
createUnit: [{ required: true, message: '请选择检测公司', trigger: 'change' }],
|
||||
contractNumber: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
||||
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const ensureCurrentOption = (
|
||||
options: Array<{ label: string; value: string }>,
|
||||
value: string,
|
||||
fallbackLabel: string
|
||||
) => {
|
||||
if (!value || options.some(option => option.value === value)) return options
|
||||
return [...options, { label: fallbackLabel || value, value }]
|
||||
}
|
||||
|
||||
const clientUnitSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.clientUnitOptions, localFormModel.clientUnitId, props.record?.clientUnitName || '')
|
||||
)
|
||||
const reportModelSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.reportModelOptions, localFormModel.reportModelId, props.record?.reportModelName || '')
|
||||
)
|
||||
const companySelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.companyOptions, localFormModel.createUnit, props.record?.createUnit || '')
|
||||
)
|
||||
const standardSelectOptions = computed(() => {
|
||||
const optionMap = new Map(props.standardOptions.map(option => [option.value, option]))
|
||||
const extraOptions = localFormModel.standardIds.filter(item => !optionMap.has(item)).map(item => ({ label: item, value: item }))
|
||||
return [...props.standardOptions, ...extraOptions]
|
||||
})
|
||||
|
||||
const canSubmit = computed(() => checkReportTaskLedgerPrepared(props.preparedState))
|
||||
const importSummary = computed(() => {
|
||||
const importResult = props.preparedState.latestImportResult
|
||||
const snapshot = props.preparedState.snapshot
|
||||
|
||||
return {
|
||||
pointCount: String(importResult?.pointCount ?? snapshot?.rowCount ?? '-'),
|
||||
groupCount: String(importResult?.groupCount ?? snapshot?.groupSummary?.length ?? '-'),
|
||||
summaryFileName: importResult?.summaryFileName || snapshot?.summaryFileName || '-'
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
formRef,
|
||||
value => {
|
||||
emit('register-form', value)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.formModel,
|
||||
value => {
|
||||
Object.assign(localFormModel, value)
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
localFormModel,
|
||||
value => {
|
||||
emit('update:form-model', { ...value, standardIds: [...value.standardIds] })
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.form-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.summary-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
:deep(.report-task-form .el-form-item) {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.summary-strip {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<div class="complete-panel">
|
||||
<el-result
|
||||
icon="success"
|
||||
:title="mode === 'create' ? '报告任务新增完成' : '报告任务编辑完成'"
|
||||
sub-title="文件导入与基础信息保存均已完成,本次结果已同步刷新到列表。"
|
||||
/>
|
||||
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="报告编号">{{ formModel.no || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位">{{ resolveCurrentOptionLabel(clientUnitOptions, formModel.clientUnitId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="检测公司">{{ resolveCurrentOptionLabel(companyOptions, formModel.createUnit) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">{{ importSummary.pointCount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分组数">{{ importSummary.groupCount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">{{ importSummary.summaryFileName }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import type { ReportTaskFormModel } from '../utils/testReportForm'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskCompleteStep'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
mode: 'create' | 'edit'
|
||||
formModel: ReportTaskFormModel
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
clientUnitOptions: Array<{ label: string; value: string }>
|
||||
companyOptions: Array<{ label: string; value: string }>
|
||||
}>()
|
||||
|
||||
const resolveCurrentOptionLabel = (options: Array<{ label: string; value: string }>, value: string) =>
|
||||
options.find(option => option.value === value)?.label || value || '-'
|
||||
|
||||
const importSummary = {
|
||||
pointCount: String(props.preparedState.latestImportResult?.pointCount ?? props.preparedState.snapshot?.rowCount ?? '-'),
|
||||
groupCount: String(props.preparedState.latestImportResult?.groupCount ?? props.preparedState.snapshot?.groupSummary?.length ?? '-'),
|
||||
summaryFileName: props.preparedState.latestImportResult?.summaryFileName || props.preparedState.snapshot?.summaryFileName || '-'
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.complete-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,118 @@
|
||||
<template>
|
||||
<el-dialog v-model="visibleProxy" title="报告任务详情" width="880px" append-to-body destroy-on-close>
|
||||
<div v-loading="loading" class="report-task-detail-dialog">
|
||||
<el-descriptions class="detail-descriptions" :column="2" border>
|
||||
<el-descriptions-item label="报告编号">{{ resolveReportTaskText(detail?.no) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位">{{ resolveReportTaskText(detail?.clientUnitName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="报告模板">{{ resolveReportTaskText(detail?.reportModelName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="检测公司">
|
||||
{{ resolveReportTaskCreateUnitText(detail?.createUnit, companyLabelMap) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="合同编号">{{ resolveReportTaskText(detail?.contractNumber) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="联系电话">{{ resolveReportTaskText(detail?.phonenumber) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="测试依据" :span="2">
|
||||
{{ resolveReportTaskStandardText(detail?.standard, standardLabelMap) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="送资数据" :span="2">{{ resolveReportTaskText(detail?.data) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数量">{{ resolveReportTaskText(detail?.pointCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分组数量">{{ resolveReportTaskText(detail?.groupCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核人">{{ resolveReportTaskText(detail?.checkerName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核时间">{{ resolveReportTaskText(detail?.checkTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="审核意见" :span="2">{{ resolveReportTaskText(detail?.checkResult) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="创建人">
|
||||
{{ resolveReportTaskText(detail?.createByName || detail?.createBy) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">{{ resolveReportTaskText(detail?.createTime) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="更新人">
|
||||
{{ resolveReportTaskText(detail?.updateByName || detail?.updateBy) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="更新时间">{{ resolveReportTaskText(detail?.updateTime) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div class="group-report-section">
|
||||
<div class="group-report-title">分组报告生成状态</div>
|
||||
<el-empty v-if="!groupReports.length" description="暂无分组报告记录" :image-size="88" />
|
||||
<el-table v-else :data="groupReports" border size="small">
|
||||
<el-table-column prop="groupNo" label="分组号" width="100" />
|
||||
<el-table-column prop="reportName" label="报告名称" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="生成状态" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="resolveReportTaskGroupReportGenerateStateTagType(row.generateState)">
|
||||
{{ resolveReportTaskGroupReportGenerateStateText(row.generateState) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="generateMessage" label="生成消息" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="generateTime" label="生成时间" min-width="160" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="visibleProxy = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import {
|
||||
resolveReportTaskCreateUnitText,
|
||||
resolveReportTaskGroupReportGenerateStateTagType,
|
||||
resolveReportTaskGroupReportGenerateStateText,
|
||||
resolveReportTaskStandardText,
|
||||
resolveReportTaskText
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskDetailDialog'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
loading: boolean
|
||||
detail: ReportTask.ReportTaskRecord | null
|
||||
groupReports: ReportTask.ReportTaskGroupReportRecord[]
|
||||
companyLabelMap: Record<string, string>
|
||||
standardLabelMap: Record<string, string>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
}>()
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const companyLabelMap = computed(() => props.companyLabelMap)
|
||||
const standardLabelMap = computed(() => props.standardLabelMap)
|
||||
const groupReports = computed(() => props.groupReports || [])
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-task-detail-dialog {
|
||||
min-height: 180px;
|
||||
}
|
||||
|
||||
.report-task-detail-dialog :deep(.detail-descriptions .el-descriptions__table) {
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.report-task-detail-dialog :deep(.detail-descriptions .el-descriptions__label.el-descriptions__cell.is-bordered-label) {
|
||||
width: 112px;
|
||||
}
|
||||
|
||||
.group-report-section {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.group-report-title {
|
||||
margin-bottom: 12px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,896 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="visibleProxy"
|
||||
:title="mode === 'create' ? '新增报告任务' : '编辑报告任务'"
|
||||
width="1080px"
|
||||
append-to-body
|
||||
destroy-on-close
|
||||
class="report-task-flow-dialog"
|
||||
@closed="resetForm"
|
||||
>
|
||||
<div class="report-task-form-dialog">
|
||||
<div class="flow-nav">
|
||||
<button
|
||||
v-for="step in REPORT_TASK_FORM_STEPS"
|
||||
:key="step.value"
|
||||
type="button"
|
||||
class="flow-step"
|
||||
:class="[`is-${resolveStepStatus(step.value)}`, { 'is-clickable': canSwitchStep(step.value) }]"
|
||||
:disabled="!canSwitchStep(step.value)"
|
||||
@click="handleStepClick(step.value)"
|
||||
>
|
||||
<span class="flow-step-index">{{ step.index }}</span>
|
||||
<span class="flow-step-content">
|
||||
<span class="flow-step-title">{{ step.title }}</span>
|
||||
<span class="flow-step-desc">{{ step.description }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flow-main">
|
||||
<div v-if="currentStep === 'import'" class="flow-panel">
|
||||
<ReportTaskLedgerImportPanel
|
||||
:draft-id="activeDraftId"
|
||||
:disabled="saving"
|
||||
:prepared-state="ledgerPreparedState"
|
||||
:snapshot="ledgerSnapshot"
|
||||
@change="handleLedgerPreparedChange"
|
||||
@log="handleLog"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="currentStep === 'form'" class="flow-panel">
|
||||
<div class="form-panel">
|
||||
<el-form ref="formRef" :model="formModel" :rules="formRules" label-width="108px" class="report-task-form">
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告编号" prop="no">
|
||||
<el-input v-model="formModel.no" maxlength="32" clearable placeholder="请输入报告编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="委托单位" prop="clientUnitId">
|
||||
<el-select v-model="formModel.clientUnitId" filterable clearable placeholder="请选择委托单位">
|
||||
<el-option
|
||||
v-for="option in clientUnitSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="报告模板" prop="reportModelId">
|
||||
<el-select v-model="formModel.reportModelId" filterable clearable placeholder="请选择报告模板">
|
||||
<el-option
|
||||
v-for="option in reportModelSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="检测公司" prop="createUnit">
|
||||
<el-select v-model="formModel.createUnit" filterable clearable placeholder="请选择检测公司">
|
||||
<el-option
|
||||
v-for="option in companySelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="合同编号" prop="contractNumber">
|
||||
<el-input v-model="formModel.contractNumber" maxlength="32" clearable placeholder="请输入合同编号" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="测试依据" prop="standardIds">
|
||||
<el-select
|
||||
v-model="formModel.standardIds"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
collapse-tags
|
||||
placeholder="请选择测试依据"
|
||||
>
|
||||
<el-option
|
||||
v-for="option in standardSelectOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12">
|
||||
<el-form-item label="联系电话" prop="phonenumber">
|
||||
<el-input v-model="formModel.phonenumber" maxlength="32" clearable placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
|
||||
<div class="summary-strip">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">导入状态</span>
|
||||
<el-tag :type="canSubmit ? 'success' : 'warning'">
|
||||
{{ canSubmit ? '已准备提交' : '待完成台账校验' }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">监测点数</span>
|
||||
<span class="summary-value">{{ importSummary.pointCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">分组数</span>
|
||||
<span class="summary-value">{{ importSummary.groupCount }}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">汇总文件</span>
|
||||
<span class="summary-value">{{ importSummary.summaryFileName }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="flow-panel">
|
||||
<div class="complete-panel">
|
||||
<el-result
|
||||
icon="success"
|
||||
:title="mode === 'create' ? '报告任务新增完成' : '报告任务编辑完成'"
|
||||
sub-title="台账校验与基础信息保存均已完成,本次结果已同步刷新到列表。"
|
||||
/>
|
||||
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="报告编号">{{ formModel.no || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位">
|
||||
{{ resolveCurrentOptionLabel(clientUnitSelectOptions, formModel.clientUnitId) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="检测公司">
|
||||
{{ resolveCurrentOptionLabel(companySelectOptions, formModel.createUnit) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">{{ importSummary.pointCount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分组数">{{ importSummary.groupCount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">{{ importSummary.summaryFileName }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="log-panel" :class="{ 'is-collapsed': !logPanelExpanded }">
|
||||
<button type="button" class="log-panel-header" @click="logPanelExpanded = !logPanelExpanded">
|
||||
<span class="log-panel-toggle" :class="{ 'is-collapsed': !logPanelExpanded }" aria-hidden="true"></span>
|
||||
<div class="log-title">日志信息</div>
|
||||
</button>
|
||||
|
||||
<div v-show="logPanelExpanded" class="log-panel-body">
|
||||
<div class="log-popover-body">
|
||||
<div v-if="logEntries.length" class="log-list">
|
||||
<div v-for="entry in logEntries" :key="entry.id" class="log-item">
|
||||
<div class="log-meta">
|
||||
<el-tag size="small" :type="resolveLogTagType(entry.type)">{{ resolveLogTypeText(entry.type) }}</el-tag>
|
||||
<span class="log-time">{{ entry.time }}</span>
|
||||
</div>
|
||||
<div class="log-message">{{ entry.message }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="当前暂无日志输出" :image-size="60" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button :disabled="saving" @click="visibleProxy = false">{{ currentStep === 'done' ? '关闭' : '取消' }}</el-button>
|
||||
|
||||
<template v-if="currentStep === 'import'">
|
||||
<el-button type="primary" :disabled="!canSubmit" @click="goToFormStep">下一步</el-button>
|
||||
</template>
|
||||
|
||||
<template v-else-if="currentStep === 'form'">
|
||||
<el-button type="primary" plain :disabled="saving" @click="goToImportStep">返回导入</el-button>
|
||||
<el-button type="primary" :loading="saving" :disabled="!canSubmit" @click="submitForm">提交</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { generateUUID } from '@/utils'
|
||||
import ReportTaskLedgerImportPanel from './ReportTaskLedgerImportPanel.vue'
|
||||
import {
|
||||
checkReportTaskLedgerPrepared,
|
||||
getReportTaskErrorMessage,
|
||||
normalizeReportTaskLedgerSnapshot,
|
||||
parseReportTaskStandardIds,
|
||||
stringifyReportTaskStandardIds
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskFormDialog'
|
||||
})
|
||||
|
||||
type ReportTaskFormStep = 'import' | 'form' | 'done'
|
||||
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||
|
||||
const REPORT_TASK_FORM_STEPS: Array<{
|
||||
index: number
|
||||
value: ReportTaskFormStep
|
||||
title: string
|
||||
description: string
|
||||
}> = [
|
||||
{
|
||||
index: 1,
|
||||
value: 'import',
|
||||
title: '数据导入',
|
||||
description: '先完成台账与附件校验'
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
value: 'form',
|
||||
title: '基础信息填写',
|
||||
description: '填写并确认任务基础信息'
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
value: 'done',
|
||||
title: '完成',
|
||||
description: '查看结果并结束本次流程'
|
||||
}
|
||||
]
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
mode: 'create' | 'edit'
|
||||
record: ReportTask.ReportTaskRecord | null
|
||||
saving: boolean
|
||||
saveSuccessVersion: number
|
||||
clientUnitOptions: Array<{ label: string; value: string }>
|
||||
reportModelOptions: Array<{ label: string; value: string }>
|
||||
companyOptions: Array<{ label: string; value: string }>
|
||||
standardOptions: Array<{ label: string; value: string }>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'submit', value: ReportTask.ReportTaskSaveRequest): void
|
||||
}>()
|
||||
|
||||
const formRef = ref<FormInstance>()
|
||||
const activeDraftId = ref('')
|
||||
const currentStep = ref<ReportTaskFormStep>('import')
|
||||
const logPanelExpanded = ref(true)
|
||||
const logEntries = ref<Array<{ id: string; type: ReportTaskLogType; time: string; message: string }>>([])
|
||||
const ledgerPreparedState = ref<ReportTask.ReportTaskLedgerPreparedState>({
|
||||
draftId: '',
|
||||
batchId: '',
|
||||
latestImportResult: null,
|
||||
snapshot: null,
|
||||
hasImported: false,
|
||||
pendingReimport: false
|
||||
})
|
||||
const lastHandledSaveSuccessVersion = ref(0)
|
||||
|
||||
const formModel = reactive({
|
||||
id: '',
|
||||
no: '',
|
||||
clientUnitId: '',
|
||||
reportModelId: '',
|
||||
createUnit: '',
|
||||
contractNumber: '',
|
||||
standardIds: [] as string[],
|
||||
data: '',
|
||||
phonenumber: ''
|
||||
})
|
||||
|
||||
const formRules: FormRules = {
|
||||
no: [{ required: true, message: '请输入报告编号', trigger: 'blur' }],
|
||||
clientUnitId: [{ required: true, message: '请选择委托单位', trigger: 'change' }],
|
||||
reportModelId: [{ required: true, message: '请选择报告模板', trigger: 'change' }],
|
||||
createUnit: [{ required: true, message: '请选择检测公司', trigger: 'change' }],
|
||||
contractNumber: [{ required: true, message: '请输入合同编号', trigger: 'blur' }],
|
||||
standardIds: [{ required: true, message: '请选择测试依据', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const visibleProxy = computed({
|
||||
get: () => props.visible,
|
||||
set: value => emit('update:visible', value)
|
||||
})
|
||||
|
||||
const ledgerSnapshot = computed(() => ledgerPreparedState.value.snapshot)
|
||||
const canSubmit = computed(() => !props.saving && checkReportTaskLedgerPrepared(ledgerPreparedState.value))
|
||||
const importSummary = computed(() => {
|
||||
const importResult = ledgerPreparedState.value.latestImportResult
|
||||
const snapshot = ledgerPreparedState.value.snapshot
|
||||
|
||||
return {
|
||||
pointCount: String(importResult?.pointCount ?? snapshot?.rowCount ?? '-'),
|
||||
groupCount: String(importResult?.groupCount ?? snapshot?.groupSummary?.length ?? '-'),
|
||||
summaryFileName: importResult?.summaryFileName || snapshot?.summaryFileName || '-'
|
||||
}
|
||||
})
|
||||
|
||||
const ensureCurrentOption = (
|
||||
options: Array<{ label: string; value: string }>,
|
||||
value: string,
|
||||
fallbackLabel: string
|
||||
) => {
|
||||
if (!value || options.some(option => option.value === value)) return options
|
||||
|
||||
return [...options, { label: fallbackLabel || value, value }]
|
||||
}
|
||||
|
||||
const clientUnitSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.clientUnitOptions, formModel.clientUnitId, props.record?.clientUnitName || '')
|
||||
)
|
||||
const reportModelSelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.reportModelOptions, formModel.reportModelId, props.record?.reportModelName || '')
|
||||
)
|
||||
const companySelectOptions = computed(() =>
|
||||
ensureCurrentOption(props.companyOptions, formModel.createUnit, props.record?.createUnit || '')
|
||||
)
|
||||
const standardSelectOptions = computed(() => {
|
||||
const optionMap = new Map(props.standardOptions.map(option => [option.value, option]))
|
||||
const extraOptions = formModel.standardIds
|
||||
.filter(item => !optionMap.has(item))
|
||||
.map(item => ({ label: item, value: item }))
|
||||
|
||||
return [...props.standardOptions, ...extraOptions]
|
||||
})
|
||||
|
||||
const buildLogId = () => window.crypto?.randomUUID?.() || generateUUID()
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => {
|
||||
logEntries.value.push({
|
||||
id: buildLogId(),
|
||||
type,
|
||||
time: new Date().toLocaleTimeString('zh-CN', { hour12: false }),
|
||||
message
|
||||
})
|
||||
}
|
||||
|
||||
const handleLog = (payload: { type: ReportTaskLogType; message: string }) => {
|
||||
pushLog(payload.type, payload.message)
|
||||
}
|
||||
|
||||
const resolveCurrentOptionLabel = (options: Array<{ label: string; value: string }>, value: string) =>
|
||||
options.find(option => option.value === value)?.label || value || '-'
|
||||
|
||||
const resolveLogTagType = (type: ReportTaskLogType) => {
|
||||
if (type === 'success') return 'success'
|
||||
if (type === 'warning') return 'warning'
|
||||
if (type === 'error') return 'danger'
|
||||
return 'info'
|
||||
}
|
||||
|
||||
const resolveLogTypeText = (type: ReportTaskLogType) => {
|
||||
if (type === 'success') return '成功'
|
||||
if (type === 'warning') return '警告'
|
||||
if (type === 'error') return '错误'
|
||||
return '信息'
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
formRef.value?.clearValidate()
|
||||
formModel.id = ''
|
||||
formModel.no = ''
|
||||
formModel.clientUnitId = ''
|
||||
formModel.reportModelId = ''
|
||||
formModel.createUnit = ''
|
||||
formModel.contractNumber = ''
|
||||
formModel.standardIds = []
|
||||
formModel.data = ''
|
||||
formModel.phonenumber = ''
|
||||
activeDraftId.value = ''
|
||||
currentStep.value = 'import'
|
||||
logPanelExpanded.value = true
|
||||
logEntries.value = []
|
||||
ledgerPreparedState.value = {
|
||||
draftId: '',
|
||||
batchId: '',
|
||||
latestImportResult: null,
|
||||
snapshot: null,
|
||||
hasImported: false,
|
||||
pendingReimport: false
|
||||
}
|
||||
}
|
||||
|
||||
const buildDraftId = () => {
|
||||
if (props.mode === 'edit') {
|
||||
return String(props.record?.id || '').trim()
|
||||
}
|
||||
|
||||
return window.crypto?.randomUUID?.() || generateUUID()
|
||||
}
|
||||
|
||||
const applyInitialStep = (hasPreparedLedger: boolean) => {
|
||||
if (props.mode === 'edit' && hasPreparedLedger) {
|
||||
currentStep.value = 'form'
|
||||
pushLog('info', '编辑场景检测到已有导入结果,默认进入基础信息填写步骤')
|
||||
return
|
||||
}
|
||||
|
||||
currentStep.value = 'import'
|
||||
pushLog('info', '已进入数据导入步骤,请先完成台账校验')
|
||||
}
|
||||
|
||||
const fillForm = async () => {
|
||||
try {
|
||||
const record = props.record
|
||||
const snapshot = normalizeReportTaskLedgerSnapshot(record?.data)
|
||||
|
||||
formModel.id = record?.id || ''
|
||||
formModel.no = record?.no || ''
|
||||
formModel.clientUnitId = record?.clientUnitId || ''
|
||||
formModel.reportModelId = record?.reportModelId || ''
|
||||
formModel.createUnit = record?.createUnit || ''
|
||||
formModel.contractNumber = record?.contractNumber || ''
|
||||
formModel.standardIds = parseReportTaskStandardIds(record?.standard)
|
||||
formModel.data = record?.data || ''
|
||||
formModel.phonenumber = record?.phonenumber || ''
|
||||
|
||||
activeDraftId.value = buildDraftId()
|
||||
ledgerPreparedState.value = {
|
||||
draftId: activeDraftId.value,
|
||||
batchId: '',
|
||||
latestImportResult: null,
|
||||
snapshot,
|
||||
hasImported: Boolean(snapshot || Number(record?.pointCount) > 0),
|
||||
pendingReimport: false
|
||||
}
|
||||
|
||||
applyInitialStep(Boolean(snapshot || Number(record?.pointCount) > 0))
|
||||
if (snapshot) {
|
||||
pushLog('info', `已加载最近一次导入快照:${snapshot.summaryFileName || '未命名汇总文件'}`)
|
||||
}
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '报告任务台账快照加载失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
}
|
||||
}
|
||||
|
||||
const goToFormStep = () => {
|
||||
if (!canSubmit.value) {
|
||||
pushLog('warning', '当前校验尚未完成,不能进入基础信息填写步骤')
|
||||
return
|
||||
}
|
||||
|
||||
currentStep.value = 'form'
|
||||
pushLog('info', '已切换到基础信息填写步骤')
|
||||
}
|
||||
|
||||
const goToImportStep = () => {
|
||||
currentStep.value = 'import'
|
||||
pushLog('info', '已返回数据导入步骤,可继续沿用当前结果或重新校验台账')
|
||||
}
|
||||
|
||||
const handleLedgerPreparedChange = (value: ReportTask.ReportTaskLedgerPreparedState) => {
|
||||
const wasPrepared = checkReportTaskLedgerPrepared(ledgerPreparedState.value)
|
||||
const nextState = {
|
||||
...value,
|
||||
draftId: activeDraftId.value
|
||||
}
|
||||
|
||||
ledgerPreparedState.value = nextState
|
||||
|
||||
if (!wasPrepared && checkReportTaskLedgerPrepared(nextState) && currentStep.value === 'import') {
|
||||
currentStep.value = 'form'
|
||||
pushLog('success', '台账校验已完成,已自动进入基础信息填写步骤')
|
||||
}
|
||||
}
|
||||
|
||||
const canSwitchStep = (step: ReportTaskFormStep) => {
|
||||
if (step === 'import') return true
|
||||
if (step === 'form') return canSubmit.value || currentStep.value === 'form' || currentStep.value === 'done'
|
||||
return currentStep.value === 'done'
|
||||
}
|
||||
|
||||
const handleStepClick = (step: ReportTaskFormStep) => {
|
||||
if (!canSwitchStep(step)) return
|
||||
if (step === 'import') {
|
||||
goToImportStep()
|
||||
return
|
||||
}
|
||||
if (step === 'form') {
|
||||
goToFormStep()
|
||||
}
|
||||
}
|
||||
|
||||
const resolveStepStatus = (step: ReportTaskFormStep) => {
|
||||
if (currentStep.value === step) return 'active'
|
||||
if (step === 'import' && (currentStep.value === 'form' || currentStep.value === 'done')) return 'done'
|
||||
if (step === 'form' && currentStep.value === 'done') return 'done'
|
||||
return 'pending'
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.visible, props.mode, props.record?.id],
|
||||
async ([visible]) => {
|
||||
if (!visible) return
|
||||
resetForm()
|
||||
await fillForm()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.saveSuccessVersion,
|
||||
value => {
|
||||
if (!props.visible || !value || value === lastHandledSaveSuccessVersion.value) return
|
||||
|
||||
lastHandledSaveSuccessVersion.value = value
|
||||
currentStep.value = 'done'
|
||||
pushLog('success', props.mode === 'create' ? '报告任务新增成功,流程已完成' : '报告任务编辑成功,流程已完成')
|
||||
}
|
||||
)
|
||||
|
||||
const submitForm = async () => {
|
||||
const valid = await formRef.value?.validate().catch(() => false)
|
||||
if (!valid) {
|
||||
pushLog('warning', '基础信息校验未通过,请检查必填项')
|
||||
return
|
||||
}
|
||||
|
||||
if (!checkReportTaskLedgerPrepared(ledgerPreparedState.value)) {
|
||||
const message = '请先完成台账校验后再提交基础信息'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
pushLog('info', props.mode === 'create' ? '开始提交新增任务基础信息并写入台账数据' : '开始提交编辑后的任务基础信息并更新台账数据')
|
||||
emit('submit', {
|
||||
id: activeDraftId.value || formModel.id || undefined,
|
||||
no: formModel.no.trim(),
|
||||
clientUnitId: formModel.clientUnitId,
|
||||
reportModelId: formModel.reportModelId,
|
||||
createUnit: formModel.createUnit,
|
||||
contractNumber: formModel.contractNumber.trim(),
|
||||
standard: stringifyReportTaskStandardIds(formModel.standardIds),
|
||||
data: formModel.data.trim(),
|
||||
batchId: ledgerPreparedState.value.batchId || undefined,
|
||||
phonenumber: formModel.phonenumber.trim() || undefined
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-task-form-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.flow-nav {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0;
|
||||
padding: 22px 18px 18px;
|
||||
border: 1px solid #d9ebe7;
|
||||
border-radius: 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.flow-step {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 12px 18px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
text-align: center;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.flow-step::before,
|
||||
.flow-step::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
width: calc(50% - 18px);
|
||||
height: 1px;
|
||||
background: #cfd5df;
|
||||
}
|
||||
|
||||
.flow-step::before {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.flow-step::after {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.flow-step:first-child::before,
|
||||
.flow-step:last-child::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.flow-step.is-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.flow-step:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.flow-step.is-active .flow-step-title,
|
||||
.flow-step.is-active .flow-step-desc {
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.flow-step.is-done .flow-step-index {
|
||||
border-color: var(--el-color-success);
|
||||
background: rgba(103, 194, 58, 0.1);
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.flow-step.is-done::after,
|
||||
.flow-step.is-done + .flow-step::before {
|
||||
background: rgba(103, 194, 58, 0.45);
|
||||
}
|
||||
|
||||
.flow-step-index {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border: 2px solid #b8bec9;
|
||||
border-radius: 50%;
|
||||
background: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
color: #a9b0bb;
|
||||
flex-shrink: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.flow-step.is-active .flow-step-index {
|
||||
border-color: #67c23a;
|
||||
background: rgba(103, 194, 58, 0.1);
|
||||
color: #67c23a;
|
||||
}
|
||||
|
||||
.flow-step-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.flow-step-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
color: #a9b0bb;
|
||||
}
|
||||
|
||||
.flow-step-desc {
|
||||
font-size: 12px;
|
||||
line-height: 1.25;
|
||||
color: #b9bfc9;
|
||||
}
|
||||
|
||||
.flow-main {
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
padding-bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.flow-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.form-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.summary-strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.complete-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.log-panel {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
background: var(--el-fill-color-blank);
|
||||
overflow: hidden;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.log-panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 0 16px;
|
||||
border: none;
|
||||
background: linear-gradient(180deg, #eef3ff 0%, #e6ecff 100%);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.log-panel-toggle {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-right: 10px;
|
||||
border-right: 2px solid #2f4fb7;
|
||||
border-bottom: 2px solid #2f4fb7;
|
||||
transform: rotate(45deg);
|
||||
transition: transform 0.2s ease;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.log-panel-toggle.is-collapsed {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.log-title {
|
||||
flex: 1;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: #2f4fb7;
|
||||
text-align: center;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.log-panel-body {
|
||||
border-top: 1px solid #d9e3ff;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.log-popover-body {
|
||||
max-height: 160px;
|
||||
overflow: auto;
|
||||
padding: 0;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.log-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
display: grid;
|
||||
grid-template-columns: 180px minmax(0, 1fr);
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
.log-item:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.log-meta,
|
||||
.log-message {
|
||||
padding: 10px 14px;
|
||||
}
|
||||
|
||||
.log-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
border-right: 1px solid var(--el-border-color-lighter);
|
||||
background: #f6f8ff;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.log-time {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.log-message {
|
||||
font-size: 13px;
|
||||
line-height: 1.3;
|
||||
color: var(--el-text-color-primary);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.log-empty {
|
||||
padding: 18px 0;
|
||||
}
|
||||
|
||||
:deep(.report-task-flow-dialog .el-dialog__body) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.flow-nav,
|
||||
.summary-strip {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.flow-nav {
|
||||
gap: 14px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.flow-step {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.flow-step::before,
|
||||
.flow-step::after {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.flow-step-content {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.log-panel-header {
|
||||
padding: 0 14px;
|
||||
}
|
||||
|
||||
.log-item {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.log-meta {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--el-border-color-lighter);
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<div class="report-task-step">
|
||||
<div class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">文件导入</div>
|
||||
<div class="section-desc">基于上一阶段校验通过的批次执行正式导入。</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="preparedState.pendingRevalidate"
|
||||
title="文件已变更,当前不能继续导入,请先返回上一步重新校验。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
/>
|
||||
|
||||
<el-descriptions :column="3" border>
|
||||
<el-descriptions-item label="sessionId">{{ resolveReportTaskText(preparedState.validateSessionId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="校验批次">{{ resolveReportTaskText(preparedState.validatedBatchId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">
|
||||
{{ resolveReportTaskText(preparedState.validateResult?.summaryFileName || snapshot?.summaryFileName) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="已上传文件数">
|
||||
{{ resolveReportTaskText(preparedState.validateResult?.uploadedFileCount) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">
|
||||
{{ resolveReportTaskText(preparedState.validateResult?.pointCount || snapshot?.rowCount) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="可继续补传">
|
||||
<el-tag :type="preparedState.validateResult?.canContinueUpload ? 'warning' : 'info'">
|
||||
{{ preparedState.validateResult?.canContinueUpload ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div class="action-bar">
|
||||
<el-button type="primary" :icon="UploadFilled" :loading="importing" :disabled="disabled || !canImport" @click="handleImport">
|
||||
执行导入
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="latestImportResult" class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">导入结果</div>
|
||||
<div class="section-desc">只有正式导入成功后才允许进入基础信息维护。</div>
|
||||
</div>
|
||||
|
||||
<el-descriptions :column="3" border>
|
||||
<el-descriptions-item label="当前阶段">{{ resolveReportTaskText(latestImportResult.currentStage) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="导入状态">
|
||||
<el-tag :type="latestImportResult.success ? 'success' : 'warning'">
|
||||
{{ latestImportResult.success ? '成功' : '未完成' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="导入批次">{{ resolveReportTaskText(latestImportResult.batchId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(latestImportResult.summaryFileName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="总文件数">{{ resolveReportTaskText(latestImportResult.totalFileCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="已上传文件数">{{ resolveReportTaskText(latestImportResult.uploadedFileCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">{{ resolveReportTaskText(latestImportResult.pointCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分组数">{{ resolveReportTaskText(latestImportResult.groupCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="临时目录">{{ resolveReportTaskText(latestImportResult.tempStoragePath) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="Excel 附件数">{{ resolveReportTaskText(latestImportResult.excelAttachmentCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="Word 附件数">{{ resolveReportTaskText(latestImportResult.wordAttachmentCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="设备新增 / 复用">
|
||||
{{ `${latestImportResult.deviceAddedCount || 0} / ${latestImportResult.deviceReuseCount || 0}` }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位新增 / 复用" :span="2">
|
||||
{{ `${latestImportResult.clientAddedCount || 0} / ${latestImportResult.clientReuseCount || 0}` }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-alert
|
||||
v-if="latestImportResult.failReasons?.length"
|
||||
:title="`存在 ${latestImportResult.failReasons.length} 条导入提示`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
>
|
||||
<template #default>
|
||||
<div v-for="reason in latestImportResult.failReasons" :key="reason" class="fail-reason">{{ reason }}</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-table v-if="orderedStages.length" :data="orderedStages" border size="small" max-height="240" class="stage-table">
|
||||
<el-table-column prop="stage" label="阶段" width="150" />
|
||||
<el-table-column label="结果" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.success ? 'success' : 'warning'">{{ row.success ? '成功' : '未通过' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="message" label="说明" min-width="280" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="snapshot" class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">已保存快照</div>
|
||||
<div class="section-desc">编辑场景可参考当前任务最近一次已保存的导入摘要。</div>
|
||||
</div>
|
||||
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(snapshot.summaryFileName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="导入模式">{{ resolveReportTaskText(snapshot.importMode) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点 Sheet">{{ resolveReportTaskText(snapshot.sheetSummary?.pointSheet) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点行数">{{ resolveReportTaskText(snapshot.rowCount) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { computed, ref } from 'vue'
|
||||
import { importReportTaskLedgerApi } from '@/api/aireport/testReport'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { hasValidatedLedgerBatch } from '../utils/reportTaskFlow'
|
||||
import {
|
||||
TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER,
|
||||
checkReportTaskLedgerPrepared,
|
||||
getReportTaskErrorMessage,
|
||||
normalizeReportTaskLedgerImportResult,
|
||||
resolveReportTaskText
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskImportStep'
|
||||
})
|
||||
|
||||
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||
|
||||
const props = defineProps<{
|
||||
disabled?: boolean
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
snapshot: ReportTask.ReportTaskLedgerImportSnapshot | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'change', value: ReportTask.ReportTaskLedgerPreparedState): void
|
||||
(event: 'log', payload: { type: ReportTaskLogType; message: string }): void
|
||||
}>()
|
||||
|
||||
const importing = ref(false)
|
||||
const latestImportResult = computed(() => props.preparedState.latestImportResult)
|
||||
const canImport = computed(() => hasValidatedLedgerBatch(props.preparedState))
|
||||
const orderedStages = computed(() => {
|
||||
const stageMap = new Map((latestImportResult.value?.stages || []).map(stage => [stage.stage, stage]))
|
||||
|
||||
return TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER.map(stage => {
|
||||
const currentStage = stageMap.get(stage)
|
||||
return {
|
||||
stage,
|
||||
success: currentStage?.success ?? false,
|
||||
message: currentStage?.message || ''
|
||||
}
|
||||
}).filter(stage =>
|
||||
stage.stage === '文件导入' || stage.stage === '基础资料维护' || stage.stage === '完成' ? stage.message || stage.success : false
|
||||
)
|
||||
})
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => emit('log', { type, message })
|
||||
|
||||
const updatePreparedState = (patch: Partial<ReportTask.ReportTaskLedgerPreparedState>) => {
|
||||
emit('change', {
|
||||
...props.preparedState,
|
||||
...patch
|
||||
})
|
||||
}
|
||||
|
||||
const handleImport = async () => {
|
||||
if (importing.value) return
|
||||
|
||||
if (!canImport.value) {
|
||||
const message = '请先完成文件校验并拿到导入批次后再执行正式导入'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
importing.value = true
|
||||
pushLog('info', `开始执行正式导入,校验批次:${props.preparedState.validatedBatchId}`)
|
||||
|
||||
try {
|
||||
// 关键业务节点:创建和编辑都统一使用 ledger/validate -> ledger/import,只有正式导入成功后才允许继续执行 add/update。
|
||||
const response = await importReportTaskLedgerApi(props.preparedState.draftId, {
|
||||
batchId: props.preparedState.validatedBatchId
|
||||
})
|
||||
const normalizedResult = normalizeReportTaskLedgerImportResult(response)
|
||||
|
||||
updatePreparedState({
|
||||
latestImportResult: normalizedResult,
|
||||
hasImported: Boolean(normalizedResult.success),
|
||||
pendingRevalidate: false
|
||||
})
|
||||
|
||||
if (
|
||||
!checkReportTaskLedgerPrepared({
|
||||
...props.preparedState,
|
||||
latestImportResult: normalizedResult,
|
||||
hasImported: Boolean(normalizedResult.success),
|
||||
pendingRevalidate: false
|
||||
})
|
||||
) {
|
||||
const message = '正式导入未完成,请根据导入结果修正后重新处理'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
normalizedResult.failReasons?.forEach(reason => pushLog('warning', reason))
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.success('正式导入成功')
|
||||
pushLog('success', '正式导入成功,可以进入基础信息维护步骤')
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '正式导入失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-task-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.panel-block {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.section-alert,
|
||||
.stage-table,
|
||||
.fail-reason + .fail-reason,
|
||||
.action-bar {
|
||||
margin-top: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,434 @@
|
||||
<template>
|
||||
<div class="ledger-import-panel">
|
||||
<div class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">数据导入</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="preparedState.pendingReimport"
|
||||
title="已重新选择文件,当前校验结果已失效,请重新执行台账校验。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
/>
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-actions">
|
||||
<el-upload
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
multiple
|
||||
accept=".xls,.xlsx,.doc,.docx"
|
||||
:disabled="disabled || importing"
|
||||
@change="handleFileChange"
|
||||
@remove="handleFileRemove"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="disabled || importing">选择文件</el-button>
|
||||
</template>
|
||||
</el-upload>
|
||||
|
||||
<el-button type="primary" :icon="UploadFilled" :loading="importing" :disabled="disabled" @click="handleImportFiles">
|
||||
执行校验
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-button class="toolbar-download" type="primary" plain :icon="Download" :disabled="disabled || importing" @click="handleDownloadTemplate">
|
||||
下载模板
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-table v-if="selectedFiles.length" :data="selectedFiles" border size="small" max-height="260" class="file-table">
|
||||
<el-table-column type="index" label="序号" width="68" />
|
||||
<el-table-column prop="name" label="文件名称" min-width="280" show-overflow-tooltip />
|
||||
<el-table-column label="文件大小" width="140">
|
||||
<template #default="{ row }">{{ formatFileSize(row.size) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="文件类型" width="120">
|
||||
<template #default="{ row }">{{ resolveFileTypeText(row.name) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="100" fixed="right">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" :disabled="disabled || importing" @click="removeSelectedFile($index)">
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-empty v-else description="尚未选择待导入文件" :image-size="88" />
|
||||
</div>
|
||||
|
||||
<div v-if="latestImportResult" class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">导入结果</div>
|
||||
<div class="section-desc">以后端返回的阶段结果和汇总统计为准。</div>
|
||||
</div>
|
||||
|
||||
<el-descriptions :column="3" border>
|
||||
<el-descriptions-item label="当前阶段">{{ resolveReportTaskText(latestImportResult.currentStage) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="导入状态">
|
||||
<el-tag :type="latestImportResult.success ? 'success' : 'warning'">
|
||||
{{ latestImportResult.success ? '成功' : '未完成' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(latestImportResult.summaryFileName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="总文件数">{{ resolveReportTaskText(latestImportResult.totalFileCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">{{ resolveReportTaskText(latestImportResult.pointCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分组数">{{ resolveReportTaskText(latestImportResult.groupCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="Excel 附件数">
|
||||
{{ resolveReportTaskText(latestImportResult.excelAttachmentCount) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="Word 附件数">
|
||||
{{ resolveReportTaskText(latestImportResult.wordAttachmentCount) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="设备新增 / 复用">
|
||||
{{ `${latestImportResult.deviceAddedCount || 0} / ${latestImportResult.deviceReuseCount || 0}` }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位新增 / 复用" :span="2">
|
||||
{{ `${latestImportResult.clientAddedCount || 0} / ${latestImportResult.clientReuseCount || 0}` }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-alert
|
||||
v-if="latestImportResult.failReasons?.length"
|
||||
:title="`存在 ${latestImportResult.failReasons.length} 条失败提示`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
>
|
||||
<template #default>
|
||||
<div v-for="reason in latestImportResult.failReasons" :key="reason" class="fail-reason">{{ reason }}</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-table
|
||||
v-if="orderedStages.length"
|
||||
:data="orderedStages"
|
||||
border
|
||||
size="small"
|
||||
max-height="240"
|
||||
class="stage-table"
|
||||
>
|
||||
<el-table-column prop="stage" label="阶段" width="150" />
|
||||
<el-table-column label="结果" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.success ? 'success' : 'warning'">{{ row.success ? '成功' : '未通过' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="message" label="说明" min-width="280" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<div v-if="snapshot" class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">已保存快照</div>
|
||||
<div class="section-desc">编辑场景下展示当前任务最近一次已保存的台账处理摘要。</div>
|
||||
</div>
|
||||
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(snapshot.summaryFileName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="导入模式">{{ resolveReportTaskText(snapshot.importMode) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点 Sheet">
|
||||
{{ resolveReportTaskText(snapshot.sheetSummary?.pointSheet) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点行数">{{ resolveReportTaskText(snapshot.rowCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="设备 Sheet">
|
||||
{{ snapshot.sheetSummary?.deviceSheetPresent ? '存在' : '不存在' }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="委托单位 Sheet">
|
||||
{{ snapshot.sheetSummary?.clientSheetPresent ? '存在' : '不存在' }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Download, FolderOpened, UploadFilled } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type UploadFile, type UploadFiles } from 'element-plus'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { downloadReportTaskLedgerTemplateApi, validateReportTaskLedgerApi } from '@/api/aireport/testReport'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||
import {
|
||||
TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER,
|
||||
checkReportTaskLedgerPrepared,
|
||||
getReportTaskErrorMessage,
|
||||
isReportTaskLedgerAttachmentFileName,
|
||||
normalizeReportTaskLedgerImportResult,
|
||||
resolveReportTaskText
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskLedgerImportPanel'
|
||||
})
|
||||
|
||||
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||
|
||||
const props = defineProps<{
|
||||
draftId: string
|
||||
disabled?: boolean
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
snapshot: ReportTask.ReportTaskLedgerImportSnapshot | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'change', value: ReportTask.ReportTaskLedgerPreparedState): void
|
||||
(event: 'log', payload: { type: ReportTaskLogType; message: string }): void
|
||||
}>()
|
||||
|
||||
const importing = ref(false)
|
||||
const selectedFiles = ref<UploadFile[]>([])
|
||||
const latestImportResult = ref<ReportTask.ReportTaskLedgerImportResult | null>(null)
|
||||
|
||||
const orderedStages = computed(() => {
|
||||
const stageMap = new Map((latestImportResult.value?.stages || []).map(stage => [stage.stage, stage]))
|
||||
|
||||
return TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER.map(stage => {
|
||||
const currentStage = stageMap.get(stage)
|
||||
return {
|
||||
stage,
|
||||
success: currentStage?.success ?? false,
|
||||
message: currentStage?.message || ''
|
||||
}
|
||||
}).filter(stage => stage.message || latestImportResult.value?.currentStage === stage.stage || stage.success)
|
||||
})
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => {
|
||||
emit('log', {
|
||||
type,
|
||||
message
|
||||
})
|
||||
}
|
||||
|
||||
const updatePreparedState = (patch: Partial<ReportTask.ReportTaskLedgerPreparedState>) => {
|
||||
emit('change', {
|
||||
...props.preparedState,
|
||||
...patch
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.preparedState,
|
||||
value => {
|
||||
latestImportResult.value = value.latestImportResult
|
||||
},
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
|
||||
const formatFileSize = (size?: number) => {
|
||||
if (!size) return '0 B'
|
||||
if (size < 1024) return `${size} B`
|
||||
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`
|
||||
return `${(size / (1024 * 1024)).toFixed(1)} MB`
|
||||
}
|
||||
|
||||
const resolveFileTypeText = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
if (normalizedName === '台账信息汇总.xlsx') return '汇总台账'
|
||||
if (normalizedName.endsWith('.doc') || normalizedName.endsWith('.docx')) return 'Word 附件'
|
||||
if (normalizedName.endsWith('.xls') || normalizedName.endsWith('.xlsx')) return 'Excel 附件'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
const handleFileChange = (_file: UploadFile, files: UploadFiles) => {
|
||||
selectedFiles.value = [...files]
|
||||
pushLog('info', `已选择 ${selectedFiles.value.length} 个待导入文件`)
|
||||
|
||||
if (props.preparedState.hasImported) {
|
||||
updatePreparedState({
|
||||
batchId: '',
|
||||
pendingReimport: true
|
||||
})
|
||||
pushLog('warning', '已更换导入文件,需重新执行台账校验后才能继续保存')
|
||||
}
|
||||
}
|
||||
|
||||
const handleFileRemove = (_file: UploadFile, files: UploadFiles) => {
|
||||
selectedFiles.value = [...files]
|
||||
pushLog('info', `已更新待导入文件列表,当前剩余 ${selectedFiles.value.length} 个文件`)
|
||||
|
||||
if (props.preparedState.hasImported) {
|
||||
updatePreparedState({
|
||||
batchId: '',
|
||||
pendingReimport: true
|
||||
})
|
||||
pushLog('warning', '导入文件已发生变化,之前的导入结果已标记为失效')
|
||||
}
|
||||
}
|
||||
|
||||
const removeSelectedFile = (index: number) => {
|
||||
selectedFiles.value.splice(index, 1)
|
||||
pushLog('info', `已删除第 ${index + 1} 个待导入文件`)
|
||||
|
||||
if (props.preparedState.hasImported) {
|
||||
updatePreparedState({
|
||||
batchId: '',
|
||||
pendingReimport: true
|
||||
})
|
||||
pushLog('warning', '导入文件已发生变化,之前的导入结果已标记为失效')
|
||||
}
|
||||
}
|
||||
|
||||
const handleDownloadTemplate = async () => {
|
||||
try {
|
||||
await useDownloadWithServerFileName(downloadReportTaskLedgerTemplateApi, '台账信息汇总', undefined, false, '.xlsx')
|
||||
pushLog('success', '台账导入模板下载成功')
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '台账模板下载失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleImportFiles = async () => {
|
||||
if (importing.value) return
|
||||
|
||||
if (!props.draftId) {
|
||||
const message = '报告任务 ID 缺失,无法执行台账校验'
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
return
|
||||
}
|
||||
|
||||
if (!selectedFiles.value.length) {
|
||||
const message = '请先选择待校验的台账汇总与附件文件'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
const invalidFile = selectedFiles.value.find(file => !isReportTaskLedgerAttachmentFileName(file.name))
|
||||
if (invalidFile) {
|
||||
const message = '仅支持导入 .xls、.xlsx、.doc、.docx 文件'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', `${message},异常文件:${invalidFile.name}`)
|
||||
return
|
||||
}
|
||||
|
||||
const formData = new FormData()
|
||||
selectedFiles.value.forEach(file => {
|
||||
if (file.raw) {
|
||||
formData.append('files', file.raw)
|
||||
}
|
||||
})
|
||||
|
||||
if (!formData.getAll('files').length) {
|
||||
const message = '未检测到可上传的文件内容'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
importing.value = true
|
||||
pushLog('info', `开始校验台账和附件文件,本次共上传 ${selectedFiles.value.length} 个文件`)
|
||||
|
||||
try {
|
||||
const response = await validateReportTaskLedgerApi(props.draftId, formData)
|
||||
const normalizedResult = normalizeReportTaskLedgerImportResult(response)
|
||||
|
||||
latestImportResult.value = normalizedResult
|
||||
updatePreparedState({
|
||||
batchId: normalizedResult.batchId || '',
|
||||
latestImportResult: normalizedResult,
|
||||
hasImported: Boolean(normalizedResult.success),
|
||||
pendingReimport: false
|
||||
})
|
||||
|
||||
if (
|
||||
!checkReportTaskLedgerPrepared({
|
||||
...props.preparedState,
|
||||
batchId: normalizedResult.batchId || '',
|
||||
latestImportResult: normalizedResult,
|
||||
hasImported: Boolean(normalizedResult.success),
|
||||
pendingReimport: false
|
||||
})
|
||||
) {
|
||||
const message = '台账校验未通过,请根据阶段结果修正后重新校验'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
normalizedResult.failReasons?.forEach(reason => pushLog('warning', reason))
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.success('台账校验通过')
|
||||
pushLog('success', '台账校验通过,可以继续填写基础信息')
|
||||
} catch (error) {
|
||||
updatePreparedState({
|
||||
batchId: '',
|
||||
hasImported: false
|
||||
})
|
||||
const message = getReportTaskErrorMessage(error, '台账校验失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.ledger-import-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.panel-block {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.panel-block:first-child {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.section-alert,
|
||||
.file-table,
|
||||
.stage-table,
|
||||
.fail-reason + .fail-reason {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.toolbar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.toolbar-download {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
:deep(.el-empty) {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,588 @@
|
||||
<template>
|
||||
<div class="report-task-step">
|
||||
<div class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">文件准备</div>
|
||||
<div class="section-desc">先选择台账汇总与附件,再执行校验并根据会话结果决定是否继续补传。</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="preparedState.pendingRevalidate"
|
||||
title="文件已变更,之前的校验与导入结果已失效,请重新执行校验。"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
/>
|
||||
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-actions">
|
||||
<el-upload
|
||||
:auto-upload="false"
|
||||
:show-file-list="false"
|
||||
multiple
|
||||
accept=".xls,.xlsx,.doc,.docx"
|
||||
:disabled="disabled || validating"
|
||||
@change="handleFileChange"
|
||||
@remove="handleFileRemove"
|
||||
>
|
||||
<template #trigger>
|
||||
<el-button type="primary" plain :icon="FolderOpened" :disabled="disabled || validating">选择文件</el-button>
|
||||
</template>
|
||||
</el-upload>
|
||||
|
||||
<el-button type="primary" :icon="Select" :loading="validating" :disabled="disabled" @click="handleValidateFiles">
|
||||
执行校验
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="selectedFiles.length" class="file-summary-grid">
|
||||
<div class="file-summary-card">
|
||||
<span class="file-summary-label">汇总台账</span>
|
||||
<span class="file-summary-value">{{ summaryLedgerFileName || '未选择' }}</span>
|
||||
</div>
|
||||
<div class="file-summary-card">
|
||||
<span class="file-summary-label">附件数量</span>
|
||||
<span class="file-summary-value">{{ otherAttachmentFiles.length }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-button class="toolbar-download" type="primary" plain :icon="Download" :disabled="disabled || validating" @click="handleDownloadTemplate">
|
||||
下载模板
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
title="该步骤只负责 ledger/validate;只有校验通过且返回导入批次后,才允许进入正式导入。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
class="section-alert"
|
||||
/>
|
||||
|
||||
<div v-if="selectedFiles.length" class="file-table-wrap">
|
||||
<el-table :data="selectedFiles" border size="small" height="100%" class="file-table">
|
||||
<el-table-column type="index" label="序号" width="68" />
|
||||
<el-table-column prop="name" label="文件名称" min-width="280" show-overflow-tooltip />
|
||||
<el-table-column label="文件大小" width="140">
|
||||
<template #default="{ row }">{{ formatFileSize(row.size) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="文件类型" width="120">
|
||||
<template #default="{ row }">{{ resolveFileTypeText(row.name) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="100" fixed="right">
|
||||
<template #default="{ $index }">
|
||||
<el-button link type="danger" :disabled="disabled || validating" @click="removeSelectedFile($index)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
<el-empty v-else description="尚未选择待校验文件" :image-size="88" />
|
||||
</div>
|
||||
|
||||
<div v-if="validateResult" class="panel-block">
|
||||
<div class="section-header">
|
||||
<div class="section-title">校验结果</div>
|
||||
<div class="section-desc">按会话、监测点、附件三层展示本次校验结果。</div>
|
||||
</div>
|
||||
|
||||
<el-descriptions :column="3" border>
|
||||
<el-descriptions-item label="sessionId">{{ resolveReportTaskText(validateResult.sessionId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="导入批次">{{ resolveReportTaskText(validateResult.batchId) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="校验状态">
|
||||
<el-tag :type="validateResult.success ? 'success' : 'warning'">
|
||||
{{ validateResult.success ? '通过' : '未通过' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="汇总文件">{{ resolveReportTaskText(validateResult.summaryFileName) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="已上传文件数">{{ resolveReportTaskText(validateResult.uploadedFileCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="监测点数">{{ resolveReportTaskText(validateResult.pointCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="缺失附件数">{{ resolveReportTaskText(validateResult.missingAttachmentCount) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="可继续补传">
|
||||
<el-tag :type="validateResult.canContinueUpload ? 'warning' : 'info'">
|
||||
{{ validateResult.canContinueUpload ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="临时目录">{{ resolveReportTaskText(validateResult.tempStoragePath) }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<div v-if="validateResult.failReasons?.length || validateResult.missingSheets?.length || validateResult.orphanAttachmentNames?.length" class="warning-grid">
|
||||
<el-alert
|
||||
v-if="validateResult.failReasons?.length"
|
||||
:title="`存在 ${validateResult.failReasons.length} 条校验提示`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #default>
|
||||
<div v-for="reason in validateResult.failReasons" :key="reason" class="fail-reason">{{ reason }}</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-alert
|
||||
v-if="validateResult.missingSheets?.length"
|
||||
:title="`缺少 ${validateResult.missingSheets.length} 个必需 sheet`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #default>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="sheet in validateResult.missingSheets" :key="sheet" type="danger" effect="plain">{{ sheet }}</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<el-alert
|
||||
v-if="validateResult.orphanAttachmentNames?.length"
|
||||
:title="`存在 ${validateResult.orphanAttachmentNames.length} 个孤儿附件`"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
show-icon
|
||||
>
|
||||
<template #default>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="fileName in validateResult.orphanAttachmentNames" :key="fileName" type="warning" effect="plain">
|
||||
{{ fileName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
</div>
|
||||
|
||||
<div class="sheet-summary-grid">
|
||||
<div class="sheet-summary-card">
|
||||
<span class="sheet-summary-label">requiredSheets</span>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="sheet in validateResult.requiredSheets" :key="sheet" effect="plain">{{ sheet }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sheet-summary-card">
|
||||
<span class="sheet-summary-label">existingSheets</span>
|
||||
<div class="tag-list">
|
||||
<el-tag v-for="sheet in validateResult.existingSheets" :key="sheet" type="success" effect="plain">{{ sheet }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-table v-if="validatePoints.length" :data="validatePoints" border size="small" max-height="320" class="stage-table">
|
||||
<el-table-column type="expand" width="48">
|
||||
<template #default="{ row }">
|
||||
<div class="attachment-panel">
|
||||
<div class="attachment-header">attachments</div>
|
||||
<el-table :data="row.attachments || []" border size="small">
|
||||
<el-table-column prop="attachmentName" label="附件名" min-width="220" show-overflow-tooltip />
|
||||
<el-table-column prop="attachmentType" label="类型" width="100" />
|
||||
<el-table-column label="上传" width="80">
|
||||
<template #default="{ row: attachment }">
|
||||
<el-tag :type="attachment.uploaded ? 'success' : 'info'">{{ attachment.uploaded ? '是' : '否' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="缺失" width="80">
|
||||
<template #default="{ row: attachment }">
|
||||
<el-tag :type="attachment.missing ? 'danger' : 'success'">{{ attachment.missing ? '是' : '否' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="允许补传" width="100">
|
||||
<template #default="{ row: attachment }">
|
||||
<el-tag :type="attachment.reuploadAllowed ? 'warning' : 'info'">
|
||||
{{ attachment.reuploadAllowed ? '是' : '否' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="message" label="说明" min-width="220" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="rowNo" label="行号" width="80" />
|
||||
<el-table-column prop="pointKey" label="点位标识" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="substationName" label="站点" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="pointName" label="点位" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column label="完整" width="90">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.complete ? 'success' : 'warning'">{{ row.complete ? '是' : '否' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="missingAttachmentCount" label="缺失附件" width="100" />
|
||||
<el-table-column label="设备匹配" width="110">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.testDeviceNoValid ? 'success' : 'danger'">{{ row.testDeviceNoValid ? '通过' : '未通过' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="testDeviceNoMessage" label="设备说明" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column label="委托单位匹配" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.clientUnitNameValid ? 'success' : 'danger'">{{ row.clientUnitNameValid ? '通过' : '未通过' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="clientUnitNameMessage" label="委托单位说明" min-width="180" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Download, FolderOpened, Select } from '@element-plus/icons-vue'
|
||||
import { ElMessage, type UploadFile, type UploadFiles } from 'element-plus'
|
||||
import { computed, ref } from 'vue'
|
||||
import { downloadReportTaskLedgerTemplateApi, validateReportTaskLedgerApi } from '@/api/aireport/testReport'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||
import {
|
||||
getReportTaskErrorMessage,
|
||||
isReportTaskLedgerAttachmentFileName,
|
||||
isReportTaskLedgerSummaryFileName,
|
||||
normalizeReportTaskLedgerValidateResult,
|
||||
resolveReportTaskText
|
||||
} from '../utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskPrepareStep'
|
||||
})
|
||||
|
||||
type ReportTaskLogType = 'info' | 'success' | 'warning' | 'error'
|
||||
|
||||
const props = defineProps<{
|
||||
draftId: string
|
||||
disabled?: boolean
|
||||
preparedState: ReportTask.ReportTaskLedgerPreparedState
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'change', value: ReportTask.ReportTaskLedgerPreparedState): void
|
||||
(event: 'log', payload: { type: ReportTaskLogType; message: string }): void
|
||||
}>()
|
||||
|
||||
const validating = ref(false)
|
||||
const selectedFiles = ref<UploadFile[]>([])
|
||||
const validateResult = computed(() => props.preparedState.validateResult)
|
||||
const validatePoints = computed(() => validateResult.value?.points || [])
|
||||
const summaryLedgerFileName = computed(() => {
|
||||
const summaryFile = selectedFiles.value.find(file => isReportTaskLedgerSummaryFileName(file.name))
|
||||
return summaryFile?.name || ''
|
||||
})
|
||||
const otherAttachmentFiles = computed(() => selectedFiles.value.filter(file => !isReportTaskLedgerSummaryFileName(file.name)))
|
||||
|
||||
const pushLog = (type: ReportTaskLogType, message: string) => emit('log', { type, message })
|
||||
|
||||
const updatePreparedState = (patch: Partial<ReportTask.ReportTaskLedgerPreparedState>) => {
|
||||
emit('change', {
|
||||
...props.preparedState,
|
||||
...patch
|
||||
})
|
||||
}
|
||||
|
||||
const markResultsDirty = () => {
|
||||
updatePreparedState({
|
||||
validateSessionId: '',
|
||||
validateResult: null,
|
||||
latestImportResult: null,
|
||||
hasImported: false,
|
||||
validatedBatchId: '',
|
||||
pendingRevalidate: true
|
||||
})
|
||||
}
|
||||
|
||||
const formatFileSize = (size?: number) => {
|
||||
if (!size) return '0 B'
|
||||
if (size < 1024) return `${size} B`
|
||||
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)} KB`
|
||||
return `${(size / (1024 * 1024)).toFixed(1)} MB`
|
||||
}
|
||||
|
||||
const resolveFileTypeText = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
if (isReportTaskLedgerSummaryFileName(normalizedName)) return '汇总台账'
|
||||
if (normalizedName.endsWith('.doc') || normalizedName.endsWith('.docx')) return 'Word 附件'
|
||||
if (normalizedName.endsWith('.xls') || normalizedName.endsWith('.xlsx')) return 'Excel 附件'
|
||||
return '未知'
|
||||
}
|
||||
|
||||
const handleFileChange = (_file: UploadFile, files: UploadFiles) => {
|
||||
selectedFiles.value = [...files]
|
||||
pushLog('info', `已选择 ${selectedFiles.value.length} 个待校验文件`)
|
||||
|
||||
if (props.preparedState.validateResult || props.preparedState.latestImportResult || props.preparedState.hasImported) {
|
||||
markResultsDirty()
|
||||
pushLog('warning', '导入文件已变更,需要重新执行文件校验和正式导入')
|
||||
}
|
||||
}
|
||||
|
||||
const handleFileRemove = (_file: UploadFile, files: UploadFiles) => {
|
||||
selectedFiles.value = [...files]
|
||||
pushLog('info', `已更新待校验文件列表,当前剩余 ${selectedFiles.value.length} 个文件`)
|
||||
|
||||
if (props.preparedState.validateResult || props.preparedState.latestImportResult || props.preparedState.hasImported) {
|
||||
markResultsDirty()
|
||||
pushLog('warning', '导入文件已变更,需要重新执行文件校验和正式导入')
|
||||
}
|
||||
}
|
||||
|
||||
const removeSelectedFile = (index: number) => {
|
||||
selectedFiles.value.splice(index, 1)
|
||||
pushLog('info', `已删除第 ${index + 1} 个待校验文件`)
|
||||
|
||||
if (props.preparedState.validateResult || props.preparedState.latestImportResult || props.preparedState.hasImported) {
|
||||
markResultsDirty()
|
||||
pushLog('warning', '导入文件已变更,需要重新执行文件校验和正式导入')
|
||||
}
|
||||
}
|
||||
|
||||
const handleDownloadTemplate = async () => {
|
||||
try {
|
||||
await useDownloadWithServerFileName(downloadReportTaskLedgerTemplateApi, '台账信息汇总', undefined, false, '.xlsx')
|
||||
pushLog('success', '台账导入模板下载成功')
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '台账模板下载失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
}
|
||||
}
|
||||
|
||||
const handleValidateFiles = async () => {
|
||||
if (validating.value) return
|
||||
|
||||
if (!props.draftId) {
|
||||
const message = '报告任务 ID 缺失,无法执行文件校验'
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
return
|
||||
}
|
||||
|
||||
if (!selectedFiles.value.length) {
|
||||
const message = '请先选择待校验的台账汇总与附件文件'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
const invalidFile = selectedFiles.value.find(file => !isReportTaskLedgerAttachmentFileName(file.name))
|
||||
if (invalidFile) {
|
||||
const message = '仅支持导入 .xls、.xlsx、.doc、.docx 文件'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', `${message},异常文件:${invalidFile.name}`)
|
||||
return
|
||||
}
|
||||
|
||||
const formData = new FormData()
|
||||
selectedFiles.value.forEach(file => {
|
||||
if (file.raw) {
|
||||
formData.append('files', file.raw)
|
||||
}
|
||||
})
|
||||
|
||||
if (!formData.getAll('files').length) {
|
||||
const message = '未检测到可上传的文件内容'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
return
|
||||
}
|
||||
|
||||
validating.value = true
|
||||
const validateId = props.preparedState.validateSessionId || props.draftId
|
||||
pushLog('info', `开始执行文件校验,本次共上传 ${selectedFiles.value.length} 个文件,会话标识:${validateId}`)
|
||||
|
||||
try {
|
||||
// 关键业务节点:首次校验使用当前草稿 ID,后续补传必须复用后端返回的 sessionId。
|
||||
const response = await validateReportTaskLedgerApi(validateId, formData)
|
||||
const normalizedResult = normalizeReportTaskLedgerValidateResult(response)
|
||||
const nextSessionId = String(normalizedResult.sessionId || validateId)
|
||||
const nextBatchId = normalizedResult.success && normalizedResult.batchId ? String(normalizedResult.batchId) : ''
|
||||
|
||||
updatePreparedState({
|
||||
validateSessionId: nextSessionId,
|
||||
validateResult: normalizedResult,
|
||||
latestImportResult: null,
|
||||
hasImported: false,
|
||||
validatedBatchId: nextBatchId,
|
||||
pendingRevalidate: false
|
||||
})
|
||||
|
||||
if (!normalizedResult.success || !nextBatchId) {
|
||||
const message = normalizedResult.canContinueUpload
|
||||
? '文件校验未通过,请按结果补传后继续使用当前 sessionId 重试'
|
||||
: '文件校验未通过,请根据校验结果修正后重新校验'
|
||||
ElMessage.warning(message)
|
||||
pushLog('warning', message)
|
||||
normalizedResult.failReasons?.forEach(reason => pushLog('warning', reason))
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.success('文件校验通过')
|
||||
pushLog('success', `文件校验通过,可进入正式导入步骤,batchId:${nextBatchId}`)
|
||||
} catch (error) {
|
||||
const message = getReportTaskErrorMessage(error, '文件校验失败')
|
||||
ElMessage.error(message)
|
||||
pushLog('error', message)
|
||||
} finally {
|
||||
validating.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-task-step {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
gap: 16px;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.panel-block {
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.panel-block:first-child {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.section-desc {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.section-alert,
|
||||
.file-table,
|
||||
.stage-table,
|
||||
.fail-reason + .fail-reason,
|
||||
.warning-grid,
|
||||
.sheet-summary-grid {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.file-table-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.file-table {
|
||||
height: 100%;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.toolbar-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.toolbar-download {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.file-summary-grid {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.file-summary-grid > * {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.file-summary-card,
|
||||
.sheet-summary-card {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
max-width: 260px;
|
||||
min-height: 32px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid var(--el-border-color-light);
|
||||
border-radius: 10px;
|
||||
background: var(--el-fill-color-light);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.file-summary-label,
|
||||
.sheet-summary-label {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.file-summary-value {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.warning-grid {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sheet-summary-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sheet-summary-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
max-width: none;
|
||||
min-height: 72px;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.attachment-panel {
|
||||
padding: 8px 16px 16px;
|
||||
background: var(--el-fill-color-lighter);
|
||||
}
|
||||
|
||||
.attachment-header {
|
||||
margin-bottom: 8px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
:deep(.el-empty) {
|
||||
flex: 1;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,40 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import assert from 'node:assert/strict'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const pageDir = path.resolve(__dirname, '..')
|
||||
const utilsFile = path.join(pageDir, 'utils/testReport.ts')
|
||||
const panelFile = path.join(pageDir, 'components/ReportTaskPrepareStep.vue')
|
||||
|
||||
const read = file => fs.readFileSync(file, 'utf8')
|
||||
|
||||
const utilsSource = read(utilsFile)
|
||||
const panelSource = read(panelFile)
|
||||
|
||||
assert.match(
|
||||
utilsSource,
|
||||
/export const TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME = '台账信息汇总'/,
|
||||
'utils/testReport.ts should define the ledger summary base file name constant'
|
||||
)
|
||||
|
||||
assert.match(
|
||||
utilsSource,
|
||||
/export const isReportTaskLedgerSummaryFileName = \(fileName: string\) =>[\s\S]*includes\(TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME\.toLowerCase\(\)\)[\s\S]*isReportTaskExcelFileName\(normalizedName\)/,
|
||||
'utils/testReport.ts should treat any Excel file containing 台账信息汇总 as the summary ledger file'
|
||||
)
|
||||
|
||||
assert.match(
|
||||
panelSource,
|
||||
/isReportTaskLedgerSummaryFileName/,
|
||||
'ReportTaskPrepareStep.vue should reuse the shared summary ledger matcher'
|
||||
)
|
||||
|
||||
assert.doesNotMatch(
|
||||
panelSource,
|
||||
/const isSummaryLedgerFileName =/,
|
||||
'ReportTaskPrepareStep.vue should not keep a local exact-match summary file matcher'
|
||||
)
|
||||
|
||||
console.log('ledger summary file contract passed')
|
||||
@@ -0,0 +1,124 @@
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
const pageDir = path.resolve(__dirname, '..')
|
||||
const srcDir = path.resolve(pageDir, '../../..')
|
||||
const apiDir = path.resolve(srcDir, 'api/aireport/testReport')
|
||||
|
||||
const read = file => fs.readFileSync(file, 'utf8')
|
||||
const assertFileIncludes = (file, snippets) => {
|
||||
const content = read(file)
|
||||
const missing = snippets.filter(snippet => !content.includes(snippet))
|
||||
|
||||
if (missing.length) {
|
||||
throw new Error(`${path.relative(srcDir, file)} missing: ${missing.join(', ')}`)
|
||||
}
|
||||
}
|
||||
|
||||
assertFileIncludes(path.join(srcDir, 'constants/dictCodes.ts'), ['TEST_REPORT_COMPANY', 'TEST_REPORT_STANDARD'])
|
||||
|
||||
assertFileIncludes(path.join(apiDir, 'index.ts'), [
|
||||
"const REPORT_TASK_BASE_URL = '/api/test-report'",
|
||||
'listReportTasksApi',
|
||||
'createReportTaskApi',
|
||||
'updateReportTaskApi',
|
||||
'deleteReportTasksApi',
|
||||
'getReportTaskDetailApi',
|
||||
'exportReportTasksApi',
|
||||
'submitReportTaskAuditApi',
|
||||
'downloadReportTaskLedgerTemplateApi',
|
||||
'importReportTaskLedgerApi',
|
||||
'listReportTaskGroupReportsApi'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(apiDir, 'interface/index.ts'), [
|
||||
'export namespace ReportTask',
|
||||
'ReportTaskRecord',
|
||||
'ReportTaskListParams',
|
||||
'ReportTaskAddParam',
|
||||
'ReportTaskSaveRequest',
|
||||
'ReportTaskAuditRequest',
|
||||
'ReportTaskLedgerImportResult',
|
||||
'ReportTaskLedgerImportStageRecord',
|
||||
'ReportTaskLedgerImportSnapshot',
|
||||
'ReportTaskGroupReportRecord',
|
||||
'ReportTaskLedgerPreparedState'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'utils/testReport.ts'), [
|
||||
'TEST_REPORT_EXCEL_EXTENSIONS',
|
||||
'REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP',
|
||||
'isReportTaskExcelFileName',
|
||||
'TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER',
|
||||
'normalizeReportTaskLedgerImportResult',
|
||||
'normalizeReportTaskLedgerSnapshot',
|
||||
'checkReportTaskLedgerPrepared',
|
||||
'resolveReportTaskGroupReportGenerateStateText',
|
||||
'resolveReportTaskGroupReportGenerateStateTagType'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
||||
"name: 'ReportTaskLedgerImportPanel'",
|
||||
'downloadReportTaskLedgerTemplateApi',
|
||||
'importReportTaskLedgerApi',
|
||||
'selectedFiles',
|
||||
'latestImportResult',
|
||||
'handleImportFiles',
|
||||
'toolbar-actions',
|
||||
'toolbar-download'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskFormDialog.vue'), [
|
||||
"name: 'ReportTaskFormDialog'",
|
||||
'ReportTaskLedgerImportPanel',
|
||||
'REPORT_TASK_FORM_STEPS',
|
||||
'currentStep',
|
||||
'logEntries',
|
||||
'logPanelExpanded',
|
||||
'goToImportStep',
|
||||
'handleLedgerPreparedChange',
|
||||
'ledgerPreparedState',
|
||||
'activeDraftId',
|
||||
'checkReportTaskLedgerPrepared',
|
||||
'log-panel-header',
|
||||
'log-panel-body',
|
||||
'log-panel-toggle',
|
||||
'white-space: nowrap',
|
||||
'text-overflow: ellipsis',
|
||||
'log-empty'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskDetailDialog.vue'), [
|
||||
"name: 'ReportTaskDetailDialog'",
|
||||
'groupReports',
|
||||
'generateState',
|
||||
'group-report-title',
|
||||
'resolveReportTaskGroupReportGenerateStateText'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskAuditDialog.vue'), [
|
||||
"name: 'ReportTaskAuditDialog'",
|
||||
'checkResult'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'index.vue'), [
|
||||
"name: 'ReportTaskPage'",
|
||||
'<ProTable',
|
||||
'ReportTaskFormDialog',
|
||||
'ReportTaskDetailDialog',
|
||||
'ReportTaskAuditDialog',
|
||||
'listReportTaskGroupReportsApi',
|
||||
'detailGroupReports',
|
||||
'ledger/import -> add/update'
|
||||
])
|
||||
|
||||
assertFileIncludes(path.join(pageDir, 'components/ReportTaskLedgerImportPanel.vue'), [
|
||||
'min-height: 0',
|
||||
'flex: 1',
|
||||
'display: flex',
|
||||
'flex-direction: column'
|
||||
])
|
||||
|
||||
console.log('testReport page contract passed')
|
||||
432
frontend/src/views/aireport/testReport/index.vue
Normal file
432
frontend/src/views/aireport/testReport/index.vue
Normal file
@@ -0,0 +1,432 @@
|
||||
<template>
|
||||
<div class="table-box report-task-page">
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
:request-error="handleTableRequestError"
|
||||
:search-col="{ xs: 1, sm: 2, md: 2, lg: 4, xl: 4 }"
|
||||
:tool-button="['refresh', 'setting']"
|
||||
row-key="id"
|
||||
>
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="Plus" @click="openCreateDialog">新增</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
:icon="Delete"
|
||||
:disabled="!scope.isSelected"
|
||||
@click="handleBatchDelete(scope.selectedListIds)"
|
||||
>
|
||||
批量删除
|
||||
</el-button>
|
||||
<el-button type="primary" plain :icon="Download" @click="handleExport">导出</el-button>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<el-button link type="primary" :icon="View" @click="openDetailDialog(row)">详情</el-button>
|
||||
<el-button link type="primary" :icon="Edit" @click="openEditDialog(row)">编辑</el-button>
|
||||
<el-button link type="primary" :icon="Upload" @click="openAuditDialog(row)">提交审核</el-button>
|
||||
<el-button link type="danger" :icon="Delete" @click="handleDelete(row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<ReportTaskFormDialog
|
||||
v-model:visible="formDialogVisible"
|
||||
:mode="formMode"
|
||||
:record="currentRecord"
|
||||
:saving="formSaving"
|
||||
:save-success-version="formSaveSuccessVersion"
|
||||
:client-unit-options="clientUnitOptions"
|
||||
:report-model-options="reportModelOptions"
|
||||
:company-options="companyOptions"
|
||||
:standard-options="standardOptions"
|
||||
@submit="handleSaveReportTask"
|
||||
/>
|
||||
|
||||
<ReportTaskDetailDialog
|
||||
v-model:visible="detailDialogVisible"
|
||||
:loading="detailLoading"
|
||||
:detail="detailRecord"
|
||||
:group-reports="detailGroupReports"
|
||||
:company-label-map="companyLabelMap"
|
||||
:standard-label-map="standardLabelMap"
|
||||
/>
|
||||
|
||||
<ReportTaskAuditDialog
|
||||
v-model:visible="auditDialogVisible"
|
||||
:saving="auditSaving"
|
||||
:record="currentAuditRecord"
|
||||
@submit="handleSubmitAudit"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { Delete, Download, Edit, Plus, Upload, View } from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import type { Dict, ResPage } from '@/api/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import {
|
||||
createReportTaskApi,
|
||||
deleteReportTasksApi,
|
||||
exportReportTasksApi,
|
||||
getReportTaskDetailApi,
|
||||
listReportTaskGroupReportsApi,
|
||||
listReportTasksApi,
|
||||
submitReportTaskAuditApi,
|
||||
updateReportTaskApi
|
||||
} from '@/api/aireport/testReport'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { listClientUnitsApi } from '@/api/aireport/clientUnit'
|
||||
import { listReportModelsApi } from '@/api/aireport/reportModel'
|
||||
import { getDictList } from '@/api/user/login'
|
||||
import { DICT_CODES } from '@/constants/dictCodes'
|
||||
import { useDownloadWithServerFileName } from '@/hooks/useDownload'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import ReportTaskAuditDialog from './components/ReportTaskAuditDialog.vue'
|
||||
import ReportTaskDetailDialog from './components/ReportTaskDetailDialog.vue'
|
||||
import ReportTaskFormDialog from './components/ReportTaskFormDialog.vue'
|
||||
import {
|
||||
buildDictSelectOptions,
|
||||
buildOptionLabelMap,
|
||||
getReportTaskErrorMessage,
|
||||
normalizeReportTaskGroupReportList,
|
||||
normalizeReportTaskListParams,
|
||||
normalizeReportTaskPage,
|
||||
resolveReportTaskCreateUnitText,
|
||||
resolveReportTaskStandardText,
|
||||
resolveReportTaskText,
|
||||
unwrapReportTaskPayload
|
||||
} from './utils/testReport'
|
||||
|
||||
defineOptions({
|
||||
name: 'ReportTaskPage'
|
||||
})
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const proTable = ref<ProTableInstance>()
|
||||
const formDialogVisible = ref(false)
|
||||
const detailDialogVisible = ref(false)
|
||||
const auditDialogVisible = ref(false)
|
||||
const formSaving = ref(false)
|
||||
const formSaveSuccessVersion = ref(0)
|
||||
const detailLoading = ref(false)
|
||||
const auditSaving = ref(false)
|
||||
const formMode = ref<'create' | 'edit'>('create')
|
||||
const currentRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||
const detailRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||
const detailGroupReports = ref<ReportTask.ReportTaskGroupReportRecord[]>([])
|
||||
const currentAuditRecord = ref<ReportTask.ReportTaskRecord | null>(null)
|
||||
const clientUnitOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
const reportModelOptions = ref<Array<{ label: string; value: string }>>([])
|
||||
|
||||
const companyOptions = computed(() => buildDictSelectOptions(dictStore.getDictData(DICT_CODES.TEST_REPORT_COMPANY)))
|
||||
const standardOptions = computed(() => buildDictSelectOptions(dictStore.getDictData(DICT_CODES.TEST_REPORT_STANDARD)))
|
||||
const companyLabelMap = computed(() => buildOptionLabelMap(companyOptions.value))
|
||||
const standardLabelMap = computed(() => buildOptionLabelMap(standardOptions.value))
|
||||
const requiredDictCodes = [DICT_CODES.TEST_REPORT_COMPANY, DICT_CODES.TEST_REPORT_STANDARD]
|
||||
const currentSearchParams = computed(() =>
|
||||
normalizeReportTaskListParams((proTable.value?.searchParam || {}) as ReportTask.ReportTaskListParams)
|
||||
)
|
||||
|
||||
const columns = reactive<ColumnProps<ReportTask.ReportTaskRecord>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'keyword',
|
||||
label: '关键字',
|
||||
minWidth: 180,
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'input',
|
||||
order: 1,
|
||||
props: {
|
||||
placeholder: '请输入报告编号、合同编号、委托单位或模板'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'timeRange',
|
||||
label: '创建时间',
|
||||
minWidth: 220,
|
||||
isShow: false,
|
||||
search: {
|
||||
el: 'date-picker',
|
||||
order: 2,
|
||||
key: 'timeRange',
|
||||
props: {
|
||||
type: 'datetimerange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
startPlaceholder: '开始创建时间',
|
||||
endPlaceholder: '结束创建时间'
|
||||
}
|
||||
}
|
||||
},
|
||||
{ prop: 'no', label: '报告编号', minWidth: 180, fixed: 'left', render: ({ row }) => resolveReportTaskText(row.no) },
|
||||
{ prop: 'clientUnitName', label: '委托单位', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.clientUnitName) },
|
||||
{ prop: 'reportModelName', label: '报告模板', minWidth: 160, render: ({ row }) => resolveReportTaskText(row.reportModelName) },
|
||||
{
|
||||
prop: 'createUnit',
|
||||
label: '检测公司',
|
||||
minWidth: 160,
|
||||
render: ({ row }) => resolveReportTaskCreateUnitText(row.createUnit, companyLabelMap.value)
|
||||
},
|
||||
{ prop: 'contractNumber', label: '合同编号', minWidth: 150, render: ({ row }) => resolveReportTaskText(row.contractNumber) },
|
||||
{
|
||||
prop: 'standard',
|
||||
label: '测试依据',
|
||||
minWidth: 220,
|
||||
showOverflowTooltip: true,
|
||||
render: ({ row }) => resolveReportTaskStandardText(row.standard, standardLabelMap.value)
|
||||
},
|
||||
{ prop: 'pointCount', label: '监测点数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.pointCount) },
|
||||
{ prop: 'groupCount', label: '分组数', minWidth: 100, render: ({ row }) => resolveReportTaskText(row.groupCount) },
|
||||
{ prop: 'phonenumber', label: '联系电话', minWidth: 140, render: ({ row }) => resolveReportTaskText(row.phonenumber) },
|
||||
{ prop: 'checkerName', label: '审核人', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkerName) },
|
||||
{ prop: 'checkTime', label: '审核时间', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.checkTime) },
|
||||
{ prop: 'checkResult', label: '审核意见', minWidth: 200, showOverflowTooltip: true, render: ({ row }) => resolveReportTaskText(row.checkResult) },
|
||||
{ prop: 'createByName', label: '创建人', minWidth: 120, render: ({ row }) => resolveReportTaskText(row.createByName || row.createBy) },
|
||||
{ prop: 'createTime', label: '创建时间', minWidth: 170, render: ({ row }) => resolveReportTaskText(row.createTime) },
|
||||
{ prop: 'updateByName', label: '更新人', minWidth: 120, isShow: false, render: ({ row }) => resolveReportTaskText(row.updateByName || row.updateBy) },
|
||||
{ prop: 'updateTime', label: '更新时间', minWidth: 170, isShow: false, render: ({ row }) => resolveReportTaskText(row.updateTime) },
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 280 }
|
||||
])
|
||||
|
||||
const ensureReportTaskDictOptionsReady = async () => {
|
||||
const missingCodes = requiredDictCodes.filter(code => !dictStore.getDictData(code).length)
|
||||
if (!missingCodes.length) return
|
||||
|
||||
const response = await getDictList()
|
||||
const dictData = (response.data as unknown as Dict[]) || []
|
||||
if (!dictData.length) return
|
||||
|
||||
const nextDictMap = new Map((dictStore.dictData || []).map(item => [item.code, item]))
|
||||
dictData.forEach(item => {
|
||||
if (item?.code) {
|
||||
nextDictMap.set(item.code, item)
|
||||
}
|
||||
})
|
||||
|
||||
// 关键业务节点:检测公司和测试依据展示依赖字典缓存,缺失时必须先补齐再做 ID 到名称映射。
|
||||
dictStore.setDictData(Array.from(nextDictMap.values()))
|
||||
}
|
||||
|
||||
const loadClientUnitOptions = async () => {
|
||||
const response = await listClientUnitsApi({ pageNum: 1, pageSize: 200 })
|
||||
const pageData = normalizeReportTaskPage<{ id?: string; name?: string }>(
|
||||
response as unknown as ResPage<{ id?: string; name?: string }>
|
||||
)
|
||||
|
||||
clientUnitOptions.value = (pageData.records || [])
|
||||
.filter(item => item.id && item.name)
|
||||
.map(item => ({
|
||||
label: item.name!,
|
||||
value: item.id!
|
||||
}))
|
||||
}
|
||||
|
||||
const loadReportModelOptions = async () => {
|
||||
const response = await listReportModelsApi({ pageNum: 1, pageSize: 200 })
|
||||
const pageData = normalizeReportTaskPage<{ id?: string; name?: string }>(
|
||||
response as unknown as ResPage<{ id?: string; name?: string }>
|
||||
)
|
||||
|
||||
reportModelOptions.value = (pageData.records || [])
|
||||
.filter(item => item.id && item.name)
|
||||
.map(item => ({
|
||||
label: item.name!,
|
||||
value: item.id!
|
||||
}))
|
||||
}
|
||||
|
||||
const ensureFormOptionsReady = async () => {
|
||||
try {
|
||||
await Promise.all([ensureReportTaskDictOptionsReady(), loadClientUnitOptions(), loadReportModelOptions()])
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务关联选项加载失败'))
|
||||
clientUnitOptions.value = []
|
||||
reportModelOptions.value = []
|
||||
}
|
||||
}
|
||||
|
||||
const getTableList = async (params: ReportTask.ReportTaskListParams = {}) => {
|
||||
const response = await listReportTasksApi(normalizeReportTaskListParams(params))
|
||||
const pageData = normalizeReportTaskPage<ReportTask.ReportTaskRecord>(
|
||||
response as unknown as ResPage<ReportTask.ReportTaskRecord>
|
||||
)
|
||||
|
||||
return {
|
||||
data: pageData
|
||||
}
|
||||
}
|
||||
|
||||
const refreshReportTasks = () => {
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const handleTableRequestError = (error: unknown) => {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务列表查询失败'))
|
||||
}
|
||||
|
||||
const openCreateDialog = async () => {
|
||||
formMode.value = 'create'
|
||||
currentRecord.value = null
|
||||
await ensureFormOptionsReady()
|
||||
formDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openEditDialog = async (row: ReportTask.ReportTaskRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前报告任务缺少 ID,无法编辑')
|
||||
return
|
||||
}
|
||||
|
||||
await ensureFormOptionsReady()
|
||||
formMode.value = 'edit'
|
||||
|
||||
try {
|
||||
// 关键业务节点:编辑表单提交仍依赖原始 clientUnitId、reportModelId、createUnit、standard 等字段,不能只回填列表展示文本。
|
||||
const response = await getReportTaskDetailApi(row.id)
|
||||
currentRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(response)
|
||||
formDialogVisible.value = true
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务详情查询失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const openDetailDialog = async (row: ReportTask.ReportTaskRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前报告任务缺少 ID,无法查看详情')
|
||||
return
|
||||
}
|
||||
|
||||
detailRecord.value = null
|
||||
detailGroupReports.value = []
|
||||
detailDialogVisible.value = true
|
||||
detailLoading.value = true
|
||||
|
||||
try {
|
||||
const [detailResponse, groupReportsResponse] = await Promise.all([
|
||||
getReportTaskDetailApi(row.id),
|
||||
listReportTaskGroupReportsApi(row.id)
|
||||
])
|
||||
|
||||
detailRecord.value = unwrapReportTaskPayload<ReportTask.ReportTaskRecord>(detailResponse)
|
||||
detailGroupReports.value = normalizeReportTaskGroupReportList(groupReportsResponse)
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务详情查询失败'))
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const openAuditDialog = (row: ReportTask.ReportTaskRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前报告任务缺少 ID,无法提交审核')
|
||||
return
|
||||
}
|
||||
|
||||
currentAuditRecord.value = row
|
||||
auditDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleSaveReportTask = async (params: ReportTask.ReportTaskSaveRequest) => {
|
||||
formSaving.value = true
|
||||
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
await createReportTaskApi(params)
|
||||
} else {
|
||||
await updateReportTaskApi(params)
|
||||
}
|
||||
|
||||
ElMessage.success(formMode.value === 'create' ? '报告任务新增成功' : '报告任务编辑成功')
|
||||
formSaveSuccessVersion.value += 1
|
||||
refreshReportTasks()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务保存失败'))
|
||||
} finally {
|
||||
formSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmitAudit = async (params: ReportTask.ReportTaskAuditRequest) => {
|
||||
auditSaving.value = true
|
||||
|
||||
try {
|
||||
await submitReportTaskAuditApi(params)
|
||||
ElMessage.success('报告任务提交审核成功')
|
||||
auditDialogVisible.value = false
|
||||
refreshReportTasks()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务提交审核失败'))
|
||||
} finally {
|
||||
auditSaving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const deleteReportTasks = async (ids: string[], successMessage: string) => {
|
||||
if (!ids.length) {
|
||||
ElMessage.warning('请选择要删除的报告任务')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm('删除后报告任务将不可见,是否继续?', '删除报告任务', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await deleteReportTasksApi(ids)
|
||||
ElMessage.success(successMessage)
|
||||
refreshReportTasks()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务删除失败'))
|
||||
}
|
||||
}
|
||||
|
||||
const handleDelete = async (row: ReportTask.ReportTaskRecord) => {
|
||||
if (!row.id) {
|
||||
ElMessage.warning('当前报告任务缺少 ID,无法删除')
|
||||
return
|
||||
}
|
||||
|
||||
await deleteReportTasks([row.id], '报告任务删除成功')
|
||||
}
|
||||
|
||||
const handleBatchDelete = async (ids: string[]) => {
|
||||
await deleteReportTasks(ids, '报告任务批量删除成功')
|
||||
}
|
||||
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await useDownloadWithServerFileName(exportReportTasksApi, '普测报告列表', currentSearchParams.value, false, '.xlsx')
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务导出失败'))
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await ensureReportTaskDictOptionsReady()
|
||||
} catch (error) {
|
||||
ElMessage.error(getReportTaskErrorMessage(error, '报告任务字典加载失败'))
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.report-task-page {
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,88 @@
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { checkReportTaskLedgerPrepared } from './testReport'
|
||||
|
||||
export type ReportTaskFlowStep = 'prepare' | 'import' | 'form' | 'done'
|
||||
|
||||
export interface ReportTaskFlowStepOption {
|
||||
index: number
|
||||
value: ReportTaskFlowStep
|
||||
title: string
|
||||
description: string
|
||||
}
|
||||
|
||||
export const REPORT_TASK_FLOW_STEPS: ReportTaskFlowStepOption[] = [
|
||||
{
|
||||
index: 1,
|
||||
value: 'prepare',
|
||||
title: '文件选择与校验',
|
||||
description: '准备台账文件并完成校验'
|
||||
},
|
||||
{
|
||||
index: 2,
|
||||
value: 'import',
|
||||
title: '文件导入',
|
||||
description: '使用已校验批次执行正式导入'
|
||||
},
|
||||
{
|
||||
index: 3,
|
||||
value: 'form',
|
||||
title: '基础信息维护',
|
||||
description: '填写并确认任务基础信息'
|
||||
},
|
||||
{
|
||||
index: 4,
|
||||
value: 'done',
|
||||
title: '完成',
|
||||
description: '查看结果并结束本次流程'
|
||||
}
|
||||
]
|
||||
|
||||
export const createEmptyLedgerPreparedState = (): ReportTask.ReportTaskLedgerPreparedState => ({
|
||||
draftId: '',
|
||||
validateSessionId: '',
|
||||
validateResult: null,
|
||||
latestImportResult: null,
|
||||
snapshot: null,
|
||||
hasImported: false,
|
||||
validatedBatchId: '',
|
||||
pendingRevalidate: false
|
||||
})
|
||||
|
||||
export const hasValidatedLedgerBatch = (state: ReportTask.ReportTaskLedgerPreparedState | null | undefined) =>
|
||||
Boolean(state?.draftId && state?.validatedBatchId && state?.validateResult?.success && !state?.pendingRevalidate)
|
||||
|
||||
export const resolveInitialFlowStep = (
|
||||
mode: 'create' | 'edit',
|
||||
state: ReportTask.ReportTaskLedgerPreparedState
|
||||
): ReportTaskFlowStep => {
|
||||
if (mode === 'edit' && checkReportTaskLedgerPrepared(state)) {
|
||||
return 'form'
|
||||
}
|
||||
|
||||
return 'prepare'
|
||||
}
|
||||
|
||||
export const canReachFlowStep = (
|
||||
step: ReportTaskFlowStep,
|
||||
state: ReportTask.ReportTaskLedgerPreparedState,
|
||||
currentStep: ReportTaskFlowStep
|
||||
) => {
|
||||
if (step === 'prepare') return true
|
||||
if (step === 'import') {
|
||||
return hasValidatedLedgerBatch(state) || state.hasImported || Boolean(state.snapshot) || currentStep === 'import' || currentStep === 'form' || currentStep === 'done'
|
||||
}
|
||||
if (step === 'form') return checkReportTaskLedgerPrepared(state) || currentStep === 'form' || currentStep === 'done'
|
||||
return currentStep === 'done'
|
||||
}
|
||||
|
||||
export const resolveFlowStepStatus = (
|
||||
step: ReportTaskFlowStep,
|
||||
currentStep: ReportTaskFlowStep,
|
||||
state: ReportTask.ReportTaskLedgerPreparedState
|
||||
) => {
|
||||
if (currentStep === step) return 'active'
|
||||
if (step === 'prepare' && (hasValidatedLedgerBatch(state) || currentStep === 'form' || currentStep === 'done')) return 'done'
|
||||
if (step === 'import' && (checkReportTaskLedgerPrepared(state) || currentStep === 'done')) return 'done'
|
||||
if (step === 'form' && currentStep === 'done') return 'done'
|
||||
return 'pending'
|
||||
}
|
||||
421
frontend/src/views/aireport/testReport/utils/testReport.ts
Normal file
421
frontend/src/views/aireport/testReport/utils/testReport.ts
Normal file
@@ -0,0 +1,421 @@
|
||||
import type { TagProps } from 'element-plus'
|
||||
import type { Dict, ResultData, ResPage } from '@/api/interface'
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
|
||||
type TagType = TagProps['type']
|
||||
|
||||
export const TEST_REPORT_EXCEL_EXTENSIONS = ['.xls', '.xlsx']
|
||||
export const TEST_REPORT_WORD_EXTENSIONS = ['.doc', '.docx']
|
||||
export const TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME = '台账信息汇总'
|
||||
export const TEST_REPORT_LEDGER_IMPORT_STAGE_ORDER: ReportTask.ReportTaskLedgerImportStage[] = [
|
||||
'选择文件',
|
||||
'校验文件',
|
||||
'文件导入',
|
||||
'基础资料维护',
|
||||
'完成'
|
||||
]
|
||||
export const REPORT_TASK_STATE_MAP: Record<ReportTask.ReportTaskState, { text: string; tagType: TagType }> = {
|
||||
'01': { text: '编制中', tagType: 'info' },
|
||||
'02': { text: '审核中', tagType: 'warning' },
|
||||
'03': { text: '已通过', tagType: 'success' },
|
||||
'04': { text: '已退回', tagType: 'danger' },
|
||||
'05': { text: '已删除', tagType: 'info' }
|
||||
}
|
||||
export const REPORT_TASK_STATE_OPTIONS: Array<{ label: string; value: ReportTask.ReportTaskState }> = [
|
||||
{ label: '编制中', value: '01' },
|
||||
{ label: '审核中', value: '02' },
|
||||
{ label: '已通过', value: '03' },
|
||||
{ label: '已退回', value: '04' },
|
||||
{ label: '已删除', value: '05' }
|
||||
]
|
||||
export const REPORT_TASK_GENERATE_STATE_MAP: Record<ReportTask.ReportTaskGenerateState, { text: string; tagType: TagType }> = {
|
||||
0: { text: '未生成', tagType: 'info' },
|
||||
1: { text: '生成中', tagType: 'warning' },
|
||||
2: { text: '已生成', tagType: 'success' }
|
||||
}
|
||||
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP: Record<number, string> = {
|
||||
0: '未生成',
|
||||
1: '生成中',
|
||||
2: '生成成功',
|
||||
3: '生成失败'
|
||||
}
|
||||
export const REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP: Record<
|
||||
number,
|
||||
'warning' | 'success' | 'danger' | undefined
|
||||
> = {
|
||||
0: undefined,
|
||||
1: 'warning',
|
||||
2: 'success',
|
||||
3: 'danger'
|
||||
}
|
||||
|
||||
export const resolveReportTaskText = (value: unknown) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
const text = String(value).trim()
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
export const normalizeReportTaskListParams = (
|
||||
params: ReportTask.ReportTaskListParams = {}
|
||||
): ReportTask.ReportTaskListParams => {
|
||||
const timeRange = Array.isArray(params.timeRange) ? params.timeRange : []
|
||||
const [searchBeginTime = '', searchEndTime = ''] = timeRange
|
||||
|
||||
return {
|
||||
keyword: String(params.keyword || '').trim() || undefined,
|
||||
searchBeginTime: searchBeginTime || params.searchBeginTime || undefined,
|
||||
searchEndTime: searchEndTime || params.searchEndTime || undefined,
|
||||
state: params.state || undefined,
|
||||
pageNum: params.pageNum || 1,
|
||||
pageSize: params.pageSize || 10
|
||||
}
|
||||
}
|
||||
|
||||
export const unwrapReportTaskPayload = <T>(response: ResultData<T> | T): T => {
|
||||
if (response && typeof response === 'object' && 'data' in response) {
|
||||
return (response as ResultData<T>).data
|
||||
}
|
||||
|
||||
return response as T
|
||||
}
|
||||
|
||||
export const normalizeReportTaskPage = <T>(
|
||||
response: ResultData<ResPage<T>> | ResPage<T> | null | undefined
|
||||
): ResPage<T> => {
|
||||
const payload = unwrapReportTaskPayload<ResPage<T> | null | undefined>(response as ResultData<ResPage<T>>)
|
||||
|
||||
return {
|
||||
records: payload?.records || [],
|
||||
current: payload?.current || 1,
|
||||
size: payload?.size || 10,
|
||||
total: payload?.total || 0
|
||||
}
|
||||
}
|
||||
|
||||
export const getReportTaskErrorMessage = (error: unknown, fallback: string) => {
|
||||
if (error instanceof Error && error.message) return error.message
|
||||
if (error && typeof error === 'object' && 'message' in error) {
|
||||
return String((error as { message?: unknown }).message || fallback)
|
||||
}
|
||||
|
||||
return fallback
|
||||
}
|
||||
|
||||
export const isReportTaskExcelFileName = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
return TEST_REPORT_EXCEL_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
||||
}
|
||||
|
||||
export const isReportTaskWordFileName = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
return TEST_REPORT_WORD_EXTENSIONS.some(extension => normalizedName.endsWith(extension))
|
||||
}
|
||||
|
||||
export const isReportTaskLedgerSummaryFileName = (fileName: string) => {
|
||||
const normalizedName = String(fileName || '').trim().toLowerCase()
|
||||
return normalizedName.includes(TEST_REPORT_LEDGER_SUMMARY_FILE_BASE_NAME.toLowerCase()) && isReportTaskExcelFileName(normalizedName)
|
||||
}
|
||||
|
||||
export const isReportTaskLedgerAttachmentFileName = (fileName: string) =>
|
||||
isReportTaskExcelFileName(fileName) || isReportTaskWordFileName(fileName)
|
||||
|
||||
export const normalizeReportTaskPointList = (
|
||||
response: ResultData<ReportTask.ReportTaskPointRecord[]> | ReportTask.ReportTaskPointRecord[] | null | undefined
|
||||
) => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskPointRecord[] | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskPointRecord[]>
|
||||
)
|
||||
|
||||
return Array.isArray(payload) ? payload : []
|
||||
}
|
||||
|
||||
export const normalizeReportTaskLedgerImportResult = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskLedgerImportResult>
|
||||
| ReportTask.ReportTaskLedgerImportResult
|
||||
| null
|
||||
| undefined
|
||||
): ReportTask.ReportTaskLedgerImportResult => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskLedgerImportResult | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskLedgerImportResult>
|
||||
)
|
||||
|
||||
const stageList = Array.isArray(payload?.stages) ? payload.stages : []
|
||||
|
||||
return {
|
||||
batchId: payload?.batchId || undefined,
|
||||
currentStage: payload?.currentStage || undefined,
|
||||
success: payload?.success ?? false,
|
||||
summaryFileName: payload?.summaryFileName || undefined,
|
||||
tempStoragePath: payload?.tempStoragePath || undefined,
|
||||
totalFileCount: payload?.totalFileCount ?? 0,
|
||||
uploadedFileCount: payload?.uploadedFileCount ?? 0,
|
||||
pointCount: payload?.pointCount ?? 0,
|
||||
excelAttachmentCount: payload?.excelAttachmentCount ?? 0,
|
||||
wordAttachmentCount: payload?.wordAttachmentCount ?? 0,
|
||||
deviceAddedCount: payload?.deviceAddedCount ?? 0,
|
||||
deviceReuseCount: payload?.deviceReuseCount ?? 0,
|
||||
clientAddedCount: payload?.clientAddedCount ?? 0,
|
||||
clientReuseCount: payload?.clientReuseCount ?? 0,
|
||||
groupCount: payload?.groupCount ?? 0,
|
||||
failReasons: Array.isArray(payload?.failReasons) ? payload.failReasons.filter(Boolean) : [],
|
||||
stages: stageList.map(stage => ({
|
||||
stage: stage?.stage || undefined,
|
||||
success: stage?.success ?? false,
|
||||
message: stage?.message || ''
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
export const normalizeReportTaskLedgerValidateResult = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskLedgerValidateResult>
|
||||
| ReportTask.ReportTaskLedgerValidateResult
|
||||
| null
|
||||
| undefined
|
||||
): ReportTask.ReportTaskLedgerValidateResult => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskLedgerValidateResult | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskLedgerValidateResult>
|
||||
)
|
||||
|
||||
return {
|
||||
sessionId: payload?.sessionId || undefined,
|
||||
batchId: payload?.batchId || undefined,
|
||||
success: payload?.success ?? false,
|
||||
summaryFileName: payload?.summaryFileName || undefined,
|
||||
summaryFilePresent: payload?.summaryFilePresent ?? false,
|
||||
tempStoragePath: payload?.tempStoragePath || undefined,
|
||||
uploadedFileCount: payload?.uploadedFileCount ?? 0,
|
||||
pointCount: payload?.pointCount ?? 0,
|
||||
missingAttachmentCount: payload?.missingAttachmentCount ?? 0,
|
||||
canContinueUpload: payload?.canContinueUpload ?? false,
|
||||
requiredSheets: Array.isArray(payload?.requiredSheets) ? payload.requiredSheets.filter(Boolean) : [],
|
||||
existingSheets: Array.isArray(payload?.existingSheets) ? payload.existingSheets.filter(Boolean) : [],
|
||||
missingSheets: Array.isArray(payload?.missingSheets) ? payload.missingSheets.filter(Boolean) : [],
|
||||
orphanAttachmentNames: Array.isArray(payload?.orphanAttachmentNames) ? payload.orphanAttachmentNames.filter(Boolean) : [],
|
||||
failReasons: Array.isArray(payload?.failReasons) ? payload.failReasons.filter(Boolean) : [],
|
||||
points: Array.isArray(payload?.points)
|
||||
? payload.points.map(point => ({
|
||||
rowNo: point?.rowNo ?? null,
|
||||
pointKey: point?.pointKey || undefined,
|
||||
substationName: point?.substationName || undefined,
|
||||
pointName: point?.pointName || undefined,
|
||||
complete: point?.complete ?? false,
|
||||
missingAttachmentCount: point?.missingAttachmentCount ?? 0,
|
||||
testDeviceNoValid: point?.testDeviceNoValid ?? false,
|
||||
testDeviceNoMessage: point?.testDeviceNoMessage || undefined,
|
||||
clientUnitNameValid: point?.clientUnitNameValid ?? false,
|
||||
clientUnitNameMessage: point?.clientUnitNameMessage || undefined,
|
||||
attachments: Array.isArray(point?.attachments)
|
||||
? point.attachments.map(attachment => ({
|
||||
attachmentName: attachment?.attachmentName || undefined,
|
||||
attachmentType: attachment?.attachmentType || undefined,
|
||||
referenced: attachment?.referenced ?? false,
|
||||
uploaded: attachment?.uploaded ?? false,
|
||||
missing: attachment?.missing ?? false,
|
||||
reuploadAllowed: attachment?.reuploadAllowed ?? false,
|
||||
message: attachment?.message || undefined
|
||||
}))
|
||||
: []
|
||||
}))
|
||||
: []
|
||||
}
|
||||
}
|
||||
|
||||
export const normalizeReportTaskGroupReportList = (
|
||||
response:
|
||||
| ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||
| ReportTask.ReportTaskGroupReportRecord[]
|
||||
| null
|
||||
| undefined
|
||||
) => {
|
||||
const payload = unwrapReportTaskPayload<ReportTask.ReportTaskGroupReportRecord[] | null | undefined>(
|
||||
response as ResultData<ReportTask.ReportTaskGroupReportRecord[]>
|
||||
)
|
||||
|
||||
return Array.isArray(payload) ? payload : []
|
||||
}
|
||||
|
||||
export const normalizeReportTaskLedgerSnapshot = (
|
||||
value: string | ReportTask.ReportTaskLedgerImportSnapshot | null | undefined
|
||||
): ReportTask.ReportTaskLedgerImportSnapshot | null => {
|
||||
if (!value) return null
|
||||
|
||||
const snapshot =
|
||||
typeof value === 'string'
|
||||
? (() => {
|
||||
try {
|
||||
return JSON.parse(value) as ReportTask.ReportTaskLedgerImportSnapshot
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
})()
|
||||
: value
|
||||
|
||||
if (!snapshot || typeof snapshot !== 'object') return null
|
||||
|
||||
return {
|
||||
version: snapshot.version || undefined,
|
||||
importMode: snapshot.importMode || undefined,
|
||||
summaryFileName: snapshot.summaryFileName || undefined,
|
||||
sheetSummary: snapshot.sheetSummary
|
||||
? {
|
||||
pointSheet: snapshot.sheetSummary.pointSheet || undefined,
|
||||
deviceSheetPresent: snapshot.sheetSummary.deviceSheetPresent ?? false,
|
||||
clientSheetPresent: snapshot.sheetSummary.clientSheetPresent ?? false
|
||||
}
|
||||
: null,
|
||||
rowCount: snapshot.rowCount ?? 0,
|
||||
groupSummary: Array.isArray(snapshot.groupSummary)
|
||||
? snapshot.groupSummary.map(item => ({
|
||||
groupNo: item?.groupNo ?? null,
|
||||
count: item?.count ?? 0
|
||||
}))
|
||||
: [],
|
||||
baseDataSummary: snapshot.baseDataSummary
|
||||
? {
|
||||
deviceAddedCount: snapshot.baseDataSummary.deviceAddedCount ?? 0,
|
||||
deviceReuseCount: snapshot.baseDataSummary.deviceReuseCount ?? 0,
|
||||
clientAddedCount: snapshot.baseDataSummary.clientAddedCount ?? 0,
|
||||
clientReuseCount: snapshot.baseDataSummary.clientReuseCount ?? 0
|
||||
}
|
||||
: null
|
||||
}
|
||||
}
|
||||
|
||||
export const resolveReportTaskGroupReportGenerateStateText = (value: number | null | undefined) => {
|
||||
if (value === null || value === undefined) return '-'
|
||||
|
||||
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TEXT_MAP[value] || String(value)
|
||||
}
|
||||
|
||||
export const resolveReportTaskGroupReportGenerateStateTagType = (value: number | null | undefined) => {
|
||||
if (value === null || value === undefined) return undefined
|
||||
|
||||
return REPORT_TASK_GROUP_REPORT_GENERATE_STATUS_TAG_TYPE_MAP[value]
|
||||
}
|
||||
|
||||
export const getReportTaskStateText = (state?: string | null) =>
|
||||
REPORT_TASK_STATE_MAP[state as ReportTask.ReportTaskState]?.text || '未知状态'
|
||||
|
||||
export const getReportTaskStateTagType = (state?: string | null): TagType =>
|
||||
REPORT_TASK_STATE_MAP[state as ReportTask.ReportTaskState]?.tagType || 'info'
|
||||
|
||||
export const getReportTaskGenerateStateText = (state?: number | null) =>
|
||||
REPORT_TASK_GENERATE_STATE_MAP[state as ReportTask.ReportTaskGenerateState]?.text || '未知状态'
|
||||
|
||||
export const getReportTaskGenerateStateTagType = (state?: number | null): TagType =>
|
||||
REPORT_TASK_GENERATE_STATE_MAP[state as ReportTask.ReportTaskGenerateState]?.tagType || 'info'
|
||||
|
||||
export const checkReportTaskLedgerPrepared = (
|
||||
state: ReportTask.ReportTaskLedgerPreparedState | null | undefined
|
||||
) => Boolean(state?.draftId && state.hasImported && !state.pendingRevalidate)
|
||||
|
||||
export const buildDictSelectOptions = (dictData: Dict[] = []) =>
|
||||
dictData
|
||||
.filter(item => item.id && item.name)
|
||||
.map(item => ({
|
||||
label: item.name,
|
||||
value: item.id
|
||||
}))
|
||||
|
||||
export const buildOptionLabelMap = (options: Array<{ label: string; value: string }>) =>
|
||||
options.reduce<Record<string, string>>((result, option) => {
|
||||
result[option.value] = option.label
|
||||
return result
|
||||
}, {})
|
||||
|
||||
export const parseReportTaskStandardIds = (value?: string[] | string | null) => {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(item => String(item).trim()).filter(Boolean)
|
||||
}
|
||||
|
||||
const text = String(value || '').trim()
|
||||
if (!text) return []
|
||||
|
||||
try {
|
||||
const parsedValue = JSON.parse(text)
|
||||
if (Array.isArray(parsedValue)) {
|
||||
return parsedValue.map(item => String(item).trim()).filter(Boolean)
|
||||
}
|
||||
} catch {
|
||||
return text ? [text] : []
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
export const stringifyReportTaskStandardIds = (value: string[]) =>
|
||||
value.map(item => String(item).trim()).filter(Boolean)
|
||||
|
||||
export const normalizeReportTaskGroupSavePayload = (
|
||||
pointList: ReportTask.ReportTaskPointRecord[],
|
||||
pointGroupMap: Record<string, number | string | null | undefined>
|
||||
): ReportTask.ReportTaskGroupSaveRequest => {
|
||||
const groupedPointMap = new Map<number, string[]>()
|
||||
|
||||
pointList.forEach(point => {
|
||||
const pointId = String(point.id || '').trim()
|
||||
if (!pointId) return
|
||||
|
||||
const rawGroupNo = pointGroupMap[pointId]
|
||||
const groupNo = Number(rawGroupNo)
|
||||
if (!Number.isInteger(groupNo) || groupNo <= 0) return
|
||||
|
||||
const groupPointIds = groupedPointMap.get(groupNo) || []
|
||||
groupPointIds.push(pointId)
|
||||
groupedPointMap.set(groupNo, groupPointIds)
|
||||
})
|
||||
|
||||
return {
|
||||
groups: Array.from(groupedPointMap.entries())
|
||||
.sort(([groupNoA], [groupNoB]) => groupNoA - groupNoB)
|
||||
.map(([groupNo, pointIds]) => ({
|
||||
groupNo,
|
||||
pointIds
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
export const checkReportTaskGroupingCompleted = (
|
||||
pointList: ReportTask.ReportTaskPointRecord[],
|
||||
payload: ReportTask.ReportTaskGroupSaveRequest | null | undefined
|
||||
) => {
|
||||
if (!pointList.length || !payload?.groups?.length) return false
|
||||
|
||||
const pointIds = pointList.map(point => String(point.id || '').trim()).filter(Boolean)
|
||||
if (!pointIds.length) return false
|
||||
|
||||
const groupedIds = payload.groups.flatMap(group => group.pointIds.map(pointId => String(pointId || '').trim()).filter(Boolean))
|
||||
if (groupedIds.length !== pointIds.length) return false
|
||||
|
||||
const uniqueGroupedIds = new Set(groupedIds)
|
||||
if (uniqueGroupedIds.size !== pointIds.length) return false
|
||||
|
||||
const pointIdSet = new Set(pointIds)
|
||||
const hasInvalidPointId = Array.from(uniqueGroupedIds).some(pointId => !pointIdSet.has(pointId))
|
||||
if (hasInvalidPointId) return false
|
||||
|
||||
return payload.groups.every(group => Number.isInteger(group.groupNo) && group.groupNo > 0 && group.pointIds.length > 0)
|
||||
}
|
||||
|
||||
export const resolveReportTaskCreateUnitText = (
|
||||
value: string | null | undefined,
|
||||
companyLabelMap: Record<string, string>
|
||||
) => {
|
||||
const text = String(value || '').trim()
|
||||
if (!text) return '-'
|
||||
|
||||
return companyLabelMap[text] || text
|
||||
}
|
||||
|
||||
export const resolveReportTaskStandardText = (
|
||||
value: string[] | string | null | undefined,
|
||||
standardLabelMap: Record<string, string>
|
||||
) => {
|
||||
const standardIds = parseReportTaskStandardIds(value)
|
||||
if (!standardIds.length) return resolveReportTaskText(value)
|
||||
|
||||
return standardIds.map(item => standardLabelMap[item] || item).join('、') || '-'
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import type { ReportTask } from '@/api/aireport/testReport/interface'
|
||||
import { generateUUID } from '@/utils'
|
||||
import { normalizeReportTaskLedgerSnapshot, parseReportTaskStandardIds, stringifyReportTaskStandardIds } from './testReport'
|
||||
|
||||
export interface ReportTaskFormModel {
|
||||
id: string
|
||||
no: string
|
||||
clientUnitId: string
|
||||
reportModelId: string
|
||||
createUnit: string
|
||||
contractNumber: string
|
||||
standardIds: string[]
|
||||
data: string
|
||||
phonenumber: string
|
||||
}
|
||||
|
||||
export const createDefaultReportTaskFormModel = (): ReportTaskFormModel => ({
|
||||
id: '',
|
||||
no: '',
|
||||
clientUnitId: '',
|
||||
reportModelId: '',
|
||||
createUnit: '',
|
||||
contractNumber: '',
|
||||
standardIds: [],
|
||||
data: '',
|
||||
phonenumber: ''
|
||||
})
|
||||
|
||||
export const buildReportTaskDraftId = (mode: 'create' | 'edit', record: ReportTask.ReportTaskRecord | null) => {
|
||||
if (mode === 'edit') {
|
||||
return String(record?.id || '').trim()
|
||||
}
|
||||
|
||||
return window.crypto?.randomUUID?.() || generateUUID()
|
||||
}
|
||||
|
||||
export const buildReportTaskFormContext = (mode: 'create' | 'edit', record: ReportTask.ReportTaskRecord | null) => {
|
||||
const snapshot = normalizeReportTaskLedgerSnapshot(record?.data)
|
||||
const formModel = createDefaultReportTaskFormModel()
|
||||
|
||||
formModel.id = record?.id || ''
|
||||
formModel.no = record?.no || ''
|
||||
formModel.clientUnitId = record?.clientUnitId || ''
|
||||
formModel.reportModelId = record?.reportModelId || ''
|
||||
formModel.createUnit = record?.createUnit || ''
|
||||
formModel.contractNumber = record?.contractNumber || ''
|
||||
formModel.standardIds = parseReportTaskStandardIds(record?.standard)
|
||||
formModel.data = record?.data || ''
|
||||
formModel.phonenumber = record?.phonenumber || ''
|
||||
|
||||
return {
|
||||
formModel,
|
||||
snapshot,
|
||||
draftId: buildReportTaskDraftId(mode, record),
|
||||
hasPreparedImport: Boolean(snapshot || Number(record?.pointCount) > 0)
|
||||
}
|
||||
}
|
||||
|
||||
export const buildReportTaskSavePayload = (
|
||||
draftId: string,
|
||||
formModel: ReportTaskFormModel
|
||||
): ReportTask.ReportTaskSaveRequest => ({
|
||||
id: draftId || formModel.id || undefined,
|
||||
no: formModel.no.trim(),
|
||||
clientUnitId: formModel.clientUnitId,
|
||||
reportModelId: formModel.reportModelId,
|
||||
createUnit: formModel.createUnit,
|
||||
contractNumber: formModel.contractNumber.trim(),
|
||||
standard: stringifyReportTaskStandardIds(formModel.standardIds),
|
||||
data: formModel.data.trim(),
|
||||
phonenumber: formModel.phonenumber.trim() || undefined
|
||||
})
|
||||
@@ -1,180 +1,328 @@
|
||||
<template>
|
||||
<!-- 基础信息弹出框 -->
|
||||
<el-dialog v-model='dialogVisible' :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<div>
|
||||
<el-form :model="formContent"
|
||||
ref='dialogFormRef'
|
||||
:rules='rules'
|
||||
>
|
||||
<el-form-item label="用户名" prop='name' :label-width="100">
|
||||
<el-input v-model="formContent.name" placeholder="请输入用户名" autocomplete="off" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="登录名" prop='loginName' :label-width="100" >
|
||||
<el-input v-model="formContent.loginName" placeholder="请输入登录名" autocomplete="off" :disabled="LoginNameIsShow" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop='password' :label-width="100" v-if="IsPasswordShow">
|
||||
<el-input type="password" v-model="formContent.password" show-password placeholder="请输入密码" autocomplete="off" maxlength="32" show-word-limit/>
|
||||
</el-form-item>
|
||||
<el-form-item label='角色' :label-width='100' prop='roles'>
|
||||
<el-select v-model="formContent.roleIds" multiple placeholder="请选择角色">
|
||||
<el-option
|
||||
v-for="item in roleList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop='phone' :label-width="100">
|
||||
<el-input v-model="formContent.phone" placeholder="请输入手机号码" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱地址" prop='email' :label-width="100">
|
||||
<el-input v-model="formContent.email" placeholder="请输入邮箱地址" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-dialog v-model="dialogVisible" :title="dialogTitle" v-bind="dialogSmall" @close="close" align-center>
|
||||
<el-form ref="dialogFormRef" :model="formContent" :rules="rules">
|
||||
<el-form-item label="用户名" prop="name" :label-width="100">
|
||||
<el-input
|
||||
v-model="formContent.name"
|
||||
placeholder="请输入用户名"
|
||||
autocomplete="off"
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="登录名" prop="loginName" :label-width="100">
|
||||
<el-input
|
||||
v-model="formContent.loginName"
|
||||
placeholder="请输入登录名"
|
||||
autocomplete="off"
|
||||
:disabled="loginNameDisabled"
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="isPasswordShow" label="密码" prop="password" :label-width="100">
|
||||
<el-input
|
||||
v-model="formContent.password"
|
||||
type="password"
|
||||
show-password
|
||||
placeholder="请输入密码"
|
||||
autocomplete="off"
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色" prop="roleIds" :label-width="100">
|
||||
<el-select v-model="formContent.roleIds" multiple placeholder="请选择角色">
|
||||
<el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码" prop="phone" :label-width="100">
|
||||
<el-input v-model="formContent.phone" placeholder="请输入手机号码" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="邮箱地址" prop="email" :label-width="100">
|
||||
<el-input v-model="formContent.email" placeholder="请输入邮箱地址" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="用户签名" :label-width="100">
|
||||
<div class="signature-upload">
|
||||
<el-input :model-value="signatureDisplayName" readonly placeholder="请选择签名文件" />
|
||||
<div class="signature-upload__actions">
|
||||
<el-button type="primary" plain @click="openFilePicker">选择文件</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
:disabled="!canPreviewSignature"
|
||||
@click="handlePreviewSignature"
|
||||
>
|
||||
预览签名
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="signature-upload__tip">支持 png/jpg/jpeg/bmp/webp</div>
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
class="hidden-file-input"
|
||||
type="file"
|
||||
accept=".png,.jpg,.jpeg,.bmp,.webp"
|
||||
@change="handleSignatureFileChange"
|
||||
/>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="close()">取消</el-button>
|
||||
<el-button type="primary" @click="save()">
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="close()">取消</el-button>
|
||||
<el-button type="primary" @click="save()">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed, reactive, ref, type Ref } from 'vue'
|
||||
import { ElMessage, type FormInstance, type FormItemRule } from 'element-plus'
|
||||
import { dialogSmall } from '@/utils/elementBind'
|
||||
import { addUser, previewUserSignature, updateUser } from '@/api/user/user'
|
||||
import type { Role } from '@/api/user/interface/role'
|
||||
import type { User } from '@/api/user/interface/user'
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref,computed, type Ref } from 'vue'
|
||||
import {dialogSmall} from '@/utils/elementBind'
|
||||
import { ElMessage, type FormInstance,type FormItemRule } from 'element-plus'
|
||||
import {
|
||||
addUser,
|
||||
updateUser,
|
||||
} from '@/api/user/user'
|
||||
// 使用 dayjs 库格式化
|
||||
import dayjs from 'dayjs';
|
||||
import { type User } from '@/api/user/interface/user';
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { type Role } from '@/api/user/interface/role';
|
||||
const dictStore = useDictStore()
|
||||
// 定义弹出组件元信息
|
||||
const dialogFormRef = ref()
|
||||
const IsPasswordShow = ref(false)
|
||||
const roleList = ref<Role.RoleBO[]>([])
|
||||
const LoginNameIsShow = ref(false)
|
||||
function useMetaInfo() {
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref('add')
|
||||
const formContent = ref<User.ResUser>({
|
||||
id: '', //用户ID,作为唯一标识
|
||||
name: '', //用户名(别名)
|
||||
loginName: '',//登录名
|
||||
password: '',//密码
|
||||
phone: '', //手机号
|
||||
email: '', //邮箱
|
||||
loginTime: '',//最后一次登录时间
|
||||
loginErrorTimes: 0,//登录错误次数
|
||||
lockTime: '', //用户密码错误锁定时间
|
||||
state: 1, //
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
defineOptions({
|
||||
name: 'UserPopup'
|
||||
})
|
||||
|
||||
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
||||
// 清空formContent
|
||||
const resetFormContent = () => {
|
||||
formContent.value = {
|
||||
id: '', //用户ID,作为唯一标识
|
||||
name: '', //用户名(别名)
|
||||
loginName: '',//登录名
|
||||
password: '',//密码
|
||||
phone: '', //手机号
|
||||
email: '', //邮箱
|
||||
loginTime: '',//最后一次登录时间
|
||||
loginErrorTimes: 0,//登录错误次数
|
||||
lockTime: '', //用户密码错误锁定时间
|
||||
state: 1, //
|
||||
}
|
||||
}
|
||||
const SIGNATURE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'bmp', 'webp']
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
return titleType.value === 'add' ? '新增用户' : '编辑用户'
|
||||
})
|
||||
type UserPopupMode = 'add' | 'edit'
|
||||
|
||||
interface UserFormModel {
|
||||
id: string
|
||||
name: string
|
||||
loginName: string
|
||||
password: string
|
||||
phone: string
|
||||
email: string
|
||||
roleIds: string[]
|
||||
signatureFileId: string
|
||||
signatureFileName: string
|
||||
}
|
||||
|
||||
//定义规则
|
||||
const formRuleRef = ref<FormInstance>()
|
||||
//定义校验规则
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
name: [{ required: true, message: '名称必填!', trigger: 'blur' },
|
||||
// 指定正则,此处是数字正则
|
||||
{ pattern: /^[A-Za-z\u4e00-\u9fa5]{1,16}$/, message: '名称需1~16位的英文或汉字', trigger: 'blur' }],
|
||||
loginName: [{ required: true, message: '登录名必填!', trigger: 'blur' },
|
||||
{ pattern: /^[a-zA-Z]{1}[a-zA-Z0-9]{2,15}$/, message: '格式错误,需以字母开头,长度为3-16位的字母或数字', trigger: 'blur' }],
|
||||
password: [{ required: true, message: '密码必填!', trigger: 'blur' },
|
||||
{ pattern: /^(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,16}$/, message: '密码长度为8-16,需包含特殊字符', trigger: 'blur' }],
|
||||
})
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined
|
||||
}>()
|
||||
|
||||
const dialogFormRef = ref<FormInstance>()
|
||||
const fileInputRef = ref<HTMLInputElement | null>(null)
|
||||
const dialogVisible = ref(false)
|
||||
const titleType = ref<UserPopupMode>('add')
|
||||
const roleList = ref<Role.RoleBO[]>([])
|
||||
const selectedSignatureFile = ref<File | null>(null)
|
||||
const existingSignatureFileName = ref('')
|
||||
const formContent = reactive<UserFormModel>({
|
||||
id: '',
|
||||
name: '',
|
||||
loginName: '',
|
||||
password: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
roleIds: [],
|
||||
signatureFileId: '',
|
||||
signatureFileName: ''
|
||||
})
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
// 清空dialogForm中的值
|
||||
resetFormContent()
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
}
|
||||
const dialogTitle = computed(() => (titleType.value === 'add' ? '新增用户' : '编辑用户'))
|
||||
const isPasswordShow = computed(() => titleType.value === 'add')
|
||||
const loginNameDisabled = computed(() => titleType.value === 'edit')
|
||||
const signatureDisplayName = computed(() => selectedSignatureFile.value?.name || existingSignatureFileName.value || '')
|
||||
const canPreviewSignature = computed(() =>
|
||||
Boolean(selectedSignatureFile.value || (formContent.id && existingSignatureFileName.value))
|
||||
)
|
||||
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
if (formContent.value.id) {
|
||||
await updateUser(formContent.value);
|
||||
} else {
|
||||
await addUser(formContent.value);
|
||||
}
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
close()
|
||||
// 刷新表格
|
||||
await props.refreshTable!()
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
name: [
|
||||
{ required: true, message: '名称必填', trigger: 'blur' },
|
||||
{ pattern: /^[A-Za-z\u4e00-\u9fa5]{1,16}$/, message: '名称需1~16位的英文或汉字', trigger: 'blur' }
|
||||
],
|
||||
loginName: [
|
||||
{ required: true, message: '登录名必填', trigger: 'blur' },
|
||||
{ pattern: /^[a-zA-Z]{1}[a-zA-Z0-9]{2,15}$/, message: '需以字母开头,长度为3-16位字母或数字', trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '密码必填', trigger: 'blur' },
|
||||
{
|
||||
pattern: /^(?=.*[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]).{8,16}$/,
|
||||
message: '密码长度为8-16,需包含特殊字符',
|
||||
trigger: 'blur'
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
console.error('验证过程中出现错误', err)
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: User.ResUser,roleParams: Role.RoleBO[]) => {
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
// 获取角色列表
|
||||
const resetFormContent = () => {
|
||||
formContent.id = ''
|
||||
formContent.name = ''
|
||||
formContent.loginName = ''
|
||||
formContent.password = ''
|
||||
formContent.phone = ''
|
||||
formContent.email = ''
|
||||
formContent.roleIds = []
|
||||
formContent.signatureFileId = ''
|
||||
formContent.signatureFileName = ''
|
||||
}
|
||||
|
||||
const resetSignatureState = () => {
|
||||
selectedSignatureFile.value = null
|
||||
existingSignatureFileName.value = ''
|
||||
|
||||
if (fileInputRef.value) {
|
||||
fileInputRef.value.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
const resetPopupState = () => {
|
||||
resetFormContent()
|
||||
resetSignatureState()
|
||||
dialogFormRef.value?.clearValidate()
|
||||
}
|
||||
|
||||
const validateSignatureFile = (file: File) => {
|
||||
const fileName = file.name || ''
|
||||
const extension = fileName.includes('.') ? fileName.split('.').pop()?.toLowerCase() : ''
|
||||
|
||||
if (!extension || !SIGNATURE_EXTENSIONS.includes(extension)) {
|
||||
return '签名文件仅支持 png、jpg、jpeg、bmp、webp'
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
const buildSaveRequest = (): User.UserSaveRequest => ({
|
||||
id: formContent.id || undefined,
|
||||
name: formContent.name.trim(),
|
||||
loginName: titleType.value === 'add' ? formContent.loginName.trim() : undefined,
|
||||
password: titleType.value === 'add' ? formContent.password : undefined,
|
||||
phone: formContent.phone.trim() || undefined,
|
||||
email: formContent.email.trim() || undefined,
|
||||
roleIds: formContent.roleIds
|
||||
})
|
||||
|
||||
const openBlobPreview = (blob: Blob) => {
|
||||
const previewUrl = URL.createObjectURL(blob)
|
||||
window.open(previewUrl, '_blank')
|
||||
window.setTimeout(() => URL.revokeObjectURL(previewUrl), 60 * 1000)
|
||||
}
|
||||
|
||||
const openFilePicker = () => {
|
||||
fileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const handleSignatureFileChange = (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0] || null
|
||||
|
||||
input.value = ''
|
||||
if (!file) return
|
||||
|
||||
const validationMessage = validateSignatureFile(file)
|
||||
if (validationMessage) {
|
||||
ElMessage.warning(validationMessage)
|
||||
return
|
||||
}
|
||||
|
||||
selectedSignatureFile.value = file
|
||||
}
|
||||
|
||||
const handlePreviewSignature = async () => {
|
||||
try {
|
||||
if (selectedSignatureFile.value) {
|
||||
openBlobPreview(selectedSignatureFile.value)
|
||||
return
|
||||
}
|
||||
|
||||
if (!formContent.id || !existingSignatureFileName.value) {
|
||||
ElMessage.warning('当前用户暂无可预览的签名')
|
||||
return
|
||||
}
|
||||
|
||||
const response = await previewUserSignature(formContent.id)
|
||||
openBlobPreview(response.data)
|
||||
} catch {
|
||||
ElMessage.error('用户签名预览失败')
|
||||
}
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
resetPopupState()
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
try {
|
||||
await dialogFormRef.value?.validate()
|
||||
|
||||
// 关键业务节点:编辑用户时如果未重新选择签名文件,则只提交 request,后端会保留原签名;选了新文件才会触发替换。
|
||||
if (formContent.id) {
|
||||
await updateUser(buildSaveRequest(), selectedSignatureFile.value)
|
||||
} else {
|
||||
await addUser(buildSaveRequest(), selectedSignatureFile.value)
|
||||
}
|
||||
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功` })
|
||||
close()
|
||||
await props.refreshTable?.()
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const open = async (sign: string, data: Partial<User.ResUser> = {}, roleParams: Role.RoleBO[]) => {
|
||||
resetPopupState()
|
||||
roleList.value = roleParams
|
||||
titleType.value = sign
|
||||
titleType.value = sign === 'edit' ? 'edit' : 'add'
|
||||
dialogVisible.value = true
|
||||
|
||||
if (data.id) {
|
||||
IsPasswordShow.value = false
|
||||
LoginNameIsShow.value = true
|
||||
formContent.value = { ...data }
|
||||
|
||||
|
||||
} else {
|
||||
IsPasswordShow.value = true
|
||||
LoginNameIsShow.value = false
|
||||
resetFormContent()
|
||||
formContent.id = data.id
|
||||
formContent.name = data.name || ''
|
||||
formContent.loginName = data.loginName || ''
|
||||
formContent.password = ''
|
||||
formContent.phone = data.phone || ''
|
||||
formContent.email = data.email || ''
|
||||
formContent.roleIds = Array.isArray(data.roleIds) ? [...data.roleIds] : []
|
||||
formContent.signatureFileId = data.signatureFileId || ''
|
||||
formContent.signatureFileName = data.signatureFileName || ''
|
||||
existingSignatureFileName.value = data.signatureFileName || ''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined;
|
||||
}>()
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.signature-upload {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
</script>
|
||||
.signature-upload__actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.signature-upload__tip {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-select),
|
||||
:deep(.el-input) {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,612 @@
|
||||
# check-square API 调试文档
|
||||
|
||||
## 1. 模块说明
|
||||
|
||||
- 模块路径:`steady/check-square`
|
||||
- 接口基础路径:`/steady/checksquare`
|
||||
- 返回包装:接口统一返回 `HttpResult<T>`,调试时重点查看响应体中的 `data`
|
||||
- 时间格式:`yyyy-MM-dd HH:mm:ss`
|
||||
- Content-Type:`application/json`
|
||||
|
||||
本模块用于按监测点、时间范围和指标执行稳态数据校验,并提供任务列表、任务详情、检测项明细查询、失败任务重启和任务删除能力。
|
||||
|
||||
当前标准统一使用 `lineIds` 表示任务监测点列表。单监测点也传单元素数组,例如:
|
||||
|
||||
```json
|
||||
{
|
||||
"lineIds": ["LINE_001"]
|
||||
}
|
||||
```
|
||||
|
||||
## 2. 通用枚举
|
||||
|
||||
### 2.1 任务状态
|
||||
|
||||
| 值 | 说明 |
|
||||
| --- | --- |
|
||||
| `RUNNING` | 执行中 |
|
||||
| `SUCCESS` | 执行成功 |
|
||||
| `FAIL` | 执行失败 |
|
||||
|
||||
### 2.2 明细类型
|
||||
|
||||
| 值 | 说明 |
|
||||
| --- | --- |
|
||||
| `SEGMENT` | 连续性区间,包含正常区间和缺失区间 |
|
||||
| `VALUE_ORDER` | 指标值大小关系异常明细 |
|
||||
| `HARMONIC_PARITY` | 谐波奇偶关系异常明细 |
|
||||
|
||||
### 2.3 统计类型
|
||||
|
||||
| 值 | 说明 |
|
||||
| --- | --- |
|
||||
| `AVG` | 平均值 |
|
||||
| `MAX` | 最大值 |
|
||||
| `MIN` | 最小值 |
|
||||
| `CP95` | CP95 值 |
|
||||
|
||||
## 3. 调试顺序
|
||||
|
||||
1. 调用 `POST /steady/checksquare/create`,按监测点列表、时间范围和指标列表创建或复用任务。
|
||||
2. 读取 `/create` 返回的 `data.taskId`。
|
||||
3. 如果 `taskStatus=RUNNING`,轮询 `POST /steady/checksquare/query`,或稍后调用 `GET /steady/checksquare/detail` 查看任务详情。
|
||||
4. 调用 `GET /steady/checksquare/detail`,用 `taskId` 查询任务下的检测项。
|
||||
5. 读取 `/detail` 返回的 `items[].itemId`。
|
||||
6. 调用 `GET /steady/checksquare/item-detail`,按 `itemId + detailType` 查询具体明细。
|
||||
7. 任务失败后如需重新执行,调用 `POST /steady/checksquare/restart`。
|
||||
8. 需要清理任务时调用 `POST /steady/checksquare/delete`。
|
||||
|
||||
## 4. 创建或复用任务
|
||||
|
||||
### 4.1 接口
|
||||
|
||||
`POST /steady/checksquare/create`
|
||||
|
||||
### 4.2 行为说明
|
||||
|
||||
接口执行前会先按 `lineIds + timeStart + timeEnd` 查询是否存在未删除任务:
|
||||
|
||||
- 已存在:直接返回该任务的任务列表行信息,不生成重复任务。
|
||||
- 不存在:创建 `RUNNING` 任务并立即返回任务列表行信息,后台继续执行校验。
|
||||
|
||||
`lineIds` 会去重并清理空字符串。任务执行成功后状态更新为 `SUCCESS`,失败时更新为 `FAIL`。
|
||||
|
||||
### 4.3 请求字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `lineIds` | `Array<String>` | 是 | 监测点 ID 列表;单监测点也传单元素数组 |
|
||||
| `indicatorCodes` | `Array<String>` | 是 | 指标编码列表 |
|
||||
| `timeStart` | `String` | 是 | 开始时间,格式 `yyyy-MM-dd HH:mm:ss` |
|
||||
| `timeEnd` | `String` | 是 | 结束时间,格式 `yyyy-MM-dd HH:mm:ss` |
|
||||
|
||||
`indicatorCodes` 是数组,不要传成单个字符串。
|
||||
|
||||
### 4.4 请求示例
|
||||
|
||||
单监测点:
|
||||
|
||||
```http
|
||||
POST /steady/checksquare/create
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"lineIds": ["LINE_001"],
|
||||
"indicatorCodes": ["VOLTAGE_A", "CURRENT_A"],
|
||||
"timeStart": "2026-06-18 00:00:00",
|
||||
"timeEnd": "2026-06-18 01:00:00"
|
||||
}
|
||||
```
|
||||
|
||||
多监测点:
|
||||
|
||||
```json
|
||||
{
|
||||
"lineIds": ["LINE_001", "LINE_002"],
|
||||
"indicatorCodes": ["VOLTAGE_A", "CURRENT_A"],
|
||||
"timeStart": "2026-06-18 00:00:00",
|
||||
"timeEnd": "2026-06-18 01:00:00"
|
||||
}
|
||||
```
|
||||
|
||||
### 4.5 响应字段 `data`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `taskId` | `String` | 任务 ID |
|
||||
| `taskNo` | `String` | 任务编号 |
|
||||
| `lineIds` | `Array<String>` | 本次任务的监测点 ID 列表 |
|
||||
| `lineName` | `String` | 监测点名称;多监测点时为多个名称拼接结果 |
|
||||
| `timeStart` | `String` | 开始时间 |
|
||||
| `timeEnd` | `String` | 结束时间 |
|
||||
| `intervalMinutes` | `Integer` | 统计间隔,单位分钟 |
|
||||
| `taskStatus` | `String` | 任务状态:`RUNNING`、`SUCCESS`、`FAIL` |
|
||||
| `itemCount` | `Integer` | 检测项数量 |
|
||||
| `abnormalItemCount` | `Integer` | 异常检测项数量 |
|
||||
| `minDataIntegrity` | `BigDecimal` | 最低数据完整性,0 到 1 的小数 |
|
||||
| `createTime` | `String` | 创建时间 |
|
||||
|
||||
### 4.6 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"taskId": "1812345678901234567",
|
||||
"taskNo": "CS202606180001",
|
||||
"lineIds": ["LINE_001", "LINE_002"],
|
||||
"lineName": "1号监测点,2号监测点",
|
||||
"timeStart": "2026-06-18 00:00:00",
|
||||
"timeEnd": "2026-06-18 01:00:00",
|
||||
"intervalMinutes": 1,
|
||||
"taskStatus": "RUNNING",
|
||||
"itemCount": 0,
|
||||
"abnormalItemCount": 0,
|
||||
"minDataIntegrity": 0.000000,
|
||||
"createTime": "2026-06-18 09:30:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 查询任务列表
|
||||
|
||||
### 5.1 接口
|
||||
|
||||
`POST /steady/checksquare/query`
|
||||
|
||||
### 5.2 请求字段
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `lineId` | `String` | 否 | 监测点 ID;后端按任务的 `lineIds` 检索文本匹配 |
|
||||
| `indicatorCode` | `String` | 否 | 指标编码;后端按任务的指标编码检索文本匹配 |
|
||||
| `timeStart` | `String` | 否 | 检测开始时间,格式 `yyyy-MM-dd HH:mm:ss` |
|
||||
| `timeEnd` | `String` | 否 | 检测结束时间,格式 `yyyy-MM-dd HH:mm:ss` |
|
||||
| `hasAbnormal` | `Boolean` | 否 | 是否存在异常;传 `true` 时仅查询异常检测项数量大于 0 的任务 |
|
||||
| `pageNum` | `Integer` | 否 | 页码 |
|
||||
| `pageSize` | `Integer` | 否 | 每页条数 |
|
||||
|
||||
`indicatorCode` 是单个字符串,用于历史任务筛选;和 `/create` 的 `indicatorCodes` 数组不同。
|
||||
|
||||
### 5.3 请求示例
|
||||
|
||||
```http
|
||||
POST /steady/checksquare/query
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"lineId": "LINE_001",
|
||||
"indicatorCode": "VOLTAGE_A",
|
||||
"timeStart": "2026-06-18 00:00:00",
|
||||
"timeEnd": "2026-06-18 23:59:59",
|
||||
"hasAbnormal": true,
|
||||
"pageNum": 1,
|
||||
"pageSize": 10
|
||||
}
|
||||
```
|
||||
|
||||
### 5.4 响应说明
|
||||
|
||||
`data` 为 MyBatis-Plus `Page<SteadyChecksquareTaskVO>` 分页对象,常用字段如下:
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `records` | `Array<Object>` | 任务列表,每项字段同 `/create` 返回的 `SteadyChecksquareTaskVO` |
|
||||
| `total` | `Long` | 总记录数 |
|
||||
| `size` | `Long` | 每页条数 |
|
||||
| `current` | `Long` | 当前页码 |
|
||||
| `pages` | `Long` | 总页数 |
|
||||
|
||||
### 5.5 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"records": [
|
||||
{
|
||||
"taskId": "1812345678901234567",
|
||||
"taskNo": "CS202606180001",
|
||||
"lineIds": ["LINE_001", "LINE_002"],
|
||||
"lineName": "1号监测点,2号监测点",
|
||||
"timeStart": "2026-06-18 00:00:00",
|
||||
"timeEnd": "2026-06-18 01:00:00",
|
||||
"intervalMinutes": 1,
|
||||
"taskStatus": "SUCCESS",
|
||||
"itemCount": 4,
|
||||
"abnormalItemCount": 1,
|
||||
"minDataIntegrity": 0.985000,
|
||||
"createTime": "2026-06-18 09:30:00"
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"size": 10,
|
||||
"current": 1,
|
||||
"pages": 1
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 6. 查询任务详情
|
||||
|
||||
### 6.1 接口
|
||||
|
||||
`GET /steady/checksquare/detail?taskId={taskId}`
|
||||
|
||||
### 6.2 请求参数
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `taskId` | `String` | 是 | 任务 ID |
|
||||
|
||||
### 6.3 请求示例
|
||||
|
||||
```http
|
||||
GET /steady/checksquare/detail?taskId=1812345678901234567
|
||||
```
|
||||
|
||||
### 6.4 响应字段 `data`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `taskId` | `String` | 任务 ID |
|
||||
| `taskNo` | `String` | 任务编号 |
|
||||
| `lineIds` | `Array<String>` | 本次任务的监测点 ID 列表 |
|
||||
| `lineName` | `String` | 监测点名称 |
|
||||
| `timeStart` | `String` | 开始时间 |
|
||||
| `timeEnd` | `String` | 结束时间 |
|
||||
| `intervalMinutes` | `Integer` | 统计间隔,单位分钟 |
|
||||
| `items` | `Array<Object>` | 检测项列表 |
|
||||
|
||||
### 6.5 检测项字段 `items[]`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `itemId` | `String` | 检测项 ID,用于查询明细 |
|
||||
| `itemKey` | `String` | 检测项唯一键 |
|
||||
| `lineId` | `String` | 当前检测项所属监测点 ID |
|
||||
| `lineName` | `String` | 当前检测项所属监测点名称 |
|
||||
| `indicatorCode` | `String` | 指标编码 |
|
||||
| `indicatorName` | `String` | 指标名称 |
|
||||
| `harmonicOrder` | `Integer` | 谐波次数;非谐波或聚合项可为空 |
|
||||
| `intervalMinutes` | `Integer` | 当前检测项统计间隔,单位分钟 |
|
||||
| `hasData` | `Boolean` | 时间范围内是否存在任意数据 |
|
||||
| `expectedPointCount` | `Integer` | 期望点数 |
|
||||
| `actualPointCount` | `Integer` | 实际点数 |
|
||||
| `missingPointCount` | `Integer` | 缺失点数 |
|
||||
| `dataIntegrity` | `BigDecimal` | 数据完整性,0 到 1 的小数 |
|
||||
| `dataIntegrityText` | `String` | 数据完整性文本 |
|
||||
| `abnormal` | `Boolean` | 指标值大小关系是否异常 |
|
||||
| `abnormalPointCount` | `Integer` | 指标值大小关系异常点数 |
|
||||
| `abnormalDetails` | `Array<Object>` | 指标值大小关系异常明细摘要 |
|
||||
| `harmonicParityAbnormal` | `Boolean` | 谐波奇偶关系是否异常 |
|
||||
| `harmonicParityAbnormalPointCount` | `Integer` | 谐波奇偶关系异常点数 |
|
||||
| `harmonicParityAbnormalDetails` | `Array<Object>` | 谐波奇偶关系异常明细摘要 |
|
||||
| `statSummaries` | `Array<Object>` | 统计类型摘要 |
|
||||
| `statDetails` | `Array<Object>` | 统计类型明细 |
|
||||
|
||||
### 6.6 统计摘要字段 `statSummaries[]`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `statType` | `String` | 统计类型:`AVG`、`MAX`、`MIN`、`CP95` |
|
||||
| `supported` | `Boolean` | 是否支持该统计类型 |
|
||||
| `hasData` | `Boolean` | 是否存在数据 |
|
||||
| `expectedPointCount` | `Integer` | 期望点数 |
|
||||
| `actualPointCount` | `Integer` | 实际点数 |
|
||||
| `missingPointCount` | `Integer` | 缺失点数 |
|
||||
| `dataIntegrity` | `BigDecimal` | 数据完整性 |
|
||||
| `dataIntegrityText` | `String` | 数据完整性文本 |
|
||||
|
||||
### 6.7 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"taskId": "1812345678901234567",
|
||||
"taskNo": "CS202606180001",
|
||||
"lineIds": ["LINE_001", "LINE_002"],
|
||||
"lineName": "1号监测点,2号监测点",
|
||||
"timeStart": "2026-06-18 00:00:00",
|
||||
"timeEnd": "2026-06-18 01:00:00",
|
||||
"intervalMinutes": 1,
|
||||
"items": [
|
||||
{
|
||||
"itemId": "1812345678901234568",
|
||||
"itemKey": "LINE_001|VOLTAGE_A",
|
||||
"lineId": "LINE_001",
|
||||
"lineName": "1号监测点",
|
||||
"indicatorCode": "VOLTAGE_A",
|
||||
"indicatorName": "A相电压",
|
||||
"harmonicOrder": null,
|
||||
"intervalMinutes": 1,
|
||||
"hasData": true,
|
||||
"expectedPointCount": 60,
|
||||
"actualPointCount": 59,
|
||||
"missingPointCount": 1,
|
||||
"dataIntegrity": 0.983333,
|
||||
"dataIntegrityText": "98.33%",
|
||||
"abnormal": true,
|
||||
"abnormalPointCount": 1,
|
||||
"abnormalDetails": [],
|
||||
"harmonicParityAbnormal": false,
|
||||
"harmonicParityAbnormalPointCount": 0,
|
||||
"harmonicParityAbnormalDetails": [],
|
||||
"statSummaries": [
|
||||
{
|
||||
"statType": "AVG",
|
||||
"supported": true,
|
||||
"hasData": true,
|
||||
"expectedPointCount": 60,
|
||||
"actualPointCount": 59,
|
||||
"missingPointCount": 1,
|
||||
"dataIntegrity": 0.983333,
|
||||
"dataIntegrityText": "98.33%"
|
||||
}
|
||||
],
|
||||
"statDetails": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 7. 查询检测项明细
|
||||
|
||||
### 7.1 接口
|
||||
|
||||
`GET /steady/checksquare/item-detail`
|
||||
|
||||
### 7.2 请求参数
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `itemId` | `String` | 是 | 检测项 ID |
|
||||
| `detailType` | `String` | 是 | 明细类型:`SEGMENT`、`VALUE_ORDER`、`HARMONIC_PARITY` |
|
||||
| `statType` | `String` | 否 | 统计类型;查询统计类型连续性或谐波奇偶明细时使用 |
|
||||
| `pageNum` | `Integer` | 否 | 页码;和 `pageSize` 同时为正整数时启用分页 |
|
||||
| `pageSize` | `Integer` | 否 | 每页条数;和 `pageNum` 同时为正整数时启用分页 |
|
||||
|
||||
### 7.3 请求示例
|
||||
|
||||
查询连续性区间:
|
||||
|
||||
```http
|
||||
GET /steady/checksquare/item-detail?itemId=1812345678901234568&detailType=SEGMENT&pageNum=1&pageSize=10
|
||||
```
|
||||
|
||||
查询大小关系异常:
|
||||
|
||||
```http
|
||||
GET /steady/checksquare/item-detail?itemId=1812345678901234568&detailType=VALUE_ORDER&pageNum=1&pageSize=10
|
||||
```
|
||||
|
||||
查询谐波奇偶关系异常:
|
||||
|
||||
```http
|
||||
GET /steady/checksquare/item-detail?itemId=1812345678901234568&detailType=HARMONIC_PARITY&statType=AVG&pageNum=1&pageSize=10
|
||||
```
|
||||
|
||||
### 7.4 响应字段 `data`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `itemId` | `String` | 检测项 ID |
|
||||
| `lineId` | `String` | 当前检测项所属监测点 ID |
|
||||
| `lineName` | `String` | 当前检测项所属监测点名称 |
|
||||
| `detailType` | `String` | 明细类型 |
|
||||
| `statType` | `String` | 统计类型 |
|
||||
| `pageNum` | `Integer` | 当前页码;未分页查询时为空 |
|
||||
| `pageSize` | `Integer` | 每页条数;未分页查询时为空 |
|
||||
| `total` | `Long` | 总记录数;未分页查询时为空 |
|
||||
| `segments` | `Array<Object>` | 连续性区间,`detailType=SEGMENT` 时查看 |
|
||||
| `valueOrderDetails` | `Array<Object>` | 指标值大小关系异常明细,`detailType=VALUE_ORDER` 时查看 |
|
||||
| `harmonicParityDetails` | `Array<Object>` | 谐波奇偶关系异常明细,`detailType=HARMONIC_PARITY` 时查看 |
|
||||
|
||||
### 7.5 连续性区间字段 `segments[]`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `startTime` | `String` | 区间开始时间 |
|
||||
| `endTime` | `String` | 区间结束时间 |
|
||||
| `status` | `String` | 区间状态:`NORMAL`、`MISSING` |
|
||||
| `harmonicOrder` | `Integer` | 谐波次数 |
|
||||
| `missingPointCount` | `Integer` | 缺失点数 |
|
||||
| `durationMinutes` | `Integer` | 持续时长,单位分钟 |
|
||||
|
||||
### 7.6 大小关系异常字段 `valueOrderDetails[]`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `time` | `String` | 异常点时间 |
|
||||
| `phase` | `String` | 相别 |
|
||||
| `harmonicOrder` | `Integer` | 谐波次数 |
|
||||
| `maxValue` | `BigDecimal` | 最大值 |
|
||||
| `minValue` | `BigDecimal` | 最小值 |
|
||||
| `avgValue` | `BigDecimal` | 平均值 |
|
||||
| `cp95Value` | `BigDecimal` | CP95 值 |
|
||||
|
||||
### 7.7 谐波奇偶关系异常字段 `harmonicParityDetails[]`
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `time` | `String` | 异常点时间 |
|
||||
| `phase` | `String` | 相别 |
|
||||
| `statType` | `String` | 统计类型 |
|
||||
| `evenHarmonicOrder` | `Integer` | 偶次谐波次数 |
|
||||
| `evenValue` | `BigDecimal` | 偶次谐波值 |
|
||||
| `oddHarmonicOrders` | `Array<Integer>` | 参与比较的奇次谐波次数 |
|
||||
| `oddValues` | `Array<BigDecimal>` | 参与比较的奇次谐波值 |
|
||||
| `oddMedianValue` | `BigDecimal` | 奇次谐波中位数 |
|
||||
| `thresholdMultiplier` | `BigDecimal` | 异常阈值倍数 |
|
||||
|
||||
### 7.8 响应示例
|
||||
|
||||
连续性区间:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"itemId": "1812345678901234568",
|
||||
"lineId": "LINE_001",
|
||||
"lineName": "1号监测点",
|
||||
"detailType": "SEGMENT",
|
||||
"statType": null,
|
||||
"pageNum": 1,
|
||||
"pageSize": 10,
|
||||
"total": 1,
|
||||
"segments": [
|
||||
{
|
||||
"startTime": "2026-06-18 00:10:00",
|
||||
"endTime": "2026-06-18 00:10:00",
|
||||
"status": "MISSING",
|
||||
"harmonicOrder": null,
|
||||
"missingPointCount": 1,
|
||||
"durationMinutes": 1
|
||||
}
|
||||
],
|
||||
"valueOrderDetails": [],
|
||||
"harmonicParityDetails": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
大小关系异常:
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"itemId": "1812345678901234568",
|
||||
"lineId": "LINE_001",
|
||||
"lineName": "1号监测点",
|
||||
"detailType": "VALUE_ORDER",
|
||||
"statType": null,
|
||||
"pageNum": 1,
|
||||
"pageSize": 10,
|
||||
"total": 1,
|
||||
"segments": [],
|
||||
"valueOrderDetails": [
|
||||
{
|
||||
"time": "2026-06-18 00:20:00",
|
||||
"phase": "A",
|
||||
"harmonicOrder": null,
|
||||
"maxValue": 231.12000000,
|
||||
"minValue": 228.45000000,
|
||||
"avgValue": 229.64000000,
|
||||
"cp95Value": 230.98000000
|
||||
}
|
||||
],
|
||||
"harmonicParityDetails": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 8. 重启失败任务
|
||||
|
||||
### 8.1 接口
|
||||
|
||||
`POST /steady/checksquare/restart?taskId={taskId}`
|
||||
|
||||
### 8.2 行为说明
|
||||
|
||||
- 仅允许重启 `taskStatus=FAIL` 的任务。
|
||||
- 重启复用原任务记录,`taskId` 不变。
|
||||
- 重启前会清理该任务旧的检测项、统计摘要和明细数据,避免重复结果键。
|
||||
- 接口返回时任务状态已更新为 `RUNNING`。
|
||||
|
||||
### 8.3 请求参数
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `taskId` | `String` | 是 | 失败任务 ID |
|
||||
|
||||
### 8.4 请求示例
|
||||
|
||||
```http
|
||||
POST /steady/checksquare/restart?taskId=1812345678901234567
|
||||
```
|
||||
|
||||
### 8.5 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": {
|
||||
"taskId": "1812345678901234567",
|
||||
"taskNo": "CS202606180001",
|
||||
"lineIds": ["LINE_001", "LINE_002"],
|
||||
"lineName": "1号监测点,2号监测点",
|
||||
"timeStart": "2026-06-18 00:00:00",
|
||||
"timeEnd": "2026-06-18 01:00:00",
|
||||
"intervalMinutes": 1,
|
||||
"taskStatus": "RUNNING",
|
||||
"itemCount": 0,
|
||||
"abnormalItemCount": 0,
|
||||
"minDataIntegrity": 0.000000,
|
||||
"createTime": "2026-06-18 09:30:00"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 9. 删除任务
|
||||
|
||||
### 9.1 接口
|
||||
|
||||
`POST /steady/checksquare/delete`
|
||||
|
||||
### 9.2 请求字段
|
||||
|
||||
请求体直接传任务 ID 数组。
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `taskIds` | `Array<String>` | 是 | 任务 ID 数组 |
|
||||
|
||||
### 9.3 请求示例
|
||||
|
||||
```http
|
||||
POST /steady/checksquare/delete
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
```json
|
||||
[
|
||||
"1812345678901234567"
|
||||
]
|
||||
```
|
||||
|
||||
### 9.4 响应示例
|
||||
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": true
|
||||
}
|
||||
```
|
||||
|
||||
## 10. 调试注意事项
|
||||
|
||||
- `/create` 只接收 `lineIds`,不再接收任务级 `lineId`。
|
||||
- 单监测点也传 `lineIds` 单元素数组。
|
||||
- `/create` 如果命中已存在任务,会直接返回该任务,不生成重复任务。
|
||||
- `/query` 的 `lineId` 是筛选条件,会匹配任务内的 `lineIds`。
|
||||
- 任务级返回字段使用 `lineIds`;检测项级 `items[].lineId` 表示该检测项实际所属监测点。
|
||||
- `/detail` 需要使用 `/create`、`/restart` 或 `/query` 返回的 `taskId`。
|
||||
- `/item-detail` 需要使用 `/detail` 返回的 `items[].itemId`。
|
||||
- `/item-detail` 只有 `pageNum` 和 `pageSize` 同时为正整数时才分页;否则返回全部匹配明细,分页字段为空。
|
||||
- `/restart` 只允许重启失败任务,成功或执行中的任务调用会返回业务失败。
|
||||
- `dataIntegrity` 是 0 到 1 的小数,展示百分比优先使用 `dataIntegrityText`。
|
||||
@@ -0,0 +1,280 @@
|
||||
<template>
|
||||
<aside class="table-main card checksquare-result-panel">
|
||||
<div class="table-header">
|
||||
<div class="header-button-lf">
|
||||
<span class="section-title">校验任务摘要</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="create-loading">
|
||||
<el-icon class="create-loading__icon"><Loading /></el-icon>
|
||||
<span class="create-loading__title">正在创建校验任务</span>
|
||||
<span class="create-loading__desc">任务提交后将在此显示摘要</span>
|
||||
</div>
|
||||
|
||||
<el-empty v-else-if="!task" class="empty-result" description="新增后在此查看任务摘要" />
|
||||
|
||||
<template v-else>
|
||||
<div class="result-scroll">
|
||||
<div class="result-body">
|
||||
<div class="result-overview">
|
||||
<div class="task-card">
|
||||
<div class="task-title">
|
||||
<span>{{ task.taskNo || task.taskId || '-' }}</span>
|
||||
<el-tag :type="resolveChecksquareTaskStatusType(task.taskStatus)" effect="plain">
|
||||
{{ formatChecksquareTaskStatus(task.taskStatus) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="task-meta">
|
||||
<span>{{ task.lineName || task.lineId || '-' }}</span>
|
||||
<span>{{ task.timeStart || '-' }} 至 {{ task.timeEnd || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="result-metrics">
|
||||
<div class="metric-item">
|
||||
<span class="metric-label">进线/监测点</span>
|
||||
<span class="metric-value">{{ task.lineName || task.lineId || '-' }}</span>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<span class="metric-label">检测项</span>
|
||||
<span class="metric-value">{{ displayItemCount }}</span>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<span class="metric-label">异常项</span>
|
||||
<span class="metric-value is-danger">{{ task.abnormalItemCount ?? '-' }}</span>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<span class="metric-label">最低完整率</span>
|
||||
<span class="metric-value">
|
||||
{{ formatChecksquareIntegrity(task.minDataIntegrity) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="metric-item">
|
||||
<span class="metric-label">统计间隔</span>
|
||||
<span class="metric-value">{{ task.intervalMinutes ?? '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="result-detail-grid">
|
||||
<div class="detail-block">
|
||||
<span class="detail-label">校验时间</span>
|
||||
<span class="detail-value">{{ task.timeStart || '-' }} 至 {{ task.timeEnd || '-' }}</span>
|
||||
</div>
|
||||
<div class="detail-block">
|
||||
<span class="detail-label">创建时间</span>
|
||||
<span class="detail-value">{{ task.createTime || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</aside>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
import {
|
||||
formatChecksquareIntegrity,
|
||||
formatChecksquareTaskStatus,
|
||||
resolveChecksquareTaskStatusType
|
||||
} from '../utils/checksquareTaskTable'
|
||||
|
||||
defineOptions({
|
||||
name: 'ChecksquareCreateResultPanel'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
task: SteadyDataView.SteadyChecksquareTask | null
|
||||
expectedItemCount: number
|
||||
loading?: boolean
|
||||
}>()
|
||||
|
||||
const displayItemCount = computed(() => {
|
||||
if (Number(props.task?.itemCount || 0) > 0) return props.task?.itemCount
|
||||
if (props.expectedItemCount > 0) return props.expectedItemCount
|
||||
|
||||
return props.task?.itemCount ?? '-'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.checksquare-result-panel {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.empty-result {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.create-loading {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.create-loading__icon {
|
||||
color: var(--el-color-primary);
|
||||
font-size: 28px;
|
||||
animation: rotate-loading 1s linear infinite;
|
||||
}
|
||||
|
||||
.create-loading__title {
|
||||
color: var(--el-text-color-primary);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.create-loading__desc {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@keyframes rotate-loading {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.result-body {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.result-scroll {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.result-overview {
|
||||
display: grid;
|
||||
flex: none;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.task-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.task-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.task-title span:first-child,
|
||||
.task-meta span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.task-meta {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.result-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 8px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.metric-label,
|
||||
.detail-label {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.metric-value,
|
||||
.detail-value {
|
||||
overflow: hidden;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.metric-value.is-danger {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
|
||||
.result-detail-grid {
|
||||
display: grid;
|
||||
flex: none;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.detail-block {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
padding: 12px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
background: var(--el-fill-color-blank);
|
||||
}
|
||||
|
||||
.detail-value {
|
||||
font-size: 13px;
|
||||
white-space: normal;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.result-metrics {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,48 +1,144 @@
|
||||
<template>
|
||||
<section class="card checksquare-detail">
|
||||
<div class="detail-header">
|
||||
<div>
|
||||
<div class="section-title">连续性详情</div>
|
||||
<div class="section-description">
|
||||
{{ selectedItem ? resolveChecksquareRowName(selectedItem) : '请选择总览表中的指标' }}
|
||||
<section class="table-main card checksquare-detail">
|
||||
<el-empty v-if="!selectedItem" description="请选择指标查看明细" />
|
||||
|
||||
<el-tabs v-else v-model="detailType" class="detail-tabs" @tab-change="handleDetailTypeChange">
|
||||
<el-tab-pane label="缺数区间" name="SEGMENT">
|
||||
<div class="item-overview">
|
||||
<div class="overview-item">
|
||||
<span class="overview-label">数据完整性</span>
|
||||
<span class="overview-value">
|
||||
{{ formatDataIntegrity(selectedItem.dataIntegrity, selectedItem.dataIntegrityText) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="overview-item">
|
||||
<span class="overview-label">期望点数</span>
|
||||
<span class="overview-value">{{ selectedItem.expectedPointCount ?? '-' }}</span>
|
||||
</div>
|
||||
<div class="overview-item">
|
||||
<span class="overview-label">实际点数</span>
|
||||
<span class="overview-value">{{ selectedItem.actualPointCount ?? '-' }}</span>
|
||||
</div>
|
||||
<div class="overview-item">
|
||||
<span class="overview-label">缺失点数</span>
|
||||
<span class="overview-value">{{ selectedItem.missingPointCount ?? '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-empty v-if="!selectedItem" description="请选择指标查看缺失区间" />
|
||||
|
||||
<template v-else>
|
||||
<div class="stat-grid">
|
||||
<div v-for="statType in CHECKSQUARE_STAT_TYPES" :key="statType" class="stat-card">
|
||||
<span class="stat-name">{{ formatChecksquareStatType(statType) }}</span>
|
||||
<span class="stat-value">{{ formatStatMissingRate(selectedItem, statType) }}</span>
|
||||
<div class="stat-grid">
|
||||
<div v-for="statType in CHECKSQUARE_STAT_TYPES" :key="statType" class="stat-card">
|
||||
<span class="stat-name">{{ formatChecksquareStatType(statType) }}</span>
|
||||
<span class="stat-value">{{ formatStatMissingRate(selectedItem, statType) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-table class="segment-table" :data="segments" size="small" max-height="220" empty-text="暂无缺失区间">
|
||||
<el-table-column prop="statType" label="统计类型" width="96">
|
||||
<template #default="{ row }">{{ formatChecksquareStatType(row.statType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="startTime" label="开始时间" min-width="160" />
|
||||
<el-table-column prop="endTime" label="结束时间" min-width="160" />
|
||||
<el-table-column prop="missingPointCount" label="缺失点数" width="100" align="right">
|
||||
<template #default="{ row }">{{ row.missingPointCount ?? '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="durationMinutes" label="持续分钟" width="100" align="right">
|
||||
<template #default="{ row }">{{ row.durationMinutes ?? '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
<div class="segment-toolbar">
|
||||
<el-select v-model="segmentStatType" class="stat-select" @change="handleSegmentStatTypeChange">
|
||||
<el-option v-for="statType in CHECKSQUARE_STAT_TYPES" :key="statType" :label="formatChecksquareStatType(statType)" :value="statType" />
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<el-table v-loading="loading" class="detail-table" :data="segments" height="100%" empty-text="暂无缺数区间">
|
||||
<el-table-column prop="statType" label="统计类型" width="100">
|
||||
<template #default="{ row }">{{ formatChecksquareStatType(row.statType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90">
|
||||
<template #default="{ row }">{{ formatSegmentStatus(row.status) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="startTime" label="开始时间" min-width="170" />
|
||||
<el-table-column prop="endTime" label="结束时间" min-width="170" />
|
||||
<el-table-column prop="harmonicOrder" label="谐波次数" width="100" align="right">
|
||||
<template #default="{ row }">{{ row.harmonicOrder ?? '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="missingPointCount" label="缺失点数" width="110" align="right">
|
||||
<template #default="{ row }">{{ row.missingPointCount ?? '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="durationMinutes" label="持续分钟" width="110" align="right">
|
||||
<template #default="{ row }">{{ row.durationMinutes ?? '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="值关系异常" name="VALUE_ORDER">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
class="detail-table"
|
||||
:data="itemDetail?.valueOrderDetails || []"
|
||||
height="100%"
|
||||
empty-text="暂无值关系异常"
|
||||
>
|
||||
<el-table-column prop="time" label="时间" min-width="160" />
|
||||
<el-table-column prop="phase" label="相别" width="80" />
|
||||
<el-table-column prop="harmonicOrder" label="谐波次数" width="96" align="right">
|
||||
<template #default="{ row }">{{ row.harmonicOrder ?? '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="maxValue" label="最大值" min-width="100" align="right" />
|
||||
<el-table-column prop="cp95Value" label="CP95" min-width="100" align="right" />
|
||||
<el-table-column prop="avgValue" label="平均值" min-width="100" align="right" />
|
||||
<el-table-column prop="minValue" label="最小值" min-width="100" align="right" />
|
||||
</el-table>
|
||||
|
||||
<div v-if="showDetailPagination" class="detail-pagination">
|
||||
<el-pagination
|
||||
background
|
||||
layout="total, prev, pager, next"
|
||||
:current-page="detailPageNum"
|
||||
:page-size="DETAIL_PAGE_SIZE"
|
||||
:total="detailTotal"
|
||||
@current-change="handleDetailPageChange"
|
||||
/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane label="谐波奇偶异常" name="HARMONIC_PARITY">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
class="detail-table"
|
||||
:data="itemDetail?.harmonicParityDetails || []"
|
||||
height="100%"
|
||||
empty-text="暂无谐波奇偶异常"
|
||||
>
|
||||
<el-table-column prop="time" label="时间" min-width="160" />
|
||||
<el-table-column prop="phase" label="相别" width="80" />
|
||||
<el-table-column prop="statType" label="统计类型" width="100">
|
||||
<template #default="{ row }">{{ row.statType ? formatChecksquareStatType(row.statType) : '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="evenHarmonicOrder" label="偶次" width="80" align="right" />
|
||||
<el-table-column prop="evenValue" label="偶次值" min-width="100" align="right" />
|
||||
<el-table-column prop="oddHarmonicOrders" label="奇次" min-width="110">
|
||||
<template #default="{ row }">{{ formatDetailArray(row.oddHarmonicOrders) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="oddValues" label="奇次值" min-width="130">
|
||||
<template #default="{ row }">{{ formatDetailArray(row.oddValues) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="oddMedianValue" label="奇次中位值" min-width="120" align="right" />
|
||||
<el-table-column prop="thresholdMultiplier" label="阈值倍数" min-width="100" align="right" />
|
||||
</el-table>
|
||||
|
||||
<div v-if="showDetailPagination" class="detail-pagination">
|
||||
<el-pagination
|
||||
background
|
||||
layout="total, prev, pager, next"
|
||||
:current-page="detailPageNum"
|
||||
:page-size="DETAIL_PAGE_SIZE"
|
||||
:total="detailTotal"
|
||||
@current-change="handleDetailPageChange"
|
||||
/>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { getSteadyChecksquareItemDetail } from '@/api/steady/steadyDataView'
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
import {
|
||||
CHECKSQUARE_STAT_TYPES,
|
||||
collectMissingSegments,
|
||||
formatChecksquareStatType,
|
||||
formatDataIntegrity,
|
||||
formatStatMissingRate,
|
||||
resolveChecksquareRowName
|
||||
} from '../utils/checksquareTable'
|
||||
@@ -55,36 +151,113 @@ const props = defineProps<{
|
||||
selectedItem: SteadyDataView.SteadyChecksquareItem | null
|
||||
}>()
|
||||
|
||||
const segments = computed(() => collectMissingSegments(props.selectedItem))
|
||||
const DETAIL_PAGE_SIZE = 20
|
||||
const detailType = ref<SteadyDataView.SteadyChecksquareDetailType>('SEGMENT')
|
||||
const segmentStatType = ref<SteadyDataView.SteadyTrendStatType>('AVG')
|
||||
const itemDetail = ref<SteadyDataView.SteadyChecksquareItemDetail | null>(null)
|
||||
const detailPageNum = ref(1)
|
||||
const loading = ref(false)
|
||||
|
||||
const unwrapData = <T,>(response: { data: T } | T): T => {
|
||||
if (response && typeof response === 'object' && 'data' in response) {
|
||||
return (response as { data: T }).data
|
||||
}
|
||||
|
||||
return response as T
|
||||
}
|
||||
|
||||
const segments = computed(() => {
|
||||
if (itemDetail.value?.segments?.length) {
|
||||
return itemDetail.value.segments.map(segment => ({
|
||||
...segment,
|
||||
statType: itemDetail.value?.statType || segmentStatType.value
|
||||
}))
|
||||
}
|
||||
|
||||
return collectMissingSegments(props.selectedItem)
|
||||
})
|
||||
|
||||
const detailTotal = computed(() => {
|
||||
if (typeof itemDetail.value?.total === 'number') return itemDetail.value.total
|
||||
if (detailType.value === 'VALUE_ORDER') return itemDetail.value?.valueOrderDetails?.length || 0
|
||||
if (detailType.value === 'HARMONIC_PARITY') return itemDetail.value?.harmonicParityDetails?.length || 0
|
||||
|
||||
return 0
|
||||
})
|
||||
|
||||
const showDetailPagination = computed(() => {
|
||||
return detailType.value !== 'SEGMENT' && detailTotal.value > DETAIL_PAGE_SIZE
|
||||
})
|
||||
|
||||
const formatSegmentStatus = (status?: string) => {
|
||||
if (status === 'NORMAL') return '正常'
|
||||
if (status === 'MISSING') return '缺失'
|
||||
|
||||
return status || '-'
|
||||
}
|
||||
|
||||
const formatDetailArray = (value?: Array<string | number> | null) => {
|
||||
return value?.length ? value.join('、') : '-'
|
||||
}
|
||||
|
||||
const loadCurrentDetail = async () => {
|
||||
if (!props.selectedItem?.itemId) {
|
||||
itemDetail.value = null
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
try {
|
||||
const response = await getSteadyChecksquareItemDetail({
|
||||
itemId: props.selectedItem.itemId,
|
||||
detailType: detailType.value,
|
||||
statType: detailType.value === 'SEGMENT' ? segmentStatType.value : undefined,
|
||||
pageNum: detailType.value === 'SEGMENT' ? undefined : detailPageNum.value,
|
||||
pageSize: detailType.value === 'SEGMENT' ? undefined : DETAIL_PAGE_SIZE
|
||||
})
|
||||
itemDetail.value = unwrapData(response)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleDetailTypeChange = () => {
|
||||
detailPageNum.value = 1
|
||||
itemDetail.value = null
|
||||
loadCurrentDetail()
|
||||
}
|
||||
|
||||
const handleSegmentStatTypeChange = () => {
|
||||
detailPageNum.value = 1
|
||||
itemDetail.value = null
|
||||
loadCurrentDetail()
|
||||
}
|
||||
|
||||
const handleDetailPageChange = (pageNum: number) => {
|
||||
detailPageNum.value = pageNum
|
||||
loadCurrentDetail()
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.selectedItem?.itemId,
|
||||
() => {
|
||||
detailType.value = 'SEGMENT'
|
||||
segmentStatType.value = 'AVG'
|
||||
detailPageNum.value = 1
|
||||
itemDetail.value = null
|
||||
loadCurrentDetail()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.checksquare-detail {
|
||||
display: flex;
|
||||
flex: none;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-height: 0;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.detail-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.section-description {
|
||||
margin-top: 4px;
|
||||
font-size: 13px;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.stat-grid {
|
||||
@@ -93,6 +266,55 @@ const segments = computed(() => collectMissingSegments(props.selectedItem))
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.detail-tabs {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.detail-tabs :deep(.el-tabs__content) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.detail-tabs :deep(.el-tab-pane) {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.item-overview {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.overview-item {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid var(--el-border-color-lighter);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.overview-label {
|
||||
font-size: 12px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.overview-value {
|
||||
overflow: hidden;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -113,7 +335,33 @@ const segments = computed(() => collectMissingSegments(props.selectedItem))
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.stat-select {
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.segment-toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.detail-table {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.detail-table :deep(.el-table__header .cell),
|
||||
.detail-table :deep(.el-table__body .cell) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.detail-pagination {
|
||||
display: flex;
|
||||
flex: none;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.item-overview,
|
||||
.stat-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<el-dialog :model-value="visible" :title="dialogTitle" width="640px" @update:model-value="emit('update:visible', $event)">
|
||||
<el-descriptions :column="2" border>
|
||||
<el-descriptions-item v-for="item in measurementPointItems" :key="item.prop" :label="item.label">
|
||||
{{ resolveText(data?.[item.prop]) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { ChecksquareMeasurementPointDetail } from '../utils/checksquareLedger'
|
||||
|
||||
defineOptions({
|
||||
name: 'ChecksquareMeasurementPointDialog'
|
||||
})
|
||||
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
data: ChecksquareMeasurementPointDetail | null
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
}>()
|
||||
|
||||
const dialogTitle = '监测点信息'
|
||||
const measurementPointItems: { label: string; prop: keyof ChecksquareMeasurementPointDetail }[] = [
|
||||
{ label: '工程名称', prop: 'engineeringName' },
|
||||
{ label: '项目名称', prop: 'projectName' },
|
||||
{ label: '设备名称', prop: 'equipmentName' },
|
||||
{ label: '网络参数', prop: 'networkParam' },
|
||||
{ label: '监测点名称', prop: 'lineName' }
|
||||
]
|
||||
|
||||
const resolveText = (value: unknown) => {
|
||||
if (value === null || value === undefined || value === '') return '--'
|
||||
return String(value)
|
||||
}
|
||||
</script>
|
||||
@@ -4,7 +4,11 @@
|
||||
<div class="header-button-lf">
|
||||
<span class="section-title">指标校验结果</span>
|
||||
<span v-if="result" class="summary-meta">
|
||||
<el-tag v-if="result.taskNo" size="small" effect="plain">任务编号:{{ result.taskNo }}</el-tag>
|
||||
<el-tag size="small" effect="plain">{{ result.lineName || result.lineId || '未返回监测点' }}</el-tag>
|
||||
<el-tag size="small" effect="plain">
|
||||
检测时间:{{ result.timeStart || '-' }} 至 {{ result.timeEnd || '-' }}
|
||||
</el-tag>
|
||||
<el-tag v-if="result.intervalMinutes" size="small" effect="plain">
|
||||
{{ result.intervalMinutes }} 分钟间隔
|
||||
</el-tag>
|
||||
@@ -27,44 +31,62 @@
|
||||
highlight-current-row
|
||||
empty-text="暂无校验结果"
|
||||
>
|
||||
<el-table-column prop="indicatorName" label="指标名称" min-width="208">
|
||||
<el-table-column label="监测点名称" width="150">
|
||||
<template #default="{ row }">
|
||||
<span class="line-name" :title="resolveChecksquareLineName(row)">
|
||||
{{ resolveChecksquareLineName(row) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="indicatorName" label="指标名称" width="160">
|
||||
<template #default="{ row }">
|
||||
<span class="indicator-name" :title="resolveChecksquareRowName(row)">
|
||||
{{ resolveChecksquareRowName(row) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="hasData" label="是否有数据" min-width="120" align="center">
|
||||
<el-table-column prop="abnormalPointCount" label="值关系异常点" width="88" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.hasData !== undefined" :type="row.hasData ? 'success' : 'danger'" effect="plain">
|
||||
{{ formatBooleanText(row.hasData) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
<span :class="{ 'is-abnormal-count': hasAbnormalCount(row.abnormalPointCount) }">
|
||||
{{ row.abnormalPointCount ?? '-' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="missingRate" label="总缺失率" min-width="130" align="center">
|
||||
<el-table-column prop="harmonicParityAbnormalPointCount" label="谐波奇偶异常点" width="88" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatMissingRate(row.missingRate, row.missingRateText) }}
|
||||
<span :class="{ 'is-abnormal-count': hasAbnormalCount(row.harmonicParityAbnormalPointCount) }">
|
||||
{{ row.harmonicParityAbnormalPointCount ?? '-' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="平均值缺失率" min-width="130" align="center">
|
||||
<template #default="{ row }">{{ formatStatMissingRate(row, 'AVG') }}</template>
|
||||
<el-table-column label="数据完整性" align="center">
|
||||
<el-table-column prop="hasData" label="是否有数据" width="88" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.hasData !== undefined" :type="row.hasData ? 'success' : 'danger'" effect="plain">
|
||||
{{ formatBooleanText(row.hasData) }}
|
||||
</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="dataIntegrity" label="总体(%)" width="88" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ formatSummaryDataIntegrity(row) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="平均值(%)" width="88" align="center">
|
||||
<template #default="{ row }">{{ formatSummaryStatIntegrity(row, 'AVG') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最大值(%)" width="88" align="center">
|
||||
<template #default="{ row }">{{ formatSummaryStatIntegrity(row, 'MAX') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最小值(%)" width="88" align="center">
|
||||
<template #default="{ row }">{{ formatSummaryStatIntegrity(row, 'MIN') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="CP95值(%)" width="88" align="center">
|
||||
<template #default="{ row }">{{ formatSummaryStatIntegrity(row, 'CP95') }}</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="最大值缺失率" min-width="130" align="center">
|
||||
<template #default="{ row }">{{ formatStatMissingRate(row, 'MAX') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="最小值缺失率" min-width="130" align="center">
|
||||
<template #default="{ row }">{{ formatStatMissingRate(row, 'MIN') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="CP95缺失率" min-width="140" align="center">
|
||||
<template #default="{ row }">{{ formatStatMissingRate(row, 'CP95') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="maxContinuousMissingMinutes" label="最大连续缺失" min-width="150" align="center">
|
||||
<template #default="{ row }">
|
||||
{{ row.maxContinuousMissingMinutes ?? '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="96" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="130" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link :disabled="!hasChecksquareDetail(row)" @click="emit('detail', row)">
|
||||
详情
|
||||
@@ -80,7 +102,7 @@ import { Refresh } from '@element-plus/icons-vue'
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
import {
|
||||
formatBooleanText,
|
||||
formatMissingRate,
|
||||
formatDataIntegrity,
|
||||
formatStatMissingRate,
|
||||
hasChecksquareDetail,
|
||||
resolveChecksquareRowName
|
||||
@@ -90,16 +112,35 @@ defineOptions({
|
||||
name: 'ChecksquareSummaryTable'
|
||||
})
|
||||
|
||||
defineProps<{
|
||||
const emit = defineEmits<{
|
||||
refresh: []
|
||||
detail: [row: SteadyDataView.SteadyChecksquareItem]
|
||||
}>()
|
||||
|
||||
const props = defineProps<{
|
||||
result: SteadyDataView.SteadyChecksquareQueryResult | null
|
||||
items: SteadyDataView.SteadyChecksquareItem[]
|
||||
loading: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
refresh: []
|
||||
detail: [row: SteadyDataView.SteadyChecksquareItem]
|
||||
}>()
|
||||
const hasAbnormalCount = (value?: number | null) => Number(value || 0) > 0
|
||||
|
||||
const stripPercentUnit = (value: string) => value.replace(/%$/, '')
|
||||
|
||||
const resolveChecksquareLineName = (row: SteadyDataView.SteadyChecksquareItem) => {
|
||||
return row.lineName || row.lineId || props.result?.lineName || props.result?.lineId || '-'
|
||||
}
|
||||
|
||||
const formatSummaryDataIntegrity = (row: SteadyDataView.SteadyChecksquareItem) => {
|
||||
return stripPercentUnit(formatDataIntegrity(row.dataIntegrity, row.dataIntegrityText))
|
||||
}
|
||||
|
||||
const formatSummaryStatIntegrity = (
|
||||
row: SteadyDataView.SteadyChecksquareItem,
|
||||
statType: SteadyDataView.SteadyTrendStatType
|
||||
) => {
|
||||
return stripPercentUnit(formatStatMissingRate(row, statType))
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@@ -127,6 +168,7 @@ const emit = defineEmits<{
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.line-name,
|
||||
.indicator-name {
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
@@ -135,4 +177,8 @@ const emit = defineEmits<{
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.is-abnormal-count {
|
||||
color: var(--el-color-danger);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,348 @@
|
||||
<template>
|
||||
<ProTable
|
||||
ref="proTable"
|
||||
row-key="taskId"
|
||||
:columns="columns"
|
||||
:request-api="getTableList"
|
||||
:search-col="{ xs: 1, sm: 2, md: 2, lg: 5, xl: 5 }"
|
||||
>
|
||||
<template #tableHeader>
|
||||
<el-button type="primary" :icon="Plus" @click="emit('createTask')">新增</el-button>
|
||||
</template>
|
||||
|
||||
<template #operation="{ row }">
|
||||
<el-button
|
||||
v-if="row.taskStatus === 'FAIL'"
|
||||
type="primary"
|
||||
link
|
||||
:icon="RefreshRight"
|
||||
@click="emit('restart', row)"
|
||||
>
|
||||
重启
|
||||
</el-button>
|
||||
<el-button type="danger" link :icon="Delete" @click="emit('delete', row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, h, reactive, ref } from 'vue'
|
||||
import { ElButton, ElDatePicker, ElTag, ElTreeSelect } from 'element-plus'
|
||||
import { Delete, Plus, RefreshRight } from '@element-plus/icons-vue'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
import {
|
||||
buildChecksquareTaskQueryParams,
|
||||
formatChecksquareIntegrity,
|
||||
formatChecksquareTaskStatus,
|
||||
resolveChecksquareTaskStatusType,
|
||||
resolveChecksquareText,
|
||||
type ChecksquareTaskSearchParams
|
||||
} from '../utils/checksquareTaskTable'
|
||||
|
||||
defineOptions({
|
||||
name: 'ChecksquareTaskTable'
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
ledgerTree: SteadyDataView.SteadyLedgerNode[]
|
||||
indicatorTree: SteadyDataView.SteadyIndicatorNode[]
|
||||
requestApi: (params: SteadyDataView.SteadyChecksquareTaskQueryParams) => Promise<any>
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
createTask: []
|
||||
detail: [row: SteadyDataView.SteadyChecksquareTask]
|
||||
restart: [row: SteadyDataView.SteadyChecksquareTask]
|
||||
delete: [row: SteadyDataView.SteadyChecksquareTask]
|
||||
viewMeasurementPoint: [row: SteadyDataView.SteadyChecksquareTask]
|
||||
}>()
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
interface ChecksquareFilterTreeNode {
|
||||
label: string
|
||||
value: string
|
||||
disabled?: boolean
|
||||
children?: ChecksquareFilterTreeNode[]
|
||||
}
|
||||
|
||||
const normalizeLineFilterTree = (nodes: SteadyDataView.SteadyLedgerNode[]): ChecksquareFilterTreeNode[] => {
|
||||
return nodes.map(node => ({
|
||||
label: node.name,
|
||||
value: node.id,
|
||||
disabled: node.level !== 3 || node.selectable === false,
|
||||
children: node.children?.length ? normalizeLineFilterTree(node.children) : undefined
|
||||
}))
|
||||
}
|
||||
|
||||
const normalizeIndicatorFilterTree = (
|
||||
nodes: SteadyDataView.SteadyIndicatorNode[],
|
||||
parentKey = ''
|
||||
): ChecksquareFilterTreeNode[] => {
|
||||
return nodes.map((node, index) => {
|
||||
const isLeaf = !node.children?.length
|
||||
const value =
|
||||
isLeaf && node.indicatorCode
|
||||
? node.indicatorCode
|
||||
: node.id || `${parentKey}${node.groupCode || node.name || 'node'}-${index}`
|
||||
|
||||
return {
|
||||
label: node.unit ? `${node.name}(${node.unit})` : node.name,
|
||||
value,
|
||||
disabled: !isLeaf || !node.indicatorCode,
|
||||
children: node.children?.length ? normalizeIndicatorFilterTree(node.children, `${value}-`) : undefined
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const lineFilterTree = computed(() => normalizeLineFilterTree(props.ledgerTree))
|
||||
const indicatorFilterTree = computed(() => normalizeIndicatorFilterTree(props.indicatorTree))
|
||||
|
||||
const splitTreeSelectValues = (value?: string) => {
|
||||
return (value || '')
|
||||
.split(',')
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
const normalizeTreeSelectValues = (value: unknown) => {
|
||||
const rawValues = Array.isArray(value) ? value : value === undefined || value === null || value === '' ? [] : [value]
|
||||
|
||||
return Array.from(
|
||||
new Set(
|
||||
rawValues
|
||||
.filter((item): item is string | number => typeof item === 'string' || typeof item === 'number')
|
||||
.map(item => String(item).trim())
|
||||
.filter(Boolean)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const renderTimeRangeSearch = ({ searchParam }: { searchParam: ChecksquareTaskSearchParams }) =>
|
||||
h(ElDatePicker, {
|
||||
modelValue: searchParam.taskTimeRange,
|
||||
type: 'datetimerange',
|
||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
||||
startPlaceholder: '开始时间',
|
||||
endPlaceholder: '结束时间',
|
||||
clearable: true,
|
||||
'onUpdate:modelValue': (value: string[] | null) => {
|
||||
searchParam.taskTimeRange = value || undefined
|
||||
}
|
||||
})
|
||||
|
||||
const renderLineSearch = ({ searchParam }: { searchParam: ChecksquareTaskSearchParams }) =>
|
||||
h(ElTreeSelect, {
|
||||
class: 'checksquare-search-tree-select',
|
||||
style: { width: '100%' },
|
||||
modelValue: splitTreeSelectValues(searchParam.lineId),
|
||||
data: lineFilterTree.value,
|
||||
nodeKey: 'value',
|
||||
multiple: true,
|
||||
showCheckbox: true,
|
||||
collapseTags: true,
|
||||
collapseTagsTooltip: true,
|
||||
maxCollapseTags: 1,
|
||||
popperClass: 'checksquare-search-tree-popper',
|
||||
filterable: true,
|
||||
clearable: true,
|
||||
defaultExpandAll: true,
|
||||
checkStrictly: true,
|
||||
props: { label: 'label', children: 'children', disabled: 'disabled' },
|
||||
placeholder: '请选择监测点',
|
||||
'onUpdate:modelValue': (value: unknown) => {
|
||||
const selectedValues = normalizeTreeSelectValues(value)
|
||||
searchParam.lineId = selectedValues.length ? selectedValues.join(',') : undefined
|
||||
}
|
||||
})
|
||||
|
||||
const renderIndicatorSearch = ({ searchParam }: { searchParam: ChecksquareTaskSearchParams }) =>
|
||||
h(ElTreeSelect, {
|
||||
class: 'checksquare-search-tree-select',
|
||||
style: { width: '100%' },
|
||||
modelValue: splitTreeSelectValues(searchParam.indicatorCode),
|
||||
data: indicatorFilterTree.value,
|
||||
nodeKey: 'value',
|
||||
multiple: true,
|
||||
showCheckbox: true,
|
||||
collapseTags: true,
|
||||
collapseTagsTooltip: true,
|
||||
maxCollapseTags: 1,
|
||||
popperClass: 'checksquare-search-tree-popper',
|
||||
filterable: true,
|
||||
clearable: true,
|
||||
defaultExpandAll: true,
|
||||
checkStrictly: true,
|
||||
props: { label: 'label', children: 'children', disabled: 'disabled' },
|
||||
placeholder: '请选择稳态指标',
|
||||
'onUpdate:modelValue': (value: unknown) => {
|
||||
const selectedValues = normalizeTreeSelectValues(value)
|
||||
searchParam.indicatorCode = selectedValues.length ? selectedValues.join(',') : undefined
|
||||
}
|
||||
})
|
||||
|
||||
const columns = reactive<ColumnProps<SteadyDataView.SteadyChecksquareTask>[]>([
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'taskNo',
|
||||
label: '任务编号',
|
||||
minWidth: 180,
|
||||
render: ({ row }) => resolveChecksquareText(row.taskNo)
|
||||
},
|
||||
{
|
||||
prop: 'lineId',
|
||||
label: '监测点ID',
|
||||
isShow: false,
|
||||
isSetting: false,
|
||||
search: {
|
||||
label: '监测点',
|
||||
order: 2,
|
||||
render: renderLineSearch
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'lineName',
|
||||
label: '监测点名称',
|
||||
minWidth: 160,
|
||||
render: ({ row }) =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
type: 'primary',
|
||||
link: true,
|
||||
onClick: () => emit('viewMeasurementPoint', row)
|
||||
},
|
||||
() => resolveChecksquareText(row.lineName || row.lineId)
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'indicatorCode',
|
||||
label: '稳态指标',
|
||||
isShow: false,
|
||||
isSetting: false,
|
||||
search: {
|
||||
label: '稳态指标',
|
||||
order: 3,
|
||||
render: renderIndicatorSearch
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'timeStart',
|
||||
label: '开始时间',
|
||||
minWidth: 170,
|
||||
render: ({ row }) => resolveChecksquareText(row.timeStart),
|
||||
search: {
|
||||
label: '检测时间',
|
||||
key: 'taskTimeRange',
|
||||
order: 1,
|
||||
render: renderTimeRangeSearch
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'timeEnd',
|
||||
label: '结束时间',
|
||||
minWidth: 170,
|
||||
render: ({ row }) => resolveChecksquareText(row.timeEnd)
|
||||
},
|
||||
{
|
||||
prop: 'taskStatus',
|
||||
label: '任务状态',
|
||||
minWidth: 110,
|
||||
render: ({ row }) =>
|
||||
h(
|
||||
ElTag,
|
||||
{ type: resolveChecksquareTaskStatusType(row.taskStatus), effect: 'plain' },
|
||||
() => formatChecksquareTaskStatus(row.taskStatus)
|
||||
)
|
||||
},
|
||||
{
|
||||
prop: 'itemCount',
|
||||
label: '检测项数',
|
||||
minWidth: 100,
|
||||
align: 'center',
|
||||
render: ({ row }) => resolveChecksquareText(row.itemCount)
|
||||
},
|
||||
{
|
||||
prop: 'abnormalItemCount',
|
||||
label: '异常项数',
|
||||
minWidth: 100,
|
||||
align: 'center',
|
||||
render: ({ row }) =>
|
||||
h(
|
||||
ElButton,
|
||||
{
|
||||
type: 'primary',
|
||||
link: true,
|
||||
onClick: () => emit('detail', row)
|
||||
},
|
||||
() => resolveChecksquareText(row.abnormalItemCount)
|
||||
),
|
||||
search: {
|
||||
label: '异常状态',
|
||||
key: 'hasAbnormal',
|
||||
order: 4,
|
||||
el: 'select'
|
||||
},
|
||||
enum: [
|
||||
{ label: '存在异常', value: true },
|
||||
{ label: '全部', value: false }
|
||||
],
|
||||
isFilterEnum: false
|
||||
},
|
||||
{
|
||||
prop: 'minDataIntegrity',
|
||||
label: '最低完整性',
|
||||
minWidth: 120,
|
||||
align: 'center',
|
||||
render: ({ row }) => formatChecksquareIntegrity(row.minDataIntegrity)
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
minWidth: 170,
|
||||
render: ({ row }) => resolveChecksquareText(row.createTime)
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 180 }
|
||||
])
|
||||
|
||||
const getTableList = (params: ChecksquareTaskSearchParams) => {
|
||||
return props.requestApi(buildChecksquareTaskQueryParams(params))
|
||||
}
|
||||
|
||||
const refresh = () => {
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
refresh
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.checksquare-search-tree-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.checksquare-search-tree-select .el-select__wrapper) {
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
:deep(.checksquare-search-tree-select .el-select__selection) {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
:deep(.checksquare-search-tree-select .el-select__tags-text) {
|
||||
display: inline-block;
|
||||
max-width: 120px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
vertical-align: bottom;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:global(.checksquare-search-tree-popper .el-select-dropdown__wrap) {
|
||||
max-height: 280px;
|
||||
}
|
||||
</style>
|
||||
@@ -32,6 +32,12 @@
|
||||
@update:range-value="handleTimeRangeChange"
|
||||
/>
|
||||
</div>
|
||||
<div class="query-actions">
|
||||
<el-button type="primary" :icon="Plus" :loading="loading.query" :disabled="loading.query" @click="emit('create')">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button type="primary" plain :icon="RefreshLeft" :disabled="loading.query" @click="emit('reset')">重置</el-button>
|
||||
</div>
|
||||
<div class="toolbar-field indicator-form-item">
|
||||
<span class="toolbar-field__label">稳态指标:</span>
|
||||
<div class="indicator-select-row">
|
||||
@@ -46,6 +52,7 @@
|
||||
filterable
|
||||
clearable
|
||||
default-expand-all
|
||||
:disabled="loading.query"
|
||||
node-key="treeKey"
|
||||
value-key="treeKey"
|
||||
:props="{ label: 'name', children: 'children' }"
|
||||
@@ -59,46 +66,27 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-tree-select>
|
||||
<el-button type="primary" plain @click="handleSelectAllIndicators">全选</el-button>
|
||||
<el-button type="primary" plain :disabled="loading.query" @click="handleSelectAllIndicators">全选</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="query-actions">
|
||||
<el-button type="primary" :icon="Search" :loading="loading.query" @click="emit('query')">
|
||||
查询
|
||||
</el-button>
|
||||
<el-button type="primary" plain :icon="RefreshLeft" @click="emit('reset')">重置</el-button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="checksquare-content">
|
||||
<ChecksquareSummaryTable
|
||||
class="content-summary"
|
||||
:result="result"
|
||||
:items="result?.items || []"
|
||||
:loading="loading.query"
|
||||
@refresh="emit('query')"
|
||||
@detail="openDetailDialog"
|
||||
/>
|
||||
<div class="checksquare-result-slot">
|
||||
<slot name="result" />
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<el-dialog v-model="detailDialogVisible" title="连续性详情" width="760px" append-to-body>
|
||||
<ChecksquareDetailPanel :selected-item="selectedItem" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { RefreshLeft, Search } from '@element-plus/icons-vue'
|
||||
import { Plus, RefreshLeft } from '@element-plus/icons-vue'
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
import TimePeriodSearch from '@/views/components/TimePeriodSearch/index.vue'
|
||||
import { buildTimePeriodRange, type TimePeriodUnit } from '@/views/components/TimePeriodSearch/timePeriod'
|
||||
import SteadyLedgerTree from '@/views/steady/steadyDataView/components/SteadyLedgerTree.vue'
|
||||
import { collectLeafIndicators } from '@/views/steady/steadyDataView/utils/selectionRules'
|
||||
import type { ChecksquareFormState } from '../utils/checksquarePayload'
|
||||
import ChecksquareDetailPanel from './ChecksquareDetailPanel.vue'
|
||||
import ChecksquareSummaryTable from './ChecksquareSummaryTable.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'ChecksquareWorkbench'
|
||||
@@ -108,8 +96,6 @@ const props = defineProps<{
|
||||
form: ChecksquareFormState
|
||||
ledgerTree: SteadyDataView.SteadyLedgerNode[]
|
||||
indicatorTree: SteadyDataView.SteadyIndicatorNode[]
|
||||
result: SteadyDataView.SteadyChecksquareQueryResult | null
|
||||
selectedItem: SteadyDataView.SteadyChecksquareItem | null
|
||||
loading: {
|
||||
ledger: boolean
|
||||
indicator: boolean
|
||||
@@ -129,13 +115,11 @@ const emit = defineEmits<{
|
||||
ledgerSearch: [value: string]
|
||||
ledgerChange: [nodes: SteadyDataView.SteadyLedgerNode[]]
|
||||
indicatorChange: [nodes: SteadyDataView.SteadyIndicatorNode[]]
|
||||
query: []
|
||||
create: []
|
||||
reset: []
|
||||
selectItem: [item: SteadyDataView.SteadyChecksquareItem]
|
||||
}>()
|
||||
|
||||
const selectedIndicatorKeys = ref<string[]>([])
|
||||
const detailDialogVisible = ref(false)
|
||||
const CHECKSQUARE_TIME_PERIOD_UNITS: TimePeriodUnit[] = ['day', 'week', 'month', 'year', 'custom']
|
||||
|
||||
const normalizeIndicatorSelectTree = (
|
||||
@@ -191,11 +175,6 @@ const handleSelectAllIndicators = () => {
|
||||
emitSelectedIndicators()
|
||||
}
|
||||
|
||||
const openDetailDialog = (item: SteadyDataView.SteadyChecksquareItem) => {
|
||||
emit('selectItem', item)
|
||||
detailDialogVisible.value = true
|
||||
}
|
||||
|
||||
const updateTimeRange = (unit: TimePeriodUnit, baseDate: Date) => {
|
||||
const timeRange = unit === 'custom' ? props.form.timeRange : buildTimePeriodRange(unit, baseDate)
|
||||
|
||||
@@ -236,7 +215,7 @@ watch(
|
||||
<style scoped lang="scss">
|
||||
.checksquare-layout {
|
||||
display: grid;
|
||||
grid-template-columns: 320px minmax(0, 1fr);
|
||||
grid-template-columns: 240px minmax(0, 1fr);
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@@ -275,17 +254,29 @@ watch(
|
||||
}
|
||||
|
||||
.checksquare-main {
|
||||
display: grid;
|
||||
grid-template-rows: auto minmax(0, 1fr);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
align-items: flex-end;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.checksquare-result-slot {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.checksquare-result-slot :deep(.checksquare-result-panel) {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.query-card {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(430px, 1.35fr) minmax(0, 1fr) auto;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 12px;
|
||||
@@ -299,6 +290,7 @@ watch(
|
||||
}
|
||||
|
||||
.toolbar-field--time {
|
||||
flex: 1 1 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -325,11 +317,14 @@ watch(
|
||||
}
|
||||
|
||||
.indicator-form-item {
|
||||
order: 2;
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.indicator-select-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
@@ -337,7 +332,65 @@ watch(
|
||||
|
||||
.indicator-tree-select {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.indicator-tree-select :deep(.el-select__wrapper) {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
min-height: 32px;
|
||||
height: 32px;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.indicator-tree-select :deep(.el-select__selection) {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
width: 0;
|
||||
max-width: 100%;
|
||||
min-height: 24px;
|
||||
height: 24px;
|
||||
max-height: 24px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.indicator-tree-select :deep(.el-select__selected-item) {
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
height: 24px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.indicator-tree-select :deep(.el-select__tags) {
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
min-height: 24px;
|
||||
height: 24px;
|
||||
max-height: 24px;
|
||||
overflow: hidden;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.indicator-tree-select :deep(.el-tag) {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
height: 22px;
|
||||
flex: 0 1 auto;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.indicator-tree-select :deep(.el-select__tags-text) {
|
||||
max-width: 150px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.indicator-select-node {
|
||||
@@ -357,36 +410,27 @@ watch(
|
||||
|
||||
.query-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
order: 3;
|
||||
flex: 0 0 auto;
|
||||
justify-content: flex-start;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.checksquare-content {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.content-summary {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
@media (max-width: 1360px) {
|
||||
.checksquare-layout:not(.is-ledger-collapsed) {
|
||||
grid-template-columns: 280px minmax(0, 1fr);
|
||||
grid-template-columns: 220px minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1280px) {
|
||||
.query-card {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
.toolbar-field--time,
|
||||
.indicator-form-item {
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
|
||||
.query-actions {
|
||||
justify-content: flex-start;
|
||||
.checksquare-result-slot {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -11,265 +11,780 @@ const files = {
|
||||
apiTypes: path.resolve(rootDir, 'api/steady/steadyDataView/interface/index.ts'),
|
||||
page: path.resolve(rootDir, 'views/steady/checksquare/index.vue'),
|
||||
workbench: path.resolve(rootDir, 'views/steady/checksquare/components/ChecksquareWorkbench.vue'),
|
||||
taskTable: path.resolve(rootDir, 'views/steady/checksquare/components/ChecksquareTaskTable.vue'),
|
||||
summaryTable: path.resolve(rootDir, 'views/steady/checksquare/components/ChecksquareSummaryTable.vue'),
|
||||
detailPanel: path.resolve(rootDir, 'views/steady/checksquare/components/ChecksquareDetailPanel.vue'),
|
||||
createResultPanel: path.resolve(rootDir, 'views/steady/checksquare/components/ChecksquareCreateResultPanel.vue'),
|
||||
measurementPointDialog: path.resolve(
|
||||
rootDir,
|
||||
'views/steady/checksquare/components/ChecksquareMeasurementPointDialog.vue'
|
||||
),
|
||||
payload: path.resolve(rootDir, 'views/steady/checksquare/utils/checksquarePayload.ts'),
|
||||
table: path.resolve(rootDir, 'views/steady/checksquare/utils/checksquareTable.ts')
|
||||
ledgerUtils: path.resolve(rootDir, 'views/steady/checksquare/utils/checksquareLedger.ts'),
|
||||
taskTableUtils: path.resolve(rootDir, 'views/steady/checksquare/utils/checksquareTaskTable.ts'),
|
||||
table: path.resolve(rootDir, 'views/steady/checksquare/utils/checksquareTable.ts'),
|
||||
grid: path.resolve(rootDir, 'components/Grid/index.vue'),
|
||||
searchForm: path.resolve(rootDir, 'components/SearchForm/index.vue'),
|
||||
searchFormItem: path.resolve(rootDir, 'components/SearchForm/components/SearchFormItem.vue')
|
||||
}
|
||||
|
||||
const read = file => (exists(file) ? fs.readFileSync(file, 'utf8') : '')
|
||||
const exists = file => fs.existsSync(file)
|
||||
|
||||
const checks = [
|
||||
['checksquare query api exists', () => /querySteadyChecksquare/.test(read(files.api))],
|
||||
['checksquare task query api exists', () => /querySteadyChecksquareTasks/.test(read(files.api))],
|
||||
[
|
||||
'checksquare api posts to expected endpoint',
|
||||
() => /\/steady\/data-view\/checksquare\/query/.test(read(files.api))
|
||||
'checksquare api exposes all documented endpoints',
|
||||
() => {
|
||||
const api = read(files.api)
|
||||
return (
|
||||
/\/steady\/checksquare\/query/.test(api) &&
|
||||
/\/steady\/checksquare\/create/.test(api) &&
|
||||
!/\/steady\/checksquare\/get-or-create/.test(api) &&
|
||||
/\/steady\/checksquare\/delete/.test(api) &&
|
||||
/\/steady\/checksquare\/restart\?taskId=/.test(api) &&
|
||||
/\/steady\/checksquare\/detail/.test(api) &&
|
||||
/\/steady\/checksquare\/item-detail/.test(api)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'checksquare request type uses single lineId',
|
||||
() => /interface SteadyChecksquareQueryParams[\s\S]*lineId: string/.test(read(files.apiTypes))
|
||||
'checksquare restart api uses documented task id query endpoint',
|
||||
() =>
|
||||
/export const restartSteadyChecksquareTask = \(taskId: string\)/.test(read(files.api)) &&
|
||||
/http\.post<SteadyDataView\.SteadyChecksquareTask>\([\s\S]*`\/steady\/checksquare\/restart\?taskId=\$\{encodeURIComponent\(taskId\)\}`/.test(
|
||||
read(files.api)
|
||||
)
|
||||
],
|
||||
[
|
||||
'checksquare request type supports per-order harmonic query only',
|
||||
'checksquare delete api accepts documented task id array body',
|
||||
() =>
|
||||
/export const deleteSteadyChecksquareTasks = \(taskIds: SteadyDataView\.SteadyChecksquareDeleteParams\)/.test(
|
||||
read(files.api)
|
||||
) &&
|
||||
/http\.post<boolean>\('\/steady\/checksquare\/delete', taskIds/.test(read(files.api)) &&
|
||||
/export type SteadyChecksquareDeleteParams = string\[\]/.test(read(files.apiTypes))
|
||||
],
|
||||
[
|
||||
'checksquare task query params support page and filters',
|
||||
() =>
|
||||
/interface SteadyChecksquareTaskQueryParams[\s\S]*pageNum\?: number[\s\S]*pageSize\?: number[\s\S]*lineId\?: string[\s\S]*indicatorCode\?: string[\s\S]*hasAbnormal\?: boolean/.test(
|
||||
read(files.apiTypes)
|
||||
)
|
||||
],
|
||||
[
|
||||
'checksquare create params match backend create body',
|
||||
() => {
|
||||
const typeBlock =
|
||||
read(files.apiTypes).match(/interface SteadyChecksquareQueryParams\s*\{[\s\S]*?\n {4}\}/)?.[0] || ''
|
||||
return /harmonicOrders\?: number\[\]/.test(typeBlock) && !/qualityFlag|statTypes|phases|lineIds/.test(typeBlock)
|
||||
read(files.apiTypes).match(/interface SteadyChecksquareCreateParams\s*\{[\s\S]*?\n {4}\}/)?.[0] || ''
|
||||
return (
|
||||
!/lineId\?: string/.test(typeBlock) &&
|
||||
/lineIds: string\[\]/.test(typeBlock) &&
|
||||
/indicatorCodes: string\[\]/.test(typeBlock) &&
|
||||
/timeStart: string/.test(typeBlock) &&
|
||||
/timeEnd: string/.test(typeBlock) &&
|
||||
!/harmonicOrders/.test(typeBlock)
|
||||
)
|
||||
}
|
||||
],
|
||||
['workbench component exists', () => exists(files.workbench)],
|
||||
['summary table component exists', () => exists(files.summaryTable)],
|
||||
['detail panel component exists', () => exists(files.detailPanel)],
|
||||
['payload utility exists', () => exists(files.payload)],
|
||||
['table utility exists', () => exists(files.table)],
|
||||
['page reuses steady ledger tree', () => /SteadyLedgerTree/.test(read(files.workbench))],
|
||||
['page reuses shared time period search', () => /TimePeriodSearch/.test(read(files.workbench))],
|
||||
['payload keeps shared time period unit state', () => /timeUnit:\s*TimePeriodUnit/.test(read(files.payload))],
|
||||
['task table component exists', () => exists(files.taskTable)],
|
||||
[
|
||||
'checksquare time search exposes day week month year custom units',
|
||||
'task table uses ProTable like event list',
|
||||
() => /<ProTable[\s\S]*row-key="taskId"[\s\S]*:columns="columns"/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'task table exposes create task header action',
|
||||
() =>
|
||||
/CHECKSQUARE_TIME_PERIOD_UNITS\s*:\s*TimePeriodUnit\[\]\s*=\s*\['day',\s*'week',\s*'month',\s*'year',\s*'custom'\]/.test(
|
||||
read(files.workbench)
|
||||
) && /:visible-units="CHECKSQUARE_TIME_PERIOD_UNITS"/.test(read(files.workbench))
|
||||
/<template #tableHeader>/.test(read(files.taskTable)) &&
|
||||
/>新增<\/el-button>/.test(read(files.taskTable)) &&
|
||||
/emit\('createTask'\)/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'checksquare defaults to day range',
|
||||
() =>
|
||||
/timeRange:\s*buildTimePeriodRange\('day',\s*baseDate\)/.test(read(files.payload)) &&
|
||||
/timeUnit:\s*'day'/.test(read(files.payload))
|
||||
],
|
||||
['page no longer tracks floating indicator panel state', () => !/indicatorPanelCollapsed|indicator-panel-collapsed/.test(read(files.page))],
|
||||
[
|
||||
'query form uses tree select for steady indicators',
|
||||
() =>
|
||||
/<el-tree-select/.test(read(files.workbench)) &&
|
||||
/v-model="selectedIndicatorKeys"/.test(read(files.workbench)) &&
|
||||
/multiple/.test(read(files.workbench)) &&
|
||||
/show-checkbox/.test(read(files.workbench))
|
||||
],
|
||||
[
|
||||
'query form keeps steady indicator immediately after time selector',
|
||||
() => /class="toolbar-field toolbar-field--time"[\s\S]*class="toolbar-field indicator-form-item"/.test(read(files.workbench))
|
||||
],
|
||||
[
|
||||
'query form supports selecting all steady indicators',
|
||||
() =>
|
||||
/@click="handleSelectAllIndicators"/.test(read(files.workbench)) &&
|
||||
/collectAllIndicatorKeys/.test(read(files.workbench))
|
||||
],
|
||||
[
|
||||
'checksquare no longer renders floating indicator panel',
|
||||
() => !/SteadyIndicatorFloatingPanel|indicatorPanelCollapsedProxy|is-indicator-expanded/.test(read(files.workbench))
|
||||
],
|
||||
['summary table renders unsupported stats as dash', () => /formatStatMissingRate[\s\S]*'-'/.test(read(files.table))],
|
||||
[
|
||||
'summary table has localized AVG MAX MIN CP95 columns',
|
||||
() => /平均值缺失率[\s\S]*最大值缺失率[\s\S]*最小值缺失率[\s\S]*CP95缺失率/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'table utility localizes checksquare stat type names',
|
||||
() => /AVG:\s*'平均值'[\s\S]*MAX:\s*'最大值'[\s\S]*MIN:\s*'最小值'/.test(read(files.table))
|
||||
],
|
||||
['detail panel renders missing segments', () => /segments/.test(read(files.detailPanel))]
|
||||
,
|
||||
[
|
||||
'summary table title changed to check result',
|
||||
() => /指标校验结果/.test(read(files.summaryTable)) && !/指标校验总览/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'summary table shows monitor fallback and keeps meta 15px from title',
|
||||
'task table has documented task columns',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
const source = read(files.taskTable)
|
||||
return [
|
||||
'taskNo',
|
||||
'lineName',
|
||||
'timeStart',
|
||||
'timeEnd',
|
||||
'taskStatus',
|
||||
'itemCount',
|
||||
'abnormalItemCount',
|
||||
'minDataIntegrity',
|
||||
'createTime'
|
||||
].every(prop => new RegExp(`prop:\\s*'${prop}'`).test(source))
|
||||
}
|
||||
],
|
||||
[
|
||||
'task table exposes row delete action without duplicate detail operation',
|
||||
() => {
|
||||
const taskTable = read(files.taskTable)
|
||||
const operationSlot = taskTable.match(/<template #operation="\{ row \}">[\s\S]*?<\/template>/)?.[0] || ''
|
||||
return (
|
||||
/class="summary-meta"/.test(summaryTable) &&
|
||||
/result\.lineName\s*\|\|\s*result\.lineId\s*\|\|\s*'未返回监测点'/.test(summaryTable) &&
|
||||
/\.summary-meta\s*\{[\s\S]*margin-left:\s*15px/.test(summaryTable)
|
||||
/emit\('delete', row\)/.test(operationSlot) &&
|
||||
!/emit\('detail', row\)/.test(operationSlot) &&
|
||||
/delete: \[row: SteadyDataView\.SteadyChecksquareTask\]/.test(taskTable) &&
|
||||
/Delete/.test(taskTable)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table uses tree rows for harmonic results',
|
||||
() =>
|
||||
/row-key="itemKey"/.test(read(files.summaryTable)) &&
|
||||
/tree-props/.test(read(files.summaryTable)) &&
|
||||
/children/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'summary table keeps harmonic tree rows collapsed by default',
|
||||
() => !/default-expand-all/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'summary table removes harmonic order column',
|
||||
() => !/<el-table-column[^>]*prop="harmonicOrder"/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'summary table uses balanced column widths for check result',
|
||||
'task table exposes restart only for failed rows',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
const indicatorColumn = summaryTable.match(/<el-table-column[^>]*prop="indicatorName"[^>]*>/)?.[0] || ''
|
||||
const hasDataColumn = summaryTable.match(/<el-table-column[^>]*prop="hasData"[^>]*>/)?.[0] || ''
|
||||
const missingRateColumn = summaryTable.match(/<el-table-column[^>]*prop="missingRate"[^>]*>/)?.[0] || ''
|
||||
const avgColumn = summaryTable.match(/<el-table-column[^>]*label="平均值缺失率"[^>]*>/)?.[0] || ''
|
||||
const maxColumn = summaryTable.match(/<el-table-column[^>]*label="最大值缺失率"[^>]*>/)?.[0] || ''
|
||||
const minColumn = summaryTable.match(/<el-table-column[^>]*label="最小值缺失率"[^>]*>/)?.[0] || ''
|
||||
const cp95Column = summaryTable.match(/<el-table-column[^>]*label="CP95缺失率"[^>]*>/)?.[0] || ''
|
||||
const maxMissingColumn =
|
||||
summaryTable.match(/<el-table-column[^>]*prop="maxContinuousMissingMinutes"[^>]*>/)?.[0] || ''
|
||||
const operationColumn = summaryTable.match(/<el-table-column[^>]*label="操作"[^>]*>/)?.[0] || ''
|
||||
const stretchColumns = [
|
||||
hasDataColumn,
|
||||
missingRateColumn,
|
||||
avgColumn,
|
||||
maxColumn,
|
||||
minColumn,
|
||||
cp95Column,
|
||||
maxMissingColumn
|
||||
]
|
||||
|
||||
const taskTable = read(files.taskTable)
|
||||
const operationSlot = taskTable.match(/<template #operation="\{ row \}">[\s\S]*?<\/template>/)?.[0] || ''
|
||||
return (
|
||||
/min-width="208"/.test(indicatorColumn) &&
|
||||
/min-width="120"/.test(hasDataColumn) &&
|
||||
/min-width="130"/.test(missingRateColumn) &&
|
||||
/min-width="130"/.test(avgColumn) &&
|
||||
/min-width="130"/.test(maxColumn) &&
|
||||
/min-width="130"/.test(minColumn) &&
|
||||
/min-width="140"/.test(cp95Column) &&
|
||||
/min-width="150"/.test(maxMissingColumn) &&
|
||||
/width="96"/.test(operationColumn) &&
|
||||
stretchColumns.every(column => /min-width=/.test(column) && !/\swidth=/.test(column)) &&
|
||||
stretchColumns.every(column => /align="center"/.test(column)) &&
|
||||
/align="center"/.test(operationColumn) &&
|
||||
!/align=/.test(indicatorColumn)
|
||||
/v-if="row\.taskStatus === 'FAIL'"/.test(operationSlot) &&
|
||||
/emit\('restart', row\)/.test(operationSlot) &&
|
||||
/restart: \[row: SteadyDataView\.SteadyChecksquareTask\]/.test(taskTable) &&
|
||||
/RefreshRight/.test(taskTable)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'workbench query card follows steady data view toolbar sizing',
|
||||
'task detail opens from abnormal item count value',
|
||||
() => {
|
||||
const taskTable = read(files.taskTable)
|
||||
return (
|
||||
/prop:\s*'abnormalItemCount'[\s\S]*ElButton[\s\S]*type:\s*'primary'[\s\S]*link:\s*true[\s\S]*emit\('detail', row\)/.test(
|
||||
taskTable
|
||||
) && /resolveChecksquareText\(row\.abnormalItemCount\)/.test(taskTable)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'task table query params convert time range and abnormal filter',
|
||||
() =>
|
||||
/buildChecksquareTaskQueryParams/.test(read(files.taskTable)) &&
|
||||
/taskTimeRange/.test(read(files.taskTableUtils)) &&
|
||||
/hasAbnormal/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'workbench remains create dialog selector body',
|
||||
() => /SteadyLedgerTree/.test(read(files.workbench)) && /TimePeriodSearch/.test(read(files.workbench))
|
||||
],
|
||||
[
|
||||
'shared ledger tree emits checked leaf monitor points for checksquare create payload',
|
||||
() => /getCheckedNodes\(\s*true\s*,\s*false\s*\)/.test(read(path.resolve(rootDir, 'views/steady/steadyDataView/components/SteadyLedgerTree.vue')))
|
||||
],
|
||||
[
|
||||
'workbench emits create instead of old query action',
|
||||
() => /create: \[\]/.test(read(files.workbench)) && !/query: \[\]/.test(read(files.workbench))
|
||||
],
|
||||
['workbench no longer renders result table', () => !/ChecksquareSummaryTable/.test(read(files.workbench))],
|
||||
[
|
||||
'workbench create action uses short add label',
|
||||
() => /@click="emit\('create'\)"[\s\S]*>\s*新增\s*<\/el-button>/.test(read(files.workbench))
|
||||
],
|
||||
[
|
||||
'create dialog workbench places search controls in two rows with actions after indicator',
|
||||
() => {
|
||||
const workbench = read(files.workbench)
|
||||
return (
|
||||
/\.query-card\s*\{[\s\S]*display:\s*grid[\s\S]*grid-template-columns:\s*minmax\(430px,\s*1\.35fr\)\s+minmax\(0,\s*1fr\)\s+auto[\s\S]*gap:\s*10px[\s\S]*align-items:\s*center[\s\S]*padding:\s*12px/.test(
|
||||
/\.query-card\s*\{[\s\S]*display:\s*flex[\s\S]*flex-wrap:\s*wrap/.test(workbench) &&
|
||||
/\.toolbar-field--time\s*\{[\s\S]*flex:\s*1\s+1\s+100%/.test(workbench) &&
|
||||
/\.indicator-form-item\s*\{[\s\S]*order:\s*2[\s\S]*flex:\s*1\s+1\s+auto/.test(workbench) &&
|
||||
/\.query-actions\s*\{[\s\S]*order:\s*3[\s\S]*flex:\s*0\s+0\s+auto/.test(workbench) &&
|
||||
/<div class="query-actions">[\s\S]*emit\('create'\)[\s\S]*emit\('reset'\)[\s\S]*<\/div>\s*<div class="toolbar-field indicator-form-item">/.test(
|
||||
workbench
|
||||
) &&
|
||||
/\.checksquare-time\s*\{[\s\S]*flex:\s*1\s+1\s+0[\s\S]*min-width:\s*0/.test(workbench) &&
|
||||
/\.checksquare-time\s*:deep\(\.time-period-search__unit\)\s*\{[\s\S]*width:\s*88px[\s\S]*flex:\s*0\s+0\s+88px/.test(
|
||||
workbench
|
||||
) &&
|
||||
/\.checksquare-time\s*:deep\(\.time-period-search__picker\)\s*\{[\s\S]*width:\s*136px[\s\S]*flex:\s*0\s+0\s+136px/.test(
|
||||
workbench
|
||||
) &&
|
||||
/\.query-actions\s*\{[\s\S]*display:\s*flex[\s\S]*justify-content:\s*flex-end[\s\S]*gap:\s*8px/.test(workbench)
|
||||
)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table exposes detail action',
|
||||
() => /详情/.test(read(files.summaryTable)) && /emit\('detail'/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'workbench shows detail in dialog instead of inline panel',
|
||||
'payload builds create params without harmonic orders',
|
||||
() =>
|
||||
/<el-dialog/.test(read(files.workbench)) &&
|
||||
/ChecksquareDetailPanel/.test(read(files.workbench)) &&
|
||||
!/class="content-detail"/.test(read(files.workbench))
|
||||
/buildSteadyChecksquareCreatePayload/.test(read(files.payload)) &&
|
||||
!/harmonicOrder/.test(read(files.payload))
|
||||
],
|
||||
[
|
||||
'page builds pending rows from selected indicators',
|
||||
() => /buildPendingChecksquareResult/.test(read(files.page)) && /refreshPendingResult/.test(read(files.page))
|
||||
],
|
||||
[
|
||||
'page queries indicators sequentially',
|
||||
() => /for \(const indicator of queryIndicators\)/.test(read(files.page)) && /mergeChecksquareIndicatorResult/.test(read(files.page))
|
||||
],
|
||||
[
|
||||
'page queries harmonic orders with controlled concurrency',
|
||||
() =>
|
||||
/CHECKSQUARE_HARMONIC_QUERY_CONCURRENCY\s*=\s*6/.test(read(files.page)) &&
|
||||
/runChecksquareHarmonicQuery/.test(read(files.page)) &&
|
||||
/workers = Array\.from\(\{[\s\S]*length: Math\.min\(CHECKSQUARE_HARMONIC_QUERY_CONCURRENCY/.test(read(files.page)) &&
|
||||
/await Promise\.all\(workers\)/.test(read(files.page)) &&
|
||||
/const harmonicOrders = \[\.\.\.CHECKSQUARE_HARMONIC_ORDERS\]/.test(read(files.page)) &&
|
||||
/if \(orderIndex >= harmonicOrders\.length\) return/.test(read(files.page))
|
||||
],
|
||||
[
|
||||
'table pre-creates harmonic rows from second to fiftieth order',
|
||||
() =>
|
||||
/CHECKSQUARE_HARMONIC_ORDER_MIN\s*=\s*2/.test(read(files.table)) &&
|
||||
/CHECKSQUARE_HARMONIC_ORDER_MAX\s*=\s*50/.test(read(files.table)) &&
|
||||
/CHECKSQUARE_HARMONIC_ORDER_MAX - CHECKSQUARE_HARMONIC_ORDER_MIN \+ 1/.test(read(files.table)) &&
|
||||
/children: isChecksquareHarmonicIndicator\(indicator\)\s*\?\s*buildPendingChecksquareHarmonicItems/.test(
|
||||
read(files.table)
|
||||
)
|
||||
],
|
||||
[
|
||||
'table only merges indicators whose harmonic order range intersects second to fiftieth order',
|
||||
'payload supports multi monitor point create params',
|
||||
() => {
|
||||
const table = read(files.table)
|
||||
const payload = read(files.payload)
|
||||
const page = read(files.page)
|
||||
return (
|
||||
/CHECKSQUARE_HARMONIC_ORDER_MIN/.test(table) &&
|
||||
/CHECKSQUARE_HARMONIC_ORDER_MAX/.test(table) &&
|
||||
/hasChecksquareHarmonicOrderRange/.test(table) &&
|
||||
/isChecksquareHarmonicIndicator[\s\S]*hasChecksquareHarmonicOrderRange\(indicator\)/.test(table) &&
|
||||
/const shouldMergeHarmonicItems\s*=\s*isChecksquareHarmonicIndicator\(indicator\)/.test(table) &&
|
||||
/const normalItems\s*=\s*shouldMergeHarmonicItems[\s\S]*resultItems/.test(table) &&
|
||||
/const harmonicItems\s*=\s*shouldMergeHarmonicItems[\s\S]*\[\]/.test(table)
|
||||
/buildSteadyChecksquareCreatePayload\s*=\s*\(\s*lineIds:\s*string\[\]/.test(payload) &&
|
||||
/lineIds,/.test(payload) &&
|
||||
!/lineId:\s*lineIds\[0\]/.test(payload) &&
|
||||
!/lineIds\.length > 1/.test(payload) &&
|
||||
/buildSteadyChecksquareCreatePayload\(lineIds\.value,\s*selectedIndicators\.value,\s*formState\.value\)/.test(
|
||||
page
|
||||
) &&
|
||||
!/buildSteadyChecksquareCreatePayload\(lineIds\.value\[0\]/.test(page)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'table summarizes harmonic parent after all orders finish',
|
||||
() =>
|
||||
/buildHarmonicParentSummary/.test(read(files.table)) &&
|
||||
/every\(item => isResolvedChecksquareItem\(item\)\)/.test(read(files.table)) &&
|
||||
/missingPointCount \/ expectedPointCount/.test(read(files.table))
|
||||
'payload allows empty indicator selection for full indicator checks',
|
||||
() => {
|
||||
const payload = read(files.payload)
|
||||
const page = read(files.page)
|
||||
return (
|
||||
!/if\s*\(!indicators\.length\)\s*return\s*'请选择指标'/.test(payload) &&
|
||||
/indicatorCodes:\s*collectChecksquareIndicatorCodes\(indicators\)/.test(payload) &&
|
||||
/indicators:\s*selectedIndicators\.value/.test(page)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'table marks harmonic parent valid when every order child has data',
|
||||
() =>
|
||||
/hasData:\s*children\.every\(item => item\.hasData === true\),/.test(read(files.table)) &&
|
||||
!/children\.every\(item => \(item\.missingPointCount \|\| 0\) === 0\)/.test(read(files.table))
|
||||
'payload exposes expected item count calculation for selected or full indicators',
|
||||
() => {
|
||||
const payload = read(files.payload)
|
||||
return (
|
||||
/calculateChecksquareExpectedItemCount/.test(payload) &&
|
||||
/selectedIndicatorCount/.test(payload) &&
|
||||
/totalIndicatorCount/.test(payload) &&
|
||||
/lineCount/.test(payload) &&
|
||||
/selectedIndicatorCount > 0 \? selectedIndicatorCount : totalIndicatorCount/.test(payload)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'table keeps harmonic row keys stable while merging returned order results',
|
||||
'page renders task table as first screen',
|
||||
() =>
|
||||
/normalizeChecksquareResultItemKey/.test(read(files.table)) &&
|
||||
/normalizeChecksquareResultItemKey\([\s\S]*child\.itemKey/.test(read(files.table)) &&
|
||||
/resolveChecksquareHarmonicOrder/.test(read(files.table)) &&
|
||||
/resolveChecksquareHarmonicOrder\(item\) === child\.harmonicOrder/.test(read(files.table))
|
||||
/<ChecksquareTaskTable[\s\S]*@create-task="openCreateDialog"[\s\S]*@detail="openTaskDetail"[\s\S]*@delete="handleDeleteTask"/.test(
|
||||
read(files.page)
|
||||
)
|
||||
],
|
||||
[
|
||||
'table formats harmonic parent progress before final summary is ready',
|
||||
'page passes steady ledger and indicator trees to task table filters',
|
||||
() =>
|
||||
/resolveChecksquareRowName[\s\S]*getHarmonicProgressText/.test(read(files.table)) &&
|
||||
/已完成 \$\{resolvedCount\}\/\$\{totalCount\}/.test(read(files.table))
|
||||
/<ChecksquareTaskTable[\s\S]*:ledger-tree="ledgerTree"[\s\S]*:indicator-tree="indicatorTree"/.test(
|
||||
read(files.page)
|
||||
)
|
||||
],
|
||||
[
|
||||
'page keeps selected checksquare detail synced after async row replacement',
|
||||
'task table receives steady ledger and indicator tree filter data',
|
||||
() =>
|
||||
/syncSelectedItemWithLatestResult/.test(read(files.page)) &&
|
||||
/selectedItem\.value\.itemKey/.test(read(files.page)) &&
|
||||
/mergeChecksquareIndicatorResult\(queryResult\.value/.test(read(files.page))
|
||||
/ledgerTree:\s*SteadyDataView\.SteadyLedgerNode\[\]/.test(read(files.taskTable)) &&
|
||||
/indicatorTree:\s*SteadyDataView\.SteadyIndicatorNode\[\]/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'task table monitor point filter uses dropdown tree instead of lineId input',
|
||||
() =>
|
||||
/renderLineSearch/.test(read(files.taskTable)) &&
|
||||
/ElTreeSelect/.test(read(files.taskTable)) &&
|
||||
/multiple:\s*true/.test(read(files.taskTable)) &&
|
||||
/normalizeTreeSelectValues/.test(read(files.taskTable)) &&
|
||||
/checkStrictly:\s*true/.test(read(files.taskTable)) &&
|
||||
!/lineId[\s\S]*?el:\s*'input'/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'task table indicator code filter uses steady indicator tree selection',
|
||||
() =>
|
||||
/renderIndicatorSearch/.test(read(files.taskTable)) &&
|
||||
/indicatorFilterTree/.test(read(files.taskTable)) &&
|
||||
/multiple:\s*true/.test(read(files.taskTable)) &&
|
||||
/normalizeTreeSelectValues/.test(read(files.taskTable)) &&
|
||||
/indicatorCode/.test(read(files.taskTable)) &&
|
||||
/style:\s*\{\s*width:\s*'100%'\s*\}/.test(read(files.taskTable)) &&
|
||||
!/indicatorCode[\s\S]*?el:\s*'input'/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'task table displays indicator code filter as steady indicator',
|
||||
() =>
|
||||
/label:\s*'稳态指标'/.test(read(files.taskTable)) &&
|
||||
/placeholder:\s*'请选择稳态指标'/.test(read(files.taskTable)) &&
|
||||
!/label:\s*'指标编码'/.test(read(files.taskTable)) &&
|
||||
!/placeholder:\s*'请选择指标编码'/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'task table tree select filters keep selected tags visible',
|
||||
() => {
|
||||
const taskTable = read(files.taskTable)
|
||||
return (
|
||||
/class:\s*'checksquare-search-tree-select'/.test(taskTable) &&
|
||||
/maxCollapseTags:\s*1/.test(taskTable) &&
|
||||
/\.checksquare-search-tree-select\s*\{[\s\S]*width:\s*100%/.test(taskTable) &&
|
||||
/:deep\(\.checksquare-search-tree-select \.el-select__tags-text\)[\s\S]*max-width/.test(taskTable)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'create dialog indicator select keeps selected tags from resizing input',
|
||||
() => {
|
||||
const workbench = read(files.workbench)
|
||||
return (
|
||||
/class="indicator-tree-select"/.test(workbench) &&
|
||||
/collapse-tags/.test(workbench) &&
|
||||
/\.indicator-tree-select\s*:deep\(\.el-select__wrapper\)[\s\S]*height:\s*32px/.test(workbench) &&
|
||||
/\.indicator-tree-select\s*:deep\(\.el-select__selection\)[\s\S]*width:\s*0[\s\S]*height:\s*24px[\s\S]*overflow:\s*hidden/.test(
|
||||
workbench
|
||||
) &&
|
||||
/\.indicator-tree-select\s*:deep\(\.el-select__tags\)[\s\S]*height:\s*24px[\s\S]*overflow:\s*hidden[\s\S]*flex-wrap:\s*nowrap/.test(
|
||||
workbench
|
||||
) &&
|
||||
/\.indicator-tree-select\s*:deep\(\.el-tag\)[\s\S]*height:\s*22px[\s\S]*overflow:\s*hidden/.test(
|
||||
workbench
|
||||
)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'task table tree select filters use scrollable dropdowns',
|
||||
() => {
|
||||
const taskTable = read(files.taskTable)
|
||||
return (
|
||||
/popperClass:\s*'checksquare-search-tree-popper'/.test(taskTable) &&
|
||||
/\.checksquare-search-tree-popper[\s\S]*\.el-select-dropdown__wrap[\s\S]*max-height:\s*280px/.test(
|
||||
taskTable
|
||||
)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'task table monitor point name opens measurement point dialog like event list',
|
||||
() => {
|
||||
const taskTable = read(files.taskTable)
|
||||
return (
|
||||
/viewMeasurementPoint:\s*\[row: SteadyDataView\.SteadyChecksquareTask\]/.test(taskTable) &&
|
||||
/prop:\s*'lineName'[\s\S]*ElButton[\s\S]*type:\s*'primary'[\s\S]*link:\s*true[\s\S]*emit\('viewMeasurementPoint', row\)/.test(
|
||||
taskTable
|
||||
)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'checksquare measurement point dialog matches event list fields',
|
||||
() => {
|
||||
const dialog = read(files.measurementPointDialog)
|
||||
return (
|
||||
exists(files.measurementPointDialog) &&
|
||||
/name:\s*'ChecksquareMeasurementPointDialog'/.test(dialog) &&
|
||||
/dialogTitle\s*=\s*'监测点信息'/.test(dialog) &&
|
||||
/工程名称/.test(dialog) &&
|
||||
/项目名称/.test(dialog) &&
|
||||
/设备名称/.test(dialog) &&
|
||||
/网络参数/.test(dialog) &&
|
||||
/监测点名称/.test(dialog) &&
|
||||
/resolveText/.test(dialog)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'checksquare ledger utils resolve monitor point detail from loaded ledger tree',
|
||||
() => {
|
||||
const source = read(files.ledgerUtils)
|
||||
return (
|
||||
exists(files.ledgerUtils) &&
|
||||
/resolveChecksquareMeasurementPointDetail/.test(source) &&
|
||||
/engineeringName/.test(source) &&
|
||||
/projectName/.test(source) &&
|
||||
/equipmentName/.test(source) &&
|
||||
/lineName/.test(source) &&
|
||||
/networkParam/.test(source)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'page wires checksquare measurement point dialog to task table',
|
||||
() => {
|
||||
const page = read(files.page)
|
||||
return (
|
||||
/@view-measurement-point="openMeasurementPointDialog"/.test(page) &&
|
||||
/<ChecksquareMeasurementPointDialog[\s\S]*v-model:visible="measurementPointDialogVisible"[\s\S]*:data="measurementPointData"/.test(
|
||||
page
|
||||
) &&
|
||||
/resolveChecksquareMeasurementPointDetail/.test(page)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'search grid keeps third filter visible when operation column exactly fills first row',
|
||||
() => /Number\(prev\)\s*>\s*props\.collapsedRows \* gridCols\.value - suffixCols/.test(read(files.grid))
|
||||
],
|
||||
[
|
||||
'search collapse toggle only appears when filters exceed available first row columns',
|
||||
() =>
|
||||
/const searchColCount[\s\S]*typeof props\.searchCol !== 'number'[\s\S]*props\.searchCol\[breakPoint\.value\][\s\S]*const firstRowSearchCols[\s\S]*Math\.max\(searchColCount - 1,\s*1\)[\s\S]*prev\s*>\s*firstRowSearchCols/.test(
|
||||
read(files.searchForm)
|
||||
)
|
||||
],
|
||||
[
|
||||
'checksquare task search grid follows event list five-column layout',
|
||||
() => /:search-col="\{\s*xs:\s*1,\s*sm:\s*2,\s*md:\s*2,\s*lg:\s*5,\s*xl:\s*5\s*\}"/.test(read(files.taskTable))
|
||||
],
|
||||
[
|
||||
'custom search render does not receive generic form item v-model',
|
||||
() =>
|
||||
/v-if=['"]!column\.search\?\.render['"]/.test(read(files.searchFormItem)) &&
|
||||
/v-else[\s\S]*:is="column\.search\.render"/.test(read(files.searchFormItem))
|
||||
],
|
||||
[
|
||||
'page wraps old workbench in create dialog',
|
||||
() =>
|
||||
/<el-dialog[\s\S]*新增校验任务[\s\S]*width="960px"[\s\S]*<ChecksquareWorkbench/.test(read(files.page)) &&
|
||||
/\.checksquare-create-dialog\s*\{[\s\S]*height:\s*560px/.test(read(files.page))
|
||||
],
|
||||
[
|
||||
'page create flow calls create api, then polls task list status and refreshes task table',
|
||||
() => {
|
||||
const page = read(files.page)
|
||||
return (
|
||||
/createSteadyChecksquareTask/.test(page) &&
|
||||
/querySteadyChecksquareTasks\(buildCreateTaskStatusQuery\(activeCreateTask\.value\)\)/.test(page) &&
|
||||
!/getSteadyChecksquareDetail\(createdTask\.taskId\)/.test(page) &&
|
||||
!/getOrCreateSteadyChecksquareTask/.test(page) &&
|
||||
/startCreateTaskPolling\(createdTask\.taskId\)/.test(page) &&
|
||||
/taskTableRef\.value\?\.refresh\(\)/.test(page) &&
|
||||
/activeCreateTask\.value/.test(page)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'create dialog shows create task summary without detail table',
|
||||
() => {
|
||||
const page = read(files.page)
|
||||
const workbench = read(files.workbench)
|
||||
const panel = read(files.createResultPanel)
|
||||
return (
|
||||
exists(files.createResultPanel) &&
|
||||
/<template #result>[\s\S]*<ChecksquareCreateResultPanel[\s\S]*:task="activeCreateTask"[\s\S]*:loading="loading\.query"[\s\S]*<\/template>/.test(
|
||||
page
|
||||
) &&
|
||||
/activeCreateTask\.value\s*=\s*null[\s\S]*loading\.query\s*=\s*true/.test(page) &&
|
||||
/:disabled="loading\.query"/.test(workbench) &&
|
||||
/\.checksquare-create-dialog\s*\{[\s\S]*display:\s*block/.test(page) &&
|
||||
/<slot name="result" \/>/.test(workbench) &&
|
||||
/\.checksquare-main\s*\{[\s\S]*display:\s*flex[\s\S]*flex-direction:\s*column/.test(workbench) &&
|
||||
/\.checksquare-layout\s*\{[\s\S]*grid-template-columns:\s*240px\s+minmax\(0,\s*1fr\)/.test(workbench) &&
|
||||
/\.checksquare-result-slot\s*\{[\s\S]*width:\s*100%/.test(workbench) &&
|
||||
/\.checksquare-result-slot\s*\{[\s\S]*min-width:\s*0/.test(workbench) &&
|
||||
/\.checksquare-result-slot\s*:deep\(\.checksquare-result-panel\)\s*\{[\s\S]*height:\s*100%/.test(
|
||||
workbench
|
||||
) &&
|
||||
/name:\s*'ChecksquareCreateResultPanel'/.test(panel) &&
|
||||
/loading\?:\s*boolean/.test(panel) &&
|
||||
!/detail:\s*SteadyDataView\.SteadyChecksquareQueryResult \| null/.test(panel) &&
|
||||
/expectedItemCount:\s*number/.test(panel) &&
|
||||
/:expected-item-count="expectedCreateItemCount"/.test(page) &&
|
||||
/v-if="loading"/.test(panel) &&
|
||||
/正在创建校验任务/.test(panel) &&
|
||||
/class="result-scroll"/.test(panel) &&
|
||||
/class="result-overview"/.test(panel) &&
|
||||
/class="result-body"/.test(panel) &&
|
||||
!/class="result-items"/.test(panel) &&
|
||||
!/detailItems/.test(panel) &&
|
||||
/class="result-detail-grid"/.test(panel) &&
|
||||
!/detail-block--wide/.test(panel) &&
|
||||
/\.result-overview\s*\{[\s\S]*grid-template-columns:\s*minmax\(0,\s*1fr\)/.test(panel) &&
|
||||
/\.result-metrics\s*\{[\s\S]*grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\)/.test(panel) &&
|
||||
/\.result-detail-grid\s*\{[^}]*grid-template-columns:\s*repeat\(2,\s*minmax\(0,\s*1fr\)\)/.test(
|
||||
panel
|
||||
) &&
|
||||
!/class="result-tips"/.test(panel) &&
|
||||
!/class="tips-title"/.test(panel) &&
|
||||
!/class="tips-list"/.test(panel) &&
|
||||
/class="result-metrics"[\s\S]*lineName[\s\S]*displayItemCount/.test(panel) &&
|
||||
/校验任务摘要/.test(panel) &&
|
||||
/displayItemCount/.test(panel) &&
|
||||
/props\.expectedItemCount/.test(panel) &&
|
||||
/task\.abnormalItemCount/.test(panel) &&
|
||||
/task\.minDataIntegrity/.test(panel) &&
|
||||
!/class="detail-label">任务编号/.test(panel) &&
|
||||
/\.result-body\s*\{[\s\S]*flex:\s*1/.test(panel) &&
|
||||
/\.result-scroll\s*\{[\s\S]*overflow-y:\s*auto/.test(panel) &&
|
||||
!/class="result-detail-table"/.test(panel) &&
|
||||
!/emit\('detail', row\)/.test(panel)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'create dialog polls running task status and clears polling lifecycle',
|
||||
() => {
|
||||
const page = read(files.page)
|
||||
return (
|
||||
/createTaskPollingTimer/.test(page) &&
|
||||
/startCreateTaskPolling/.test(page) &&
|
||||
/stopCreateTaskPolling/.test(page) &&
|
||||
/window\.setTimeout/.test(page) &&
|
||||
/window\.clearTimeout/.test(page) &&
|
||||
/CREATE_TASK_POLLING_INTERVALS/.test(page) &&
|
||||
/getCreateTaskPollingDelay/.test(page) &&
|
||||
/buildCreateTaskStatusQuery/.test(page) &&
|
||||
/isChecksquareTaskFinished/.test(page) &&
|
||||
/onBeforeUnmount\(stopCreateTaskPolling\)/.test(page) &&
|
||||
/watch\(createDialogVisible/.test(page) &&
|
||||
/refreshCreateTaskStatus/.test(page) &&
|
||||
!/refreshCreateTaskDetail/.test(page) &&
|
||||
/activeCreateTask\.value\s*=\s*\{\s*\.\.\.activeCreateTask\.value/.test(page)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'page delete flow confirms, calls delete api and refreshes task table',
|
||||
() =>
|
||||
/deleteSteadyChecksquareTasks/.test(read(files.page)) &&
|
||||
/ElMessageBox\.confirm/.test(read(files.page)) &&
|
||||
/deleteSteadyChecksquareTasks\(\[row\.taskId\]\)/.test(read(files.page)) &&
|
||||
/taskTableRef\.value\?\.refresh\(\)/.test(read(files.page))
|
||||
],
|
||||
[
|
||||
'page restart flow confirms, calls restart api and refreshes task table',
|
||||
() =>
|
||||
/@restart="handleRestartTask"/.test(read(files.page)) &&
|
||||
/restartSteadyChecksquareTask/.test(read(files.page)) &&
|
||||
/ElMessageBox\.confirm/.test(read(files.page)) &&
|
||||
/restartSteadyChecksquareTask\(row\.taskId\)/.test(read(files.page)) &&
|
||||
/taskTableRef\.value\?\.refresh\(\)/.test(read(files.page))
|
||||
],
|
||||
[
|
||||
'page detail flow calls detail api',
|
||||
() =>
|
||||
/getSteadyChecksquareDetail/.test(read(files.page)) &&
|
||||
/detailDialogVisible\.value = true/.test(read(files.page))
|
||||
],
|
||||
[
|
||||
'task detail and item detail dialogs use the same size',
|
||||
() => {
|
||||
const page = read(files.page)
|
||||
return (
|
||||
/v-model="detailDialogVisible"[\s\S]*?width="1080px"/.test(page) &&
|
||||
/v-model="itemDetailDialogVisible"[\s\S]*?width="1080px"/.test(page) &&
|
||||
/v-model="detailDialogVisible"[\s\S]*?class="checksquare-detail-dialog"/.test(page) &&
|
||||
/v-model="itemDetailDialogVisible"[\s\S]*?class="checksquare-detail-dialog"/.test(page) &&
|
||||
/\.checksquare-detail-dialog\s*\{[\s\S]*height:\s*560px/.test(page)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table supports persisted abnormal fields',
|
||||
() =>
|
||||
/abnormalPointCount/.test(read(files.summaryTable)) &&
|
||||
/harmonicParityAbnormalPointCount/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'summary table renders positive abnormal counts in danger color',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
return (
|
||||
/hasAbnormalCount/.test(summaryTable) &&
|
||||
/:class="\{\s*'is-abnormal-count': hasAbnormalCount\(row\.abnormalPointCount\)\s*\}"/.test(
|
||||
summaryTable
|
||||
) &&
|
||||
/:class="\{\s*'is-abnormal-count': hasAbnormalCount\(row\.harmonicParityAbnormalPointCount\)\s*\}"/.test(
|
||||
summaryTable
|
||||
) &&
|
||||
/\.is-abnormal-count\s*\{[\s\S]*color:\s*var\(--el-color-danger\)/.test(summaryTable)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table groups data integrity columns under compact double header',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
const dataIntegrityGroup =
|
||||
summaryTable.match(
|
||||
/<el-table-column label="数据完整性"[\s\S]*?<\/el-table-column>\s*<el-table-column label="操作"/
|
||||
)?.[0] || ''
|
||||
|
||||
return (
|
||||
/label="数据完整性"/.test(dataIntegrityGroup) &&
|
||||
/prop="hasData" label="是否有数据" width="88"/.test(dataIntegrityGroup) &&
|
||||
/prop="dataIntegrity" label="总体\(%\)" width="88"/.test(dataIntegrityGroup) &&
|
||||
/label="平均值\(%\)" width="88"/.test(dataIntegrityGroup) &&
|
||||
/label="最大值\(%\)" width="88"/.test(dataIntegrityGroup) &&
|
||||
/label="最小值\(%\)" width="88"/.test(dataIntegrityGroup) &&
|
||||
/label="CP95值\(%\)" width="88"/.test(dataIntegrityGroup)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table removes percent unit from data integrity cell values',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
return (
|
||||
/stripPercentUnit/.test(summaryTable) &&
|
||||
/formatSummaryDataIntegrity/.test(summaryTable) &&
|
||||
/formatSummaryStatIntegrity/.test(summaryTable) &&
|
||||
/formatSummaryDataIntegrity\(row\)/.test(summaryTable) &&
|
||||
/formatSummaryStatIntegrity\(row,\s*'AVG'\)/.test(summaryTable) &&
|
||||
/formatSummaryStatIntegrity\(row,\s*'MAX'\)/.test(summaryTable) &&
|
||||
/formatSummaryStatIntegrity\(row,\s*'MIN'\)/.test(summaryTable) &&
|
||||
/formatSummaryStatIntegrity\(row,\s*'CP95'\)/.test(summaryTable)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table keeps abnormal and operation columns compact',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
return (
|
||||
/prop="abnormalPointCount" label="值关系异常点" width="88"/.test(summaryTable) &&
|
||||
/prop="harmonicParityAbnormalPointCount" label="谐波奇偶异常点" width="88"/.test(summaryTable) &&
|
||||
/<el-table-column label="操作" width="130"/.test(summaryTable)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table keeps indicator name column at configured width',
|
||||
() => /prop="indicatorName" label="指标名称" width="160"/.test(read(files.summaryTable))
|
||||
],
|
||||
[
|
||||
'summary table displays monitor point name before indicator name',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
const lineNameIndex = summaryTable.indexOf('label="监测点名称"')
|
||||
const indicatorIndex = summaryTable.indexOf('prop="indicatorName"')
|
||||
|
||||
return (
|
||||
/resolveChecksquareLineName/.test(summaryTable) &&
|
||||
/:title="resolveChecksquareLineName\(row\)"/.test(summaryTable) &&
|
||||
/row\.lineName\s*\|\|\s*row\.lineId\s*\|\|\s*props\.result\?\.lineName\s*\|\|\s*props\.result\?\.lineId/.test(
|
||||
summaryTable
|
||||
) &&
|
||||
lineNameIndex >= 0 &&
|
||||
indicatorIndex > lineNameIndex
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table places abnormal fields after indicator name and hides max continuous missing column',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
const indicatorIndex = summaryTable.indexOf('prop="indicatorName"')
|
||||
const valueOrderIndex = summaryTable.indexOf('prop="abnormalPointCount"')
|
||||
const harmonicParityIndex = summaryTable.indexOf('prop="harmonicParityAbnormalPointCount"')
|
||||
const hasDataIndex = summaryTable.indexOf('prop="hasData"')
|
||||
|
||||
return (
|
||||
!/prop="maxContinuousMissingMinutes"/.test(summaryTable) &&
|
||||
indicatorIndex >= 0 &&
|
||||
valueOrderIndex > indicatorIndex &&
|
||||
harmonicParityIndex > valueOrderIndex &&
|
||||
hasDataIndex > harmonicParityIndex
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'checksquare display uses documented data integrity fields instead of missing rate fields',
|
||||
() => {
|
||||
const types = read(files.apiTypes)
|
||||
const taskTable = read(files.taskTable)
|
||||
const summaryTable = read(files.summaryTable)
|
||||
const tableUtils = read(files.table)
|
||||
const taskTableUtils = read(files.taskTableUtils)
|
||||
|
||||
return (
|
||||
/minDataIntegrity\?: number \| null/.test(types) &&
|
||||
/dataIntegrity\?: number \| null/.test(types) &&
|
||||
/dataIntegrityText\?: string \| null/.test(types) &&
|
||||
/prop:\s*'minDataIntegrity'/.test(taskTable) &&
|
||||
/formatChecksquareIntegrity/.test(taskTableUtils) &&
|
||||
/prop="dataIntegrity"/.test(summaryTable) &&
|
||||
/formatDataIntegrity/.test(tableUtils) &&
|
||||
!/maxMissingRate/.test(types) &&
|
||||
!/missingRate/.test(types) &&
|
||||
!/maxContinuousMissingMinutes/.test(types) &&
|
||||
!/maxMissingRate/.test(taskTable) &&
|
||||
!/missingRate/.test(summaryTable) &&
|
||||
!/missingRate/.test(tableUtils) &&
|
||||
!/missingRate/.test(taskTableUtils)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'checksquare task status follows documented FAIL value',
|
||||
() => {
|
||||
const source = read(files.taskTableUtils)
|
||||
const types = read(files.apiTypes)
|
||||
|
||||
return (
|
||||
/taskStatus\?: 'RUNNING' \| 'SUCCESS' \| 'FAIL' \| string/.test(types) &&
|
||||
/status === 'FAIL'/.test(source) &&
|
||||
!/FAILED/.test(source)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'detail dialog shows integrity overview and documented point counts',
|
||||
() => {
|
||||
const detailPanel = read(files.detailPanel)
|
||||
|
||||
return (
|
||||
/formatDataIntegrity/.test(detailPanel) &&
|
||||
/selectedItem\.dataIntegrity/.test(detailPanel) &&
|
||||
/selectedItem\.dataIntegrityText/.test(detailPanel) &&
|
||||
/selectedItem\.expectedPointCount/.test(detailPanel) &&
|
||||
/selectedItem\.actualPointCount/.test(detailPanel) &&
|
||||
/selectedItem\.missingPointCount/.test(detailPanel)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'detail panel loads item details on demand',
|
||||
() =>
|
||||
/getSteadyChecksquareItemDetail/.test(read(files.detailPanel)) && /detailType/.test(read(files.detailPanel))
|
||||
],
|
||||
[
|
||||
'item detail api types support documented pagination fields',
|
||||
() => {
|
||||
const types = read(files.apiTypes)
|
||||
return (
|
||||
/interface SteadyChecksquareItemDetailParams[\s\S]*pageNum\?: number[\s\S]*pageSize\?: number/.test(
|
||||
types
|
||||
) &&
|
||||
/interface SteadyChecksquareItemDetail[\s\S]*pageNum\?: number \| null[\s\S]*pageSize\?: number \| null[\s\S]*total\?: number \| null/.test(
|
||||
types
|
||||
)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'summary table displays documented task base fields',
|
||||
() => {
|
||||
const summaryTable = read(files.summaryTable)
|
||||
return /任务编号/.test(summaryTable) && /检测时间/.test(summaryTable) && /result\.taskNo/.test(summaryTable)
|
||||
}
|
||||
],
|
||||
[
|
||||
'detail panel paginates abnormal item details with documented page size',
|
||||
() => {
|
||||
const detailPanel = read(files.detailPanel)
|
||||
return (
|
||||
/DETAIL_PAGE_SIZE\s*=\s*20/.test(detailPanel) &&
|
||||
/detailPageNum/.test(detailPanel) &&
|
||||
/pageNum:[\s\S]*detailPageNum\.value/.test(detailPanel) &&
|
||||
/pageSize:[\s\S]*DETAIL_PAGE_SIZE/.test(detailPanel) &&
|
||||
/<el-pagination/.test(detailPanel)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'detail panel renders documented detail fields',
|
||||
() => {
|
||||
const detailPanel = read(files.detailPanel)
|
||||
return (
|
||||
/prop="status"[\s\S]*状态/.test(detailPanel) &&
|
||||
/prop="startTime" label="开始时间"/.test(detailPanel) &&
|
||||
/prop="endTime" label="结束时间"/.test(detailPanel) &&
|
||||
/oddHarmonicOrders/.test(detailPanel) &&
|
||||
/oddValues/.test(detailPanel)
|
||||
)
|
||||
}
|
||||
],
|
||||
[
|
||||
'detail panel table follows task detail table container style',
|
||||
() => {
|
||||
const detailPanel = read(files.detailPanel)
|
||||
return (
|
||||
/<section class="table-main card checksquare-detail">/.test(detailPanel) &&
|
||||
/<el-tabs/.test(detailPanel) &&
|
||||
/<el-tab-pane label="缺数区间" name="SEGMENT">/.test(detailPanel) &&
|
||||
/<el-tab-pane label="值关系异常" name="VALUE_ORDER">/.test(detailPanel) &&
|
||||
/<el-tab-pane label="谐波奇偶异常" name="HARMONIC_PARITY">/.test(detailPanel) &&
|
||||
/class="detail-table"/.test(detailPanel) &&
|
||||
/height="100%"/.test(detailPanel) &&
|
||||
!/max-height="300"/.test(detailPanel) &&
|
||||
!/section-title/.test(detailPanel) &&
|
||||
!/section-description/.test(detailPanel) &&
|
||||
!/Refresh/.test(detailPanel) &&
|
||||
/\.detail-table :deep\(\.el-table__header \.cell\),[\s\S]*\.detail-table :deep\(\.el-table__body \.cell\)[\s\S]*text-align:\s*center/.test(
|
||||
detailPanel
|
||||
)
|
||||
)
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
@@ -1,35 +1,80 @@
|
||||
<template>
|
||||
<div class="table-box checksquare-page">
|
||||
<ChecksquareWorkbench
|
||||
v-model:form="formState"
|
||||
v-model:ledger-panel-collapsed="ledgerPanelCollapsed"
|
||||
<ChecksquareTaskTable
|
||||
ref="taskTableRef"
|
||||
:ledger-tree="ledgerTree"
|
||||
:indicator-tree="indicatorTree"
|
||||
:result="queryResult"
|
||||
:selected-item="selectedItem"
|
||||
:loading="loading"
|
||||
:ledger-keyword="ledgerKeyword"
|
||||
:default-ledger-checked-keys="defaultLedgerCheckedKeys"
|
||||
:default-indicator-checked-keys="defaultIndicatorCheckedKeys"
|
||||
:selector-reset-key="selectorResetKey"
|
||||
@refresh-ledger="loadLedgerTree"
|
||||
@ledger-search="handleLedgerSearch"
|
||||
@ledger-change="handleLedgerChange"
|
||||
@indicator-change="handleIndicatorChange"
|
||||
@query="handleQuery"
|
||||
@reset="handleReset"
|
||||
@select-item="handleSelectItem"
|
||||
:request-api="querySteadyChecksquareTasks"
|
||||
@create-task="openCreateDialog"
|
||||
@detail="openTaskDetail"
|
||||
@restart="handleRestartTask"
|
||||
@delete="handleDeleteTask"
|
||||
@view-measurement-point="openMeasurementPointDialog"
|
||||
/>
|
||||
|
||||
<ChecksquareMeasurementPointDialog v-model:visible="measurementPointDialogVisible" :data="measurementPointData" />
|
||||
|
||||
<el-dialog v-model="createDialogVisible" title="新增校验任务" width="960px" append-to-body destroy-on-close>
|
||||
<div class="checksquare-create-dialog">
|
||||
<ChecksquareWorkbench
|
||||
v-model:form="formState"
|
||||
v-model:ledger-panel-collapsed="ledgerPanelCollapsed"
|
||||
:ledger-tree="ledgerTree"
|
||||
:indicator-tree="indicatorTree"
|
||||
:loading="loading"
|
||||
:ledger-keyword="ledgerKeyword"
|
||||
:default-ledger-checked-keys="defaultLedgerCheckedKeys"
|
||||
:default-indicator-checked-keys="defaultIndicatorCheckedKeys"
|
||||
:selector-reset-key="selectorResetKey"
|
||||
@refresh-ledger="loadLedgerTree"
|
||||
@ledger-search="handleLedgerSearch"
|
||||
@ledger-change="handleLedgerChange"
|
||||
@indicator-change="handleIndicatorChange"
|
||||
@create="handleCreateTask"
|
||||
@reset="handleReset"
|
||||
>
|
||||
<template #result>
|
||||
<ChecksquareCreateResultPanel
|
||||
:task="activeCreateTask"
|
||||
:loading="loading.query"
|
||||
:expected-item-count="expectedCreateItemCount"
|
||||
/>
|
||||
</template>
|
||||
</ChecksquareWorkbench>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="detailDialogVisible" title="校验任务详情" width="1080px" append-to-body destroy-on-close>
|
||||
<div v-loading="loading.detail" class="checksquare-detail-dialog">
|
||||
<ChecksquareSummaryTable
|
||||
:result="taskDetail"
|
||||
:items="taskDetail?.items || []"
|
||||
:loading="loading.detail"
|
||||
@refresh="refreshTaskDetail"
|
||||
@detail="openItemDetail"
|
||||
/>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="itemDetailDialogVisible" title="检测项明细" width="1080px" append-to-body destroy-on-close>
|
||||
<div class="checksquare-detail-dialog">
|
||||
<ChecksquareDetailPanel :selected-item="selectedItem" />
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import {
|
||||
createSteadyChecksquareTask,
|
||||
deleteSteadyChecksquareTasks,
|
||||
getSteadyChecksquareDetail,
|
||||
getSteadyTrendIndicatorTree,
|
||||
getSteadyTrendLedgerTree,
|
||||
querySteadyChecksquare
|
||||
querySteadyChecksquareTasks,
|
||||
restartSteadyChecksquareTask
|
||||
} from '@/api/steady/steadyDataView'
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
import {
|
||||
@@ -40,18 +85,22 @@ import {
|
||||
sortSteadyIndicatorTree
|
||||
} from '@/views/steady/steadyDataView/utils/selectionRules'
|
||||
import { normalizeSteadyLedgerTree } from '@/views/steady/steadyDataView/utils/ledgerTree'
|
||||
import ChecksquareCreateResultPanel from './components/ChecksquareCreateResultPanel.vue'
|
||||
import ChecksquareDetailPanel from './components/ChecksquareDetailPanel.vue'
|
||||
import ChecksquareMeasurementPointDialog from './components/ChecksquareMeasurementPointDialog.vue'
|
||||
import ChecksquareSummaryTable from './components/ChecksquareSummaryTable.vue'
|
||||
import ChecksquareTaskTable from './components/ChecksquareTaskTable.vue'
|
||||
import ChecksquareWorkbench from './components/ChecksquareWorkbench.vue'
|
||||
import {
|
||||
buildSteadyChecksquarePayload,
|
||||
resolveChecksquareMeasurementPointDetail,
|
||||
type ChecksquareMeasurementPointDetail
|
||||
} from './utils/checksquareLedger'
|
||||
import {
|
||||
buildSteadyChecksquareCreatePayload,
|
||||
calculateChecksquareExpectedItemCount,
|
||||
defaultChecksquareFormState,
|
||||
validateChecksquareSelection
|
||||
} from './utils/checksquarePayload'
|
||||
import {
|
||||
CHECKSQUARE_HARMONIC_ORDERS,
|
||||
buildPendingChecksquareResult,
|
||||
isChecksquareHarmonicIndicator,
|
||||
mergeChecksquareIndicatorResult
|
||||
} from './utils/checksquareTable'
|
||||
|
||||
defineOptions({
|
||||
name: 'ChecksquareView'
|
||||
@@ -61,29 +110,43 @@ const ledgerTree = ref<SteadyDataView.SteadyLedgerNode[]>([])
|
||||
const indicatorTree = ref<SteadyDataView.SteadyIndicatorNode[]>([])
|
||||
const selectedLedgerNodes = ref<SteadyDataView.SteadyLedgerNode[]>([])
|
||||
const selectedIndicators = ref<SteadyDataView.SteadyIndicatorNode[]>([])
|
||||
const queryResult = ref<SteadyDataView.SteadyChecksquareQueryResult | null>(null)
|
||||
const taskDetail = ref<SteadyDataView.SteadyChecksquareQueryResult | null>(null)
|
||||
const selectedTask = ref<SteadyDataView.SteadyChecksquareTask | null>(null)
|
||||
const selectedItem = ref<SteadyDataView.SteadyChecksquareItem | null>(null)
|
||||
const activeCreateTask = ref<SteadyDataView.SteadyChecksquareTask | null>(null)
|
||||
const measurementPointData = ref<ChecksquareMeasurementPointDetail | null>(null)
|
||||
const formState = ref(defaultChecksquareFormState())
|
||||
const ledgerKeyword = ref('')
|
||||
const ledgerPanelCollapsed = ref(false)
|
||||
const selectorResetKey = ref(0)
|
||||
const defaultLedgerCheckedKeys = ref<string[]>([])
|
||||
const defaultIndicatorCheckedKeys = ref<string[]>([])
|
||||
const createDialogVisible = ref(false)
|
||||
const detailDialogVisible = ref(false)
|
||||
const itemDetailDialogVisible = ref(false)
|
||||
const measurementPointDialogVisible = ref(false)
|
||||
const taskTableRef = ref<InstanceType<typeof ChecksquareTaskTable>>()
|
||||
const loading = reactive({
|
||||
ledger: false,
|
||||
indicator: false,
|
||||
query: false
|
||||
query: false,
|
||||
detail: false
|
||||
})
|
||||
let querySerial = 0
|
||||
let ledgerSearchTimer: ReturnType<typeof setTimeout> | null = null
|
||||
const CHECKSQUARE_HARMONIC_QUERY_CONCURRENCY = 6
|
||||
let createTaskPollingTimer: number | null = null
|
||||
let createTaskPollingRunning = false
|
||||
let createTaskPollingCount = 0
|
||||
const CREATE_TASK_POLLING_INTERVALS = [3000, 5000, 10000]
|
||||
|
||||
const lineIds = computed(() => collectSelectedLineIds(selectedLedgerNodes.value))
|
||||
|
||||
const refreshPendingResult = () => {
|
||||
queryResult.value = buildPendingChecksquareResult(selectedIndicators.value, formState.value)
|
||||
selectedItem.value = null
|
||||
}
|
||||
const totalIndicatorCount = computed(() => collectLeafIndicators(indicatorTree.value).length)
|
||||
const expectedCreateItemCount = computed(() =>
|
||||
calculateChecksquareExpectedItemCount({
|
||||
lineCount: lineIds.value.length,
|
||||
selectedIndicatorCount: selectedIndicators.value.length,
|
||||
totalIndicatorCount: totalIndicatorCount.value
|
||||
})
|
||||
)
|
||||
|
||||
const unwrapData = <T,>(response: { data: T } | T): T => {
|
||||
if (response && typeof response === 'object' && 'data' in response) {
|
||||
@@ -93,9 +156,11 @@ const unwrapData = <T,>(response: { data: T } | T): T => {
|
||||
return response as T
|
||||
}
|
||||
|
||||
const cancelCurrentQuery = () => {
|
||||
querySerial += 1
|
||||
loading.query = false
|
||||
const isChecksquareTaskFinished = (status?: string) => status === 'SUCCESS' || status === 'FAIL'
|
||||
|
||||
const getCreateTaskPollingDelay = () => {
|
||||
const index = Math.min(createTaskPollingCount, CREATE_TASK_POLLING_INTERVALS.length - 1)
|
||||
return CREATE_TASK_POLLING_INTERVALS[index]
|
||||
}
|
||||
|
||||
const loadLedgerTree = async (keyword = ledgerKeyword.value) => {
|
||||
@@ -126,6 +191,12 @@ const loadIndicatorTree = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const openCreateDialog = () => {
|
||||
stopCreateTaskPolling()
|
||||
activeCreateTask.value = null
|
||||
createDialogVisible.value = true
|
||||
}
|
||||
|
||||
const handleLedgerSearch = (value: string) => {
|
||||
ledgerKeyword.value = value
|
||||
if (ledgerSearchTimer) clearTimeout(ledgerSearchTimer)
|
||||
@@ -133,81 +204,120 @@ const handleLedgerSearch = (value: string) => {
|
||||
}
|
||||
|
||||
const handleLedgerChange = (nodes: SteadyDataView.SteadyLedgerNode[]) => {
|
||||
cancelCurrentQuery()
|
||||
selectedLedgerNodes.value = nodes
|
||||
}
|
||||
|
||||
const handleIndicatorChange = (nodes: SteadyDataView.SteadyIndicatorNode[]) => {
|
||||
cancelCurrentQuery()
|
||||
selectedIndicators.value = collectLeafIndicators(nodes)
|
||||
refreshPendingResult()
|
||||
}
|
||||
|
||||
const handleSelectItem = (item: SteadyDataView.SteadyChecksquareItem) => {
|
||||
selectedItem.value = item
|
||||
}
|
||||
|
||||
const findChecksquareItemByKey = (
|
||||
items: SteadyDataView.SteadyChecksquareItem[],
|
||||
itemKey: string
|
||||
): SteadyDataView.SteadyChecksquareItem | null => {
|
||||
for (const item of items) {
|
||||
if (item.itemKey === itemKey) return item
|
||||
const childItem = findChecksquareItemByKey(item.children || [], itemKey)
|
||||
if (childItem) return childItem
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
const syncSelectedItemWithLatestResult = () => {
|
||||
if (!selectedItem.value?.itemKey || !queryResult.value) return
|
||||
|
||||
selectedItem.value = findChecksquareItemByKey(queryResult.value.items || [], selectedItem.value.itemKey)
|
||||
}
|
||||
|
||||
const handleReset = () => {
|
||||
cancelCurrentQuery()
|
||||
stopCreateTaskPolling()
|
||||
formState.value = defaultChecksquareFormState()
|
||||
selectedLedgerNodes.value = []
|
||||
selectedIndicators.value = []
|
||||
defaultLedgerCheckedKeys.value = []
|
||||
defaultIndicatorCheckedKeys.value = []
|
||||
queryResult.value = null
|
||||
selectedItem.value = null
|
||||
activeCreateTask.value = null
|
||||
selectorResetKey.value += 1
|
||||
}
|
||||
|
||||
const runChecksquareHarmonicQuery = async (
|
||||
indicator: SteadyDataView.SteadyIndicatorNode,
|
||||
currentQuerySerial: number
|
||||
) => {
|
||||
const harmonicOrders = [...CHECKSQUARE_HARMONIC_ORDERS]
|
||||
let nextOrderIndex = 0
|
||||
const workers = Array.from({
|
||||
length: Math.min(CHECKSQUARE_HARMONIC_QUERY_CONCURRENCY, harmonicOrders.length)
|
||||
}).map(async () => {
|
||||
while (currentQuerySerial === querySerial) {
|
||||
const orderIndex = nextOrderIndex
|
||||
nextOrderIndex += 1
|
||||
if (orderIndex >= harmonicOrders.length) return
|
||||
const buildCreateTaskStatusQuery = (
|
||||
task: SteadyDataView.SteadyChecksquareTask | null
|
||||
): SteadyDataView.SteadyChecksquareTaskQueryParams => ({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
lineId: task?.lineId,
|
||||
timeStart: task?.timeStart,
|
||||
timeEnd: task?.timeEnd
|
||||
})
|
||||
|
||||
const harmonicOrder = harmonicOrders[orderIndex]
|
||||
const refreshCreateTaskStatus = async (taskId: string) => {
|
||||
if (createTaskPollingRunning) return
|
||||
|
||||
const payload = buildSteadyChecksquarePayload(lineIds.value[0], [indicator], formState.value, harmonicOrder)
|
||||
const response = await querySteadyChecksquare(payload)
|
||||
if (currentQuerySerial !== querySerial) return
|
||||
createTaskPollingRunning = true
|
||||
try {
|
||||
const taskResponse = await querySteadyChecksquareTasks(buildCreateTaskStatusQuery(activeCreateTask.value))
|
||||
const taskPage = unwrapData(taskResponse)
|
||||
const latestTask = taskPage.records?.find(task => task.taskId === taskId)
|
||||
|
||||
// 谐波 2-50 次请求耗时差异较大,单次返回后立即合并,避免等待全部次数完成才刷新表格。
|
||||
queryResult.value = mergeChecksquareIndicatorResult(queryResult.value, indicator, unwrapData(response))
|
||||
syncSelectedItemWithLatestResult()
|
||||
if (activeCreateTask.value && latestTask) {
|
||||
activeCreateTask.value = {
|
||||
...activeCreateTask.value,
|
||||
taskNo: latestTask.taskNo || activeCreateTask.value.taskNo,
|
||||
lineId: latestTask.lineId || activeCreateTask.value.lineId,
|
||||
lineName: latestTask.lineName || activeCreateTask.value.lineName,
|
||||
timeStart: latestTask.timeStart || activeCreateTask.value.timeStart,
|
||||
timeEnd: latestTask.timeEnd || activeCreateTask.value.timeEnd,
|
||||
intervalMinutes: latestTask.intervalMinutes ?? activeCreateTask.value.intervalMinutes,
|
||||
taskStatus: latestTask.taskStatus || activeCreateTask.value.taskStatus,
|
||||
itemCount: latestTask.itemCount ?? activeCreateTask.value.itemCount,
|
||||
abnormalItemCount: latestTask.abnormalItemCount ?? activeCreateTask.value.abnormalItemCount,
|
||||
minDataIntegrity: latestTask.minDataIntegrity ?? activeCreateTask.value.minDataIntegrity,
|
||||
createTime: latestTask.createTime || activeCreateTask.value.createTime
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await Promise.all(workers)
|
||||
if (isChecksquareTaskFinished(latestTask?.taskStatus || activeCreateTask.value?.taskStatus)) {
|
||||
stopCreateTaskPolling()
|
||||
taskTableRef.value?.refresh()
|
||||
return
|
||||
}
|
||||
|
||||
scheduleCreateTaskPolling(taskId)
|
||||
} finally {
|
||||
createTaskPollingRunning = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleQuery = async () => {
|
||||
const stopCreateTaskPolling = () => {
|
||||
if (createTaskPollingTimer !== null) window.clearTimeout(createTaskPollingTimer)
|
||||
|
||||
createTaskPollingTimer = null
|
||||
createTaskPollingRunning = false
|
||||
createTaskPollingCount = 0
|
||||
}
|
||||
|
||||
const scheduleCreateTaskPolling = (taskId: string) => {
|
||||
if (createTaskPollingTimer !== null) window.clearTimeout(createTaskPollingTimer)
|
||||
|
||||
createTaskPollingTimer = window.setTimeout(() => {
|
||||
createTaskPollingTimer = null
|
||||
createTaskPollingCount += 1
|
||||
void refreshCreateTaskStatus(taskId).catch(() => scheduleCreateTaskPolling(taskId))
|
||||
}, getCreateTaskPollingDelay())
|
||||
}
|
||||
|
||||
const startCreateTaskPolling = (taskId: string) => {
|
||||
stopCreateTaskPolling()
|
||||
|
||||
// 校验任务只需要监控执行状态,轮询任务列表行信息,避免反复拉取检测项明细。
|
||||
scheduleCreateTaskPolling(taskId)
|
||||
}
|
||||
|
||||
const normalizeCreateTask = (
|
||||
result: SteadyDataView.SteadyChecksquareTask
|
||||
): SteadyDataView.SteadyChecksquareTask | null => {
|
||||
const taskId = result.taskId || result.taskNo
|
||||
if (!taskId) return null
|
||||
|
||||
return {
|
||||
taskId,
|
||||
taskNo: result.taskNo,
|
||||
lineId: result.lineId,
|
||||
lineName: result.lineName,
|
||||
timeStart: result.timeStart,
|
||||
timeEnd: result.timeEnd,
|
||||
intervalMinutes: result.intervalMinutes,
|
||||
taskStatus: result.taskStatus,
|
||||
itemCount: result.itemCount,
|
||||
abnormalItemCount: result.abnormalItemCount,
|
||||
minDataIntegrity: result.minDataIntegrity,
|
||||
createTime: result.createTime
|
||||
}
|
||||
}
|
||||
|
||||
const handleCreateTask = async () => {
|
||||
const selectionError = validateChecksquareSelection({
|
||||
lineIds: lineIds.value,
|
||||
indicators: selectedIndicators.value,
|
||||
@@ -218,46 +328,120 @@ const handleQuery = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
const currentQuerySerial = ++querySerial
|
||||
const queryIndicators = [...selectedIndicators.value]
|
||||
activeCreateTask.value = null
|
||||
loading.query = true
|
||||
refreshPendingResult()
|
||||
selectedItem.value = null
|
||||
try {
|
||||
// /create 返回任务行信息,新增弹窗只监控任务状态,不拉取检测项详情。
|
||||
const response = await createSteadyChecksquareTask(
|
||||
buildSteadyChecksquareCreatePayload(lineIds.value, selectedIndicators.value, formState.value)
|
||||
)
|
||||
const result = unwrapData(response)
|
||||
const createdTask = normalizeCreateTask(result)
|
||||
activeCreateTask.value = createdTask
|
||||
if (createdTask?.taskId && !isChecksquareTaskFinished(createdTask.taskStatus)) {
|
||||
startCreateTaskPolling(createdTask.taskId)
|
||||
}
|
||||
ElMessage.success('校验任务已获取')
|
||||
taskTableRef.value?.refresh()
|
||||
} finally {
|
||||
loading.query = false
|
||||
}
|
||||
}
|
||||
|
||||
const refreshTaskDetail = async () => {
|
||||
if (!selectedTask.value?.taskId) return
|
||||
|
||||
loading.detail = true
|
||||
try {
|
||||
const response = await getSteadyChecksquareDetail(selectedTask.value.taskId)
|
||||
taskDetail.value = unwrapData(response)
|
||||
} finally {
|
||||
loading.detail = false
|
||||
}
|
||||
}
|
||||
|
||||
const openTaskDetail = async (row: SteadyDataView.SteadyChecksquareTask) => {
|
||||
selectedTask.value = row
|
||||
taskDetail.value = null
|
||||
detailDialogVisible.value = true
|
||||
await refreshTaskDetail()
|
||||
}
|
||||
|
||||
const handleDeleteTask = async (row: SteadyDataView.SteadyChecksquareTask) => {
|
||||
if (!row.taskId) return
|
||||
|
||||
try {
|
||||
// 按指标串行校验,保证结果列表能随单个指标完成逐步回填。
|
||||
for (const indicator of queryIndicators) {
|
||||
if (currentQuerySerial !== querySerial) return
|
||||
|
||||
if (isChecksquareHarmonicIndicator(indicator)) {
|
||||
await runChecksquareHarmonicQuery(indicator, currentQuerySerial)
|
||||
continue
|
||||
}
|
||||
|
||||
const payload = buildSteadyChecksquarePayload(lineIds.value[0], [indicator], formState.value)
|
||||
const response = await querySteadyChecksquare(payload)
|
||||
if (currentQuerySerial !== querySerial) return
|
||||
|
||||
queryResult.value = mergeChecksquareIndicatorResult(queryResult.value, indicator, unwrapData(response))
|
||||
syncSelectedItemWithLatestResult()
|
||||
}
|
||||
} finally {
|
||||
if (currentQuerySerial === querySerial) {
|
||||
loading.query = false
|
||||
}
|
||||
await ElMessageBox.confirm('确认删除该校验任务吗?删除后历史列表将不再显示该任务。', '删除确认', {
|
||||
confirmButtonText: '删除',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
// 删除接口按任务 ID 数组批量处理,行操作只传当前任务 ID。
|
||||
await deleteSteadyChecksquareTasks([row.taskId])
|
||||
ElMessage.success('删除校验任务成功')
|
||||
taskTableRef.value?.refresh()
|
||||
}
|
||||
|
||||
const handleRestartTask = async (row: SteadyDataView.SteadyChecksquareTask) => {
|
||||
if (!row.taskId) return
|
||||
|
||||
try {
|
||||
await ElMessageBox.confirm('确认重启该失败的校验任务吗?重启后会清理旧结果并重新执行。', '重启确认', {
|
||||
confirmButtonText: '重启',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
// 重启接口仅支持失败任务,成功后复用原任务 ID 并刷新列表展示最新运行状态。
|
||||
await restartSteadyChecksquareTask(row.taskId)
|
||||
ElMessage.success('校验任务已重启')
|
||||
taskTableRef.value?.refresh()
|
||||
}
|
||||
|
||||
const openItemDetail = (item: SteadyDataView.SteadyChecksquareItem) => {
|
||||
selectedItem.value = item
|
||||
itemDetailDialogVisible.value = true
|
||||
}
|
||||
|
||||
const openMeasurementPointDialog = (row: SteadyDataView.SteadyChecksquareTask) => {
|
||||
measurementPointData.value = resolveChecksquareMeasurementPointDetail(ledgerTree.value, row)
|
||||
measurementPointDialogVisible.value = true
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadLedgerTree()
|
||||
loadIndicatorTree()
|
||||
})
|
||||
|
||||
watch(createDialogVisible, visible => {
|
||||
if (!visible) stopCreateTaskPolling()
|
||||
})
|
||||
|
||||
onBeforeUnmount(stopCreateTaskPolling)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.checksquare-page {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.checksquare-create-dialog {
|
||||
display: block;
|
||||
height: 560px;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.checksquare-detail-dialog {
|
||||
height: 560px;
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
|
||||
export interface ChecksquareMeasurementPointDetail {
|
||||
engineeringName?: string
|
||||
projectName?: string
|
||||
equipmentName?: string
|
||||
networkParam?: string
|
||||
lineName?: string
|
||||
}
|
||||
|
||||
const resolveText = (data: Record<string, unknown>, ...keys: string[]) => {
|
||||
for (const key of keys) {
|
||||
const value = data[key]
|
||||
if (value === null || value === undefined) continue
|
||||
|
||||
const text = String(value).trim()
|
||||
if (text) return text
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
const collectLedgerPath = (
|
||||
nodes: SteadyDataView.SteadyLedgerNode[],
|
||||
lineId: string,
|
||||
parents: SteadyDataView.SteadyLedgerNode[] = []
|
||||
): SteadyDataView.SteadyLedgerNode[] => {
|
||||
for (const node of nodes) {
|
||||
const nextPath = [...parents, node]
|
||||
|
||||
if (node.id === lineId) {
|
||||
return nextPath
|
||||
}
|
||||
|
||||
if (node.children?.length) {
|
||||
const matchedPath = collectLedgerPath(node.children, lineId, nextPath)
|
||||
if (matchedPath.length) return matchedPath
|
||||
}
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
export const resolveChecksquareMeasurementPointDetail = (
|
||||
ledgerTree: SteadyDataView.SteadyLedgerNode[],
|
||||
row: Pick<SteadyDataView.SteadyChecksquareTask, 'lineId' | 'lineName'>
|
||||
): ChecksquareMeasurementPointDetail => {
|
||||
const lineId = row.lineId || ''
|
||||
const ledgerPath = lineId ? collectLedgerPath(ledgerTree, lineId) : []
|
||||
const engineeringNode = ledgerPath.find(item => item.level === 0)
|
||||
const projectNode = ledgerPath.find(item => item.level === 1)
|
||||
const equipmentNode = ledgerPath.find(item => item.level === 2)
|
||||
const lineNode = ledgerPath.find(item => item.level === 3)
|
||||
const rawEquipmentNode = (equipmentNode || {}) as SteadyDataView.SteadyLedgerNode & Record<string, unknown>
|
||||
const rawLineNode = (lineNode || {}) as SteadyDataView.SteadyLedgerNode & Record<string, unknown>
|
||||
|
||||
// 数据校验任务只返回监测点 ID/名称,弹窗所需层级信息从已加载的台账树回溯补齐。
|
||||
return {
|
||||
engineeringName: engineeringNode?.name,
|
||||
projectName: projectNode?.name,
|
||||
equipmentName: equipmentNode?.name,
|
||||
networkParam: resolveText(rawEquipmentNode, 'mac', 'ndid', 'unnid') || resolveText(rawLineNode, 'mac', 'ndid', 'unnid'),
|
||||
lineName: lineNode?.name || row.lineName || row.lineId
|
||||
}
|
||||
}
|
||||
@@ -29,24 +29,28 @@ export const collectChecksquareIndicatorCodes = (indicators: SteadyDataView.Stea
|
||||
return Array.from(new Set(indicators.map(item => item.indicatorCode).filter(Boolean))) as string[]
|
||||
}
|
||||
|
||||
export const buildSteadyChecksquarePayload = (
|
||||
lineId: string,
|
||||
export const calculateChecksquareExpectedItemCount = (params: {
|
||||
lineCount: number
|
||||
selectedIndicatorCount: number
|
||||
totalIndicatorCount: number
|
||||
}) => {
|
||||
const { lineCount, selectedIndicatorCount, totalIndicatorCount } = params
|
||||
const indicatorCount = selectedIndicatorCount > 0 ? selectedIndicatorCount : totalIndicatorCount
|
||||
|
||||
return lineCount * indicatorCount
|
||||
}
|
||||
|
||||
export const buildSteadyChecksquareCreatePayload = (
|
||||
lineIds: string[],
|
||||
indicators: SteadyDataView.SteadyIndicatorNode[],
|
||||
formState: ChecksquareFormState,
|
||||
harmonicOrder?: number
|
||||
): SteadyDataView.SteadyChecksquareQueryParams => {
|
||||
const payload: SteadyDataView.SteadyChecksquareQueryParams = {
|
||||
lineId,
|
||||
formState: ChecksquareFormState
|
||||
): SteadyDataView.SteadyChecksquareCreateParams => {
|
||||
return {
|
||||
lineIds,
|
||||
indicatorCodes: collectChecksquareIndicatorCodes(indicators),
|
||||
timeStart: (formState.timeRange[0] || '').replace(/\.[^.]+$/, ''),
|
||||
timeEnd: (formState.timeRange[1] || '').replace(/\.[^.]+$/, '')
|
||||
}
|
||||
|
||||
if (harmonicOrder) {
|
||||
payload.harmonicOrders = [harmonicOrder]
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
export const validateChecksquareSelection = (params: {
|
||||
@@ -54,11 +58,9 @@ export const validateChecksquareSelection = (params: {
|
||||
indicators: SteadyDataView.SteadyIndicatorNode[]
|
||||
timeRange: string[]
|
||||
}) => {
|
||||
const { lineIds, indicators, timeRange } = params
|
||||
const { lineIds, timeRange } = params
|
||||
|
||||
if (!lineIds.length) return '请选择监测点'
|
||||
if (lineIds.length > 1) return '数据校验一次只能选择一个监测点'
|
||||
if (!indicators.length) return '请选择指标'
|
||||
if (!timeRange[0]) return '请选择开始时间'
|
||||
if (!timeRange[1]) return '请选择结束时间'
|
||||
if (Date.parse(timeRange[0].replace(' ', 'T')) > Date.parse(timeRange[1].replace(' ', 'T'))) {
|
||||
|
||||
@@ -24,11 +24,13 @@ export const formatBooleanText = (value?: boolean | null) => {
|
||||
return value ? '是' : '否'
|
||||
}
|
||||
|
||||
export const formatMissingRate = (value?: number | null, text?: string | null) => {
|
||||
export const formatDataIntegrity = (value?: number | null, text?: string | null) => {
|
||||
if (text) return text
|
||||
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '-'
|
||||
const integrityValue = value === null || value === undefined || !Number.isFinite(Number(value)) ? null : Number(value)
|
||||
|
||||
return `${(Number(value) * 100).toFixed(2)}%`
|
||||
if (integrityValue === null) return '-'
|
||||
|
||||
return `${(integrityValue * 100).toFixed(2)}%`
|
||||
}
|
||||
|
||||
export const findStatSummary = (
|
||||
@@ -45,7 +47,7 @@ export const formatStatMissingRate = (
|
||||
const summary = findStatSummary(item, statType)
|
||||
if (!summary || summary.supported === false) return '-'
|
||||
|
||||
return formatMissingRate(summary.missingRate, summary.missingRateText)
|
||||
return formatDataIntegrity(summary.dataIntegrity, summary.dataIntegrityText)
|
||||
}
|
||||
|
||||
export const resolveChecksquareRowName = (item: SteadyDataView.SteadyChecksquareItem) => {
|
||||
@@ -81,7 +83,13 @@ export const collectMissingSegments = (item: SteadyDataView.SteadyChecksquareIte
|
||||
}
|
||||
|
||||
export const hasChecksquareDetail = (item: SteadyDataView.SteadyChecksquareItem) => {
|
||||
return (item.statDetails || []).some(detail => (detail.segments || []).length)
|
||||
return (
|
||||
Boolean(item.itemId) ||
|
||||
Boolean(item.abnormalPointCount) ||
|
||||
Boolean(item.harmonicParityAbnormalPointCount) ||
|
||||
Boolean(item.missingPointCount) ||
|
||||
(item.statDetails || []).some(detail => (detail.segments || []).length)
|
||||
)
|
||||
}
|
||||
|
||||
const hasChecksquareHarmonicOrderRange = (indicator: SteadyDataView.SteadyIndicatorNode) => {
|
||||
@@ -203,10 +211,6 @@ const summarizeStatType = (
|
||||
const expectedPointCount = supportedSummaries.reduce((total, summary) => total + (summary.expectedPointCount || 0), 0)
|
||||
const actualPointCount = supportedSummaries.reduce((total, summary) => total + (summary.actualPointCount || 0), 0)
|
||||
const missingPointCount = supportedSummaries.reduce((total, summary) => total + (summary.missingPointCount || 0), 0)
|
||||
const maxContinuousMissingMinutes = Math.max(
|
||||
0,
|
||||
...supportedSummaries.map(summary => summary.maxContinuousMissingMinutes || 0)
|
||||
)
|
||||
|
||||
return {
|
||||
statType,
|
||||
@@ -215,8 +219,8 @@ const summarizeStatType = (
|
||||
expectedPointCount,
|
||||
actualPointCount,
|
||||
missingPointCount,
|
||||
missingRate: expectedPointCount ? missingPointCount / expectedPointCount : null,
|
||||
maxContinuousMissingMinutes
|
||||
dataIntegrity: expectedPointCount ? actualPointCount / expectedPointCount : null,
|
||||
dataIntegrityText: expectedPointCount ? undefined : '-'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +242,6 @@ export const buildHarmonicParentSummary = (
|
||||
const expectedPointCount = sumNumber(children, item => item.expectedPointCount)
|
||||
const actualPointCount = sumNumber(children, item => item.actualPointCount)
|
||||
const missingPointCount = sumNumber(children, item => item.missingPointCount)
|
||||
const maxContinuousMissingMinutes = Math.max(0, ...children.map(item => item.maxContinuousMissingMinutes || 0))
|
||||
const statSummaries = CHECKSQUARE_STAT_TYPES.map(statType => summarizeStatType(children, statType))
|
||||
|
||||
return {
|
||||
@@ -247,9 +250,8 @@ export const buildHarmonicParentSummary = (
|
||||
expectedPointCount,
|
||||
actualPointCount,
|
||||
missingPointCount,
|
||||
missingRate: expectedPointCount ? missingPointCount / expectedPointCount : null,
|
||||
missingRateText: expectedPointCount ? undefined : '-',
|
||||
maxContinuousMissingMinutes,
|
||||
dataIntegrity: expectedPointCount ? actualPointCount / expectedPointCount : null,
|
||||
dataIntegrityText: expectedPointCount ? undefined : '-',
|
||||
statSummaries,
|
||||
statDetails: [],
|
||||
children
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { SteadyDataView } from '@/api/steady/steadyDataView/interface'
|
||||
|
||||
export interface ChecksquareTaskSearchParams extends SteadyDataView.SteadyChecksquareTaskQueryParams {
|
||||
taskTimeRange?: string[]
|
||||
}
|
||||
|
||||
export const buildChecksquareTaskQueryParams = (
|
||||
params: ChecksquareTaskSearchParams
|
||||
): SteadyDataView.SteadyChecksquareTaskQueryParams => {
|
||||
const { taskTimeRange, ...rest } = params
|
||||
const queryParams: SteadyDataView.SteadyChecksquareTaskQueryParams = { ...rest }
|
||||
|
||||
if (taskTimeRange?.[0]) queryParams.timeStart = taskTimeRange[0]
|
||||
if (taskTimeRange?.[1]) queryParams.timeEnd = taskTimeRange[1]
|
||||
|
||||
return queryParams
|
||||
}
|
||||
|
||||
export const formatChecksquareTaskStatus = (status?: string) => {
|
||||
if (!status) return '--'
|
||||
if (status === 'SUCCESS') return '成功'
|
||||
if (status === 'FAIL') return '失败'
|
||||
if (status === 'RUNNING') return '执行中'
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
export const resolveChecksquareTaskStatusType = (status?: string) => {
|
||||
if (status === 'SUCCESS') return 'success'
|
||||
if (status === 'FAIL') return 'danger'
|
||||
if (status === 'RUNNING') return 'warning'
|
||||
|
||||
return 'info'
|
||||
}
|
||||
|
||||
export const formatChecksquareIntegrity = (value?: number | null) => {
|
||||
const integrityValue = value === null || value === undefined || !Number.isFinite(Number(value)) ? null : Number(value)
|
||||
|
||||
if (integrityValue === null) return '--'
|
||||
|
||||
return `${(integrityValue * 100).toFixed(2)}%`
|
||||
}
|
||||
|
||||
export const resolveChecksquareText = (value: unknown) => {
|
||||
if (value === null || value === undefined || value === '') return '--'
|
||||
|
||||
return String(value)
|
||||
}
|
||||
@@ -123,7 +123,7 @@ const handleKeywordChange = (value: string) => {
|
||||
}
|
||||
|
||||
const handleCheck = () => {
|
||||
emit('change', (treeRef.value?.getCheckedNodes(false, false) || []) as SteadyDataView.SteadyLedgerNode[])
|
||||
emit('change', (treeRef.value?.getCheckedNodes(true, false) || []) as SteadyDataView.SteadyLedgerNode[])
|
||||
}
|
||||
|
||||
const applyDefaultCheckedKeys = async () => {
|
||||
|
||||
@@ -12,8 +12,8 @@ const selectionRulesSource = fs.readFileSync(path.join(currentDir, '..', 'utils'
|
||||
|
||||
const expectations = [
|
||||
[
|
||||
'ledger tree excludes half-checked parents when collecting checked nodes',
|
||||
/getCheckedNodes\(\s*false\s*,\s*false\s*\)/,
|
||||
'ledger tree emits leaf monitor points when collecting checked nodes',
|
||||
/getCheckedNodes\(\s*true\s*,\s*false\s*\)/,
|
||||
read('SteadyLedgerTree.vue')
|
||||
],
|
||||
[
|
||||
|
||||
@@ -123,7 +123,7 @@ const handleKeywordChange = (value: string) => {
|
||||
}
|
||||
|
||||
const handleCheck = () => {
|
||||
emit('change', (treeRef.value?.getCheckedNodes(false, false) || []) as SteadyTrend.SteadyLedgerNode[])
|
||||
emit('change', (treeRef.value?.getCheckedNodes(true, false) || []) as SteadyTrend.SteadyLedgerNode[])
|
||||
}
|
||||
|
||||
const applyDefaultCheckedKeys = async () => {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user