Compare commits

..

45 Commits

Author SHA1 Message Date
yangsy
db831e82ff docs: 更新 README.md 2026-02-02 15:04:46 +08:00
yangsy
6bf205f461 fix: 关闭调试模式时遗漏了重置 useLocalDB 状态 2026-01-30 14:48:54 +08:00
yangsy
cf3d19d89d refactor: 录像诊断导出面板统一使用批量接口 2026-01-30 14:14:53 +08:00
yangsy
b020226538 refactor: 用 useQuery 重构录像诊断卡片 2026-01-29 13:42:41 +08:00
yangsy
b79b1df57e fix: 修复服务状态和推流统计卡片的渲染条件 2026-01-29 13:41:01 +08:00
yangsy
9b21beed0f fix: 下游设备配置添加权限校验 2026-01-28 15:57:23 +08:00
yangsy
aa4684273b feat: 添加批量导出录像诊断并优化导出体验 2026-01-28 14:31:37 +08:00
yangsy
36e839142a fix: 简化设备树选中状态与路由同步的逻辑,修复选中的设备类型被异常还原的问题 2026-01-27 11:05:25 +08:00
yangsy
03006a8f06 fix: 完善设备卡片标签页切换逻辑 2026-01-26 14:05:16 +08:00
yangsy
0af52c62ce feat: 添加权限查询和管理机制
- 新增权限管理页面
- 改进轮询链,引入权限查询
- 支持订阅权限变更或轮询权限检测变更
- 应用权限到页面和组件
2026-01-26 10:54:24 +08:00
yangsy
82789c78a9 feat: 车站卡片布局列数自适应 2026-01-21 15:23:08 +08:00
yangsy
6771abec31 refactor: 移除polling-store,重构setting-store 2026-01-20 11:22:24 +08:00
yangsy
b7b6b216fb feat: 设备告警记录页面添加告警恢复状态和确认状态筛选 2026-01-16 14:36:46 +08:00
yangsy
97f05f21ae refactor: 调整API数据结构目录 2026-01-15 14:57:33 +08:00
yangsy
c4963b5b70 refactor: 优化查询链的耗时和错误日志输出 2026-01-15 14:42:38 +08:00
yangsy
86775a6eb2 feat: 优化车站状态页面的操作栏交互逻辑 2026-01-15 14:42:38 +08:00
yangsy
db3a6ddca5 refactor: 简化录像诊断卡片逻辑 2026-01-15 14:42:38 +08:00
yangsy
b59b34e68b refactor: 抽离未读告警状态,不再持久化 2026-01-15 14:42:37 +08:00
yangsy
de35075be8 refactor: 整理页面的目录结构 2026-01-15 13:41:07 +08:00
yangsy
045f7a9a81 fix: 修复设备硬件占用率卡片中showCard计算属性未获取原始值的问题 2026-01-13 13:51:25 +08:00
yangsy
bd6ad9b932 style: 更新图标库为 lucide 2026-01-13 13:36:28 +08:00
yangsy
b392328f37 fix: 修复数据表格标题错误 2026-01-08 15:59:29 +08:00
yangsy
c3692de19e fix: 修复当API接口定义中没有响应数据时会意外抛出空数据异常的问题 2026-01-08 15:55:28 +08:00
yangsy
c273ae21d9 fix: 未登录时启用离线开发模式后添加默认用户信息 2026-01-08 15:55:09 +08:00
yangsy
653981c0e7 fix: 修正告警页路由路径错误 2026-01-05 14:56:59 +08:00
yangsy
263dd5edfc refactor: 将请求封装重构为函数模式 2026-01-05 14:56:53 +08:00
yangsy
fd70f63fc9 fix: 修复请求实例选择逻辑错误 2026-01-05 14:56:47 +08:00
yangsy
8566b06429 feat: 上级调用日志添加更多数据
- 新增日志类型、用户所属类别、被调用设备名称列
- 优化在线站点选择逻辑
2026-01-04 15:31:31 +08:00
yangsy
a00c736f33 docs: 为NdmCallLog结构添加字段注释 2026-01-04 15:31:30 +08:00
yangsy
85a6b73473 fix: 将表单中的"操作类型"标签改为"日志类型" 2026-01-04 15:31:30 +08:00
yangsy
64c501f94c feat: 移除操作参数和操作结果列 2026-01-04 15:31:30 +08:00
yangsy
c81847ea0f docs: 为NdmVimpLog结构添加字段注释 2026-01-04 15:31:30 +08:00
yangsy
080759c544 fix: 修复操作类型列渲染错误的问题 2026-01-04 15:17:48 +08:00
yangsy
670054ca01 feat: 新增流媒体推流统计卡片 2026-01-04 11:27:46 +08:00
yangsy
80e879e61f refactor: 优化服务状态卡片的渲染条件 2026-01-04 11:18:33 +08:00
yangsy
c259eabc22 fix: 添加防止设备自关联的校验 2026-01-04 10:30:30 +08:00
yangsy
286449b831 feat: 添加告警画面截图相关设置
- 配置告警画面截图保留天数
- 是否自动获取告警画面截图
2025-12-31 10:50:25 +08:00
yangsy
e112b01a21 feat: 告警忽略管理页面 2025-12-30 10:57:43 +08:00
yangsy
054b2bcdac feat: 添加告警忽略管理页面和路由配置 2025-12-30 10:45:48 +08:00
yangsy
1f23588649 refactor: 调整路由结构,使告警板块支持子路由 2025-12-30 10:45:40 +08:00
yangsy
02e29eb4f3 feat: 支持查看摄像机告警画面截图 2025-12-30 10:43:05 +08:00
yangsy
118cc8be0b refactor: 明确所有 stationCode 参数的类型 2025-12-29 14:03:13 +08:00
yangsy
5170105ab8 refactor: 明确所有 stationCode 参数的类型 2025-12-29 14:03:07 +08:00
yangsy
420637352d feat: 查询页面卸载时取消未完成的请求 2025-12-28 14:34:42 +08:00
yangsy
abdbef2d05 fix: 修复跳转设备时未检查deviceId存在性的问题 2025-12-28 13:24:58 +08:00
126 changed files with 727116 additions and 989 deletions

2
.env
View File

@@ -19,7 +19,7 @@ VITE_LAMP_PASSWORD = fjoc(1KHP(Ls&Bje)C
VITE_LAMP_AUTHORIZATION = Y3VlZGVzX2FkbWluOmN1ZWRlc19hZG1pbl9zZWNyZXQ= VITE_LAMP_AUTHORIZATION = Y3VlZGVzX2FkbWluOmN1ZWRlc19hZG1pbl9zZWNyZXQ=
# 当需要重置localStorage时, 修改此变量 # 当需要重置localStorage时, 修改此变量
VITE_STORAGE_VERSION = 3 VITE_STORAGE_VERSION = 5
# 调试码 # 调试码
VITE_DEBUG_CODE = ndm_debug VITE_DEBUG_CODE = ndm_debug

141
README.md
View File

@@ -40,18 +40,145 @@ pnpm build
在执行 `pnpm build` 之前,你可以在 `package.json` 中修改 `version` 字段,将其设置为你期望的版本号,构建完成后,项目的根目录中除了 `dist` 目录外,还会生成三个压缩包,文件名的格式统一为 `ndm-web-platform_v<version>_<datetime>`,文件格式则分别为 `zip``tar``tar.gz` 在执行 `pnpm build` 之前,你可以在 `package.json` 中修改 `version` 字段,将其设置为你期望的版本号,构建完成后,项目的根目录中除了 `dist` 目录外,还会生成三个压缩包,文件名的格式统一为 `ndm-web-platform_v<version>_<datetime>`,文件格式则分别为 `zip``tar``tar.gz`
## 业务结构
所有业务相关的页面都在 `src/pages` 目录下,路由配置在 `src/router/index.ts` 文件,除登录页之外,其余页面都作为 `src/layouts/app-layout.vue` 的子路由。
```bash
src/
router/
index.ts # 路由配置文件
layouts/
app-layout.vue # 布局
pages/
login/
login-page.vue # 登录页面
station/
station-page.vue # 车站状态页面(首页)
device/
device-page.vue # 设备诊断页面
alarm/
alarm-ignore-page.vue # 告警忽略管理页面
alarm-log-page.vue # 设备告警记录页面
log/
call-log-page.vue # 上级调用日志页面
vimp-log-page.vue # 视频平台日志页面
permission/
permission-page.vue # 权限管理页面
error/
not-found-page.vue # 404 页面
```
## 数据轮询
由于后端服务的架构限制,需要前端向所有车站服务依次发送请求来获取数据,需要获取的数据包含车站状态、设备数据以及告警数据,因此需要设计一套数据轮询方案,定期从所有车站服务获取数据。
在项目中,`src/composables/query/` 目录下是所有数据轮询相关的代码,其中与业务相关的代码主要包括:
- `use-line-stations-query.ts`: 查询所有车站
- `use-line-devices-query.ts`: 查询所有设备
- `use-line-alarms-query.ts`: 查询所有告警
- `use-user-permission-query.ts`: 查询用户权限
在描述整个数据轮询流程之前,我们要明确项目中必须存在的几个关键概念:
- 车站相关车站query + 车站store
- 设备相关设备query + 设备store
- 告警相关告警query + 告警store
- 权限相关权限query + 权限store
整个数据轮询流程采用“单点驱动 + 变更监听 + 级联触发”的模式,如下图所示。
![数据轮询流程](./docs/assets/query-chain.png)
1. 轮询入口车站query
- 触发条件以120秒的周期自动轮询车站列表
- 数据流向车站store
2. 核心调度权限query
- 触发条件车站query执行后触发
- 数据流向权限store并计算当前用户在各车站的权限
- 数据监听监听车站和权限变化触发设备query和告警query
3. 设备query & 告警query
- 触发条件被动触发由权限query主动调用
- 数据流向设备store & 告警store
## 调试模式 ## 调试模式
调试模式中,用户可以查看设备的原始诊断数据,也可以对轮询器进行控制,或者启用离线开发模式,系统不会自动调用一些主动触发的请求 设置面板中有一系列与调试模式有关的设置项,主要用于开发和故障排查
### 开启调试模 ### 开启
在非登录页的任意页面中,使用键盘组合键 `Ctrl+Alt+D`,系统会弹出一个输入框,输入环境变量 `.env` 中的 `VITE_DEBUG_CODE` 对应的值即可开启调试模式,如需关闭调试模式,再次使用上述组合键并点击 `确认` 按钮即可。 调试模式默认隐藏,通过以下方式开启:
注意调试模式与其内部的功能之间没有联动关系,例如在开启调试模式后可以关闭轮询或者启用离线开发模式,但是在关闭调试模式后,轮询不会重新被开启,离线开发模式也不会被关闭,因此在关闭离线开发模式前,请务必确保系统处于正确的运行状态下。 1. 使用快捷键 `Ctrl + Alt + D` 唤起验证弹窗
2. 输入授权码进行验证(授权码对应环境变量 `.env` 中的 `VITE_DEBUG_CODE`
3. 验证通过后,在“系统设置”面板中会出现 **调试** 分组
### 关于离线开发模式 ### 设置项说明
由于离线开发模式涉及到登录操作,因此项目中将离线开发模式暴露到了全局变量 `window.$offlineDev` 中,允许在登录页中直接开启离线开发模式。 #### 数据设置
如果你第一次启动这个项目,系统在正常情况下会先跳转至登录页,此时如果希望开启离线模式,可以直接打开浏览器的开发者工具,在控制台输入 `window.$offlineDev.value = true` 即可,系统会直接跳转到首页。 - **显示设备原始数据**
- 控制是否在设备详情页显示“原始数据”标签页
- 开启后可查看设备接口返回的原始 JSON 数据,便于排查字段缺失或格式错误
#### 网络设置
- **轮询车站**
- 控制是否定时拉取车站状态,进而触发权限、设备及告警数据的更新
- 关闭后将暂停所有业务数据的自动轮询机制
- **主动请求**
- 控制组件挂载时是否自动发起数据请求
- 涵盖设备在线状态检测、用户登录验证等逻辑,关闭后组件在初始化时将不再自动拉取数据
- **订阅消息**
- 控制是否通过 WebSocket (STOMP) 接收实时告警或状态推送
- 关闭后将不再处理后端推送的实时消息
- **模拟用户**
- 开启后使用内置的超管用户绕过登录
- 开启时会自动进入调试模式,便于开发环境快速测试
#### 数据库设置
- **直接操作本地数据库**
- 控制某些业务逻辑(如交换机端口、安防箱回路)是否直接读写本地 IndexedDB
- 用于在无后端环境或特定测试场景下验证本地数据逻辑
## 离线开发
项目支持在无后端服务的情况下正常启动,具体操作取决于你的本地环境是否已有历史数据。
### 场景一:已有本地缓存
如果你的浏览器曾接入过现场环境IndexedDB 中已保存了车站、设备等数据,只需在设置中关闭网络请求即可进入离线模式:
1. 开启调试模式(`Ctrl + Alt + D`)。
2. 在“网络设置”中,关闭 **轮询车站**、**主动请求** 和 **订阅消息**
3. 此时平台将停止向后端发起请求,直接展示本地缓存的历史数据。
### 场景二:全新环境启动(新人推荐)
如果你是首次拉取项目且无法连接后端,需要按以下步骤操作:
1. **模拟登录**
在登录页按 `F12` 打开控制台,输入以下命令强制进入平台:
```javascript
window.$mockUser.value = true;
```
执行后平台将自动完成以下操作:
- 注入测试 Token 和管理员身份信息
- 关闭所有网络请求(轮询、主动请求、消息订阅)
- 开启调试模式
- 自动跳转至平台首页
2. **导入模拟数据**
进入平台后,页面默认为空。需导入预设数据以填充内容:
- 打开“系统设置”(已自动开启调试模式)。
- 在 **调试** -> **数据库设置** 中,勾选 **直接操作本地数据库**。
- 点击该选项下方的 **导入数据** 按钮。
- 依次导入项目根目录 `docs/data/` 下的三个文件:
- `ndm-station-store.json`(车站数据)
- `ndm-device-store.json`(设备数据)
- `ndm-alarm-store.json`(告警数据)
> **注意**:每次导入一个文件后,平台会自动刷新页面以应用数据。请等待刷新完成后,重新打开设置面板导入下一个文件。

BIN
docs/assets/query-chain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

527708
docs/data/ndm-alarm-store.json Normal file

File diff suppressed because it is too large Load Diff

195971
docs/data/ndm-device-store.json Normal file

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,203 @@
{
"stations": [
{
"code": "1075",
"name": "吴中路控制中心",
"online": true,
"ip": "10.18.128.10",
"occ": true
},
{
"code": "1001",
"name": "虹桥火车站",
"online": true,
"ip": "10.18.129.10"
},
{
"code": "1002",
"name": "虹桥2号航站楼",
"online": true,
"ip": "10.18.131.10"
},
{
"code": "1003",
"name": "虹桥一号航站楼",
"online": true,
"ip": "10.18.133.10"
},
{
"code": "1004",
"name": "上海动物园",
"online": true,
"ip": "10.18.135.10"
},
{
"code": "1005",
"name": "龙溪路",
"online": true,
"ip": "10.18.137.10"
},
{
"code": "1006",
"name": "水城路",
"online": true,
"ip": "10.18.139.10"
},
{
"code": "1007",
"name": "伊犁路",
"online": true,
"ip": "10.18.141.10"
},
{
"code": "1008",
"name": "宋园路",
"online": true,
"ip": "10.18.143.10"
},
{
"code": "1009",
"name": "虹桥路",
"online": true,
"ip": "10.18.145.10"
},
{
"code": "1010",
"name": "交通大学",
"online": true,
"ip": "10.18.147.10"
},
{
"code": "1011",
"name": "图书馆",
"online": true,
"ip": "10.18.149.10"
},
{
"code": "1012",
"name": "陕西南路",
"online": true,
"ip": "10.18.151.10"
},
{
"code": "1013",
"name": "新天地",
"online": true,
"ip": "10.18.153.10"
},
{
"code": "1014",
"name": "老西门",
"online": true,
"ip": "10.18.155.10"
},
{
"code": "1015",
"name": "豫园",
"online": true,
"ip": "10.18.157.10"
},
{
"code": "1016",
"name": "南京东路",
"online": true,
"ip": "10.18.159.10"
},
{
"code": "1017",
"name": "天潼路",
"online": true,
"ip": "10.18.161.10"
},
{
"code": "1018",
"name": "四川北路",
"online": true,
"ip": "10.18.163.10"
},
{
"code": "1019",
"name": "海伦路",
"online": true,
"ip": "10.18.165.10"
},
{
"code": "1020",
"name": "邮电新村",
"online": true,
"ip": "10.18.167.10"
},
{
"code": "1021",
"name": "四平路",
"online": true,
"ip": "10.18.169.10"
},
{
"code": "1022",
"name": "同济大学",
"online": true,
"ip": "10.18.171.10"
},
{
"code": "1023",
"name": "国权路",
"online": true,
"ip": "10.18.173.10"
},
{
"code": "1024",
"name": "五角场",
"online": true,
"ip": "10.18.175.10"
},
{
"code": "1025",
"name": "江湾体育场",
"online": true,
"ip": "10.18.177.10"
},
{
"code": "1026",
"name": "三门路",
"online": true,
"ip": "10.18.179.10"
},
{
"code": "1027",
"name": "殷高东路",
"online": true,
"ip": "10.18.181.10"
},
{
"code": "1028",
"name": "新江湾城",
"online": true,
"ip": "10.18.183.10"
},
{
"code": "1029",
"name": "航中路",
"online": true,
"ip": "10.18.185.10"
},
{
"code": "1030",
"name": "紫藤路",
"online": true,
"ip": "10.18.187.10"
},
{
"code": "1031",
"name": "龙柏新村",
"online": true,
"ip": "10.18.189.10"
},
{
"code": "1032",
"name": "吴中路基地",
"online": true,
"ip": "10.18.244.10"
}
]
}

View File

@@ -28,6 +28,7 @@
"echarts": "^6.0.0", "echarts": "^6.0.0",
"es-toolkit": "^1.41.0", "es-toolkit": "^1.41.0",
"localforage": "^1.10.0", "localforage": "^1.10.0",
"lucide-vue-next": "^0.562.0",
"naive-ui": "^2.43.1", "naive-ui": "^2.43.1",
"pinia": "^3.0.4", "pinia": "^3.0.4",
"pinia-plugin-persistedstate": "^4.7.1", "pinia-plugin-persistedstate": "^4.7.1",
@@ -40,8 +41,6 @@
"@tsconfig/node22": "^22.0.2", "@tsconfig/node22": "^22.0.2",
"@types/crypto-js": "^4.2.2", "@types/crypto-js": "^4.2.2",
"@types/node": "^22.18.11", "@types/node": "^22.18.11",
"@vicons/antd": "^0.13.0",
"@vicons/ionicons5": "^0.13.0",
"@vitejs/plugin-vue": "^6.0.1", "@vitejs/plugin-vue": "^6.0.1",
"@vitejs/plugin-vue-jsx": "^5.1.1", "@vitejs/plugin-vue-jsx": "^5.1.1",
"@vue/eslint-config-prettier": "^10.2.0", "@vue/eslint-config-prettier": "^10.2.0",
@@ -58,5 +57,5 @@
"vite-plugin-vue-devtools": "^8.0.3", "vite-plugin-vue-devtools": "^8.0.3",
"vue-tsc": "^3.1.3" "vue-tsc": "^3.1.3"
}, },
"packageManager": "pnpm@10.20.0+sha512.cf9998222162dd85864d0a8102e7892e7ba4ceadebbf5a31f9c2fce48dfce317a9c53b9f6464d1ef9042cba2e02ae02a9f7c143a2b438cd93c91840f0192b9dd" "packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48"
} }

28
pnpm-lock.yaml generated
View File

@@ -44,6 +44,9 @@ importers:
localforage: localforage:
specifier: ^1.10.0 specifier: ^1.10.0
version: 1.10.0 version: 1.10.0
lucide-vue-next:
specifier: ^0.562.0
version: 0.562.0(vue@3.5.24(typescript@5.9.3))
naive-ui: naive-ui:
specifier: ^2.43.1 specifier: ^2.43.1
version: 2.43.1(vue@3.5.24(typescript@5.9.3)) version: 2.43.1(vue@3.5.24(typescript@5.9.3))
@@ -75,12 +78,6 @@ importers:
'@types/node': '@types/node':
specifier: ^22.18.11 specifier: ^22.18.11
version: 22.19.1 version: 22.19.1
'@vicons/antd':
specifier: ^0.13.0
version: 0.13.0
'@vicons/ionicons5':
specifier: ^0.13.0
version: 0.13.0
'@vitejs/plugin-vue': '@vitejs/plugin-vue':
specifier: ^6.0.1 specifier: ^6.0.1
version: 6.0.1(vite@7.2.2(@types/node@22.19.1)(jiti@2.6.1)(sass@1.94.0)(tsx@4.20.6))(vue@3.5.24(typescript@5.9.3)) version: 6.0.1(vite@7.2.2(@types/node@22.19.1)(jiti@2.6.1)(sass@1.94.0)(tsx@4.20.6))(vue@3.5.24(typescript@5.9.3))
@@ -845,12 +842,6 @@ packages:
resolution: {integrity: sha512-/++5CYLQqsO9HFGLI7APrxBJYo+5OCMpViuhV8q5/Qa3o5mMrF//eQHks+PXcsAVaLdn817fMuS7zqoXNNZGaw==} resolution: {integrity: sha512-/++5CYLQqsO9HFGLI7APrxBJYo+5OCMpViuhV8q5/Qa3o5mMrF//eQHks+PXcsAVaLdn817fMuS7zqoXNNZGaw==}
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
'@vicons/antd@0.13.0':
resolution: {integrity: sha512-yrUGoUSz2BbGupk9ghQOahc04n5H3MwUDM9pVPsLh9U1uqB47oRWZvYRiZaT1JKPqgTgSE6BXcVw4i9MOF4M+g==}
'@vicons/ionicons5@0.13.0':
resolution: {integrity: sha512-zvZKBPjEXKN7AXNo2Na2uy+nvuv6SP4KAMQxpKL2vfHMj0fSvuw7JZcOPCjQC3e7ayssKnaoFVAhbYcW6v41qQ==}
'@vitejs/plugin-vue-jsx@5.1.1': '@vitejs/plugin-vue-jsx@5.1.1':
resolution: {integrity: sha512-uQkfxzlF8SGHJJVH966lFTdjM/lGcwJGzwAHpVqAPDD/QcsqoUGa+q31ox1BrUfi+FLP2ChVp7uLXE3DkHyDdQ==} resolution: {integrity: sha512-uQkfxzlF8SGHJJVH966lFTdjM/lGcwJGzwAHpVqAPDD/QcsqoUGa+q31ox1BrUfi+FLP2ChVp7uLXE3DkHyDdQ==}
engines: {node: ^20.19.0 || >=22.12.0} engines: {node: ^20.19.0 || >=22.12.0}
@@ -1636,6 +1627,11 @@ packages:
lru-cache@5.1.1: lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
lucide-vue-next@0.562.0:
resolution: {integrity: sha512-LN0BLGKMFulv0lnfK29r14DcngRUhIqdcaL0zXTt2o0oS9odlrjCGaU3/X9hIihOjjN8l8e+Y9G/famcNYaI7Q==}
peerDependencies:
vue: '>=3.0.1'
magic-string@0.30.21: magic-string@0.30.21:
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
@@ -2871,10 +2867,6 @@ snapshots:
'@typescript-eslint/types': 8.46.4 '@typescript-eslint/types': 8.46.4
eslint-visitor-keys: 4.2.1 eslint-visitor-keys: 4.2.1
'@vicons/antd@0.13.0': {}
'@vicons/ionicons5@0.13.0': {}
'@vitejs/plugin-vue-jsx@5.1.1(vite@7.2.2(@types/node@22.19.1)(jiti@2.6.1)(sass@1.94.0)(tsx@4.20.6))(vue@3.5.24(typescript@5.9.3))': '@vitejs/plugin-vue-jsx@5.1.1(vite@7.2.2(@types/node@22.19.1)(jiti@2.6.1)(sass@1.94.0)(tsx@4.20.6))(vue@3.5.24(typescript@5.9.3))':
dependencies: dependencies:
'@babel/core': 7.28.5 '@babel/core': 7.28.5
@@ -3701,6 +3693,10 @@ snapshots:
dependencies: dependencies:
yallist: 3.1.1 yallist: 3.1.1
lucide-vue-next@0.562.0(vue@3.5.24(typescript@5.9.3)):
dependencies:
vue: 3.5.24(typescript@5.9.3)
magic-string@0.30.21: magic-string@0.30.21:
dependencies: dependencies:
'@jridgewell/sourcemap-codec': 1.5.5 '@jridgewell/sourcemap-codec': 1.5.5

View File

@@ -7,10 +7,10 @@ import { dateZhCN, NConfigProvider, NDialogProvider, NLoadingBarProvider, NMessa
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { themeMode, offlineDev } = storeToRefs(settingStore); const { themeMode, mockUser } = storeToRefs(settingStore);
// 允许通过控制台启用离线开发模式 (登录页适用) // 允许通过控制台启用离线开发模式 (登录页适用)
window.$offlineDev = offlineDev; window.$mockUser = mockUser;
useVersionCheckQuery(); useVersionCheckQuery();
</script> </script>

View File

@@ -1,8 +1,8 @@
import { useUserStore } from '@/stores'; import { useUserStore } from '@/stores';
import { getAppEnvConfig, RequestClient } from '@/utils'; import { createHttpClient, getAppEnvConfig } from '@/utils';
import type { AxiosError } from 'axios'; import type { AxiosError } from 'axios';
export const ndmClient = new RequestClient({ export const ndmClient = createHttpClient({
requestInterceptor: async (config) => { requestInterceptor: async (config) => {
const userStore = useUserStore(); const userStore = useUserStore();
const { lampAuthorization, lampClientId, lampClientSecret } = getAppEnvConfig(); const { lampAuthorization, lampClientId, lampClientSecret } = getAppEnvConfig();
@@ -25,7 +25,7 @@ export const ndmClient = new RequestClient({
const userStore = useUserStore(); const userStore = useUserStore();
await userStore.lampLogin(stationCode); await userStore.lampLogin(stationCode);
error.config.headers.token = userStore.lampLoginResultRecord?.[stationCode]?.token ?? ''; error.config.headers.token = userStore.lampLoginResultRecord?.[stationCode]?.token ?? '';
return ndmClient.requestInstance(error.config); return ndmClient.clientInstance(error.config);
} }
return Promise.reject(error); return Promise.reject(error);
}, },

View File

@@ -1,9 +1,9 @@
import router from '@/router'; import router from '@/router';
import { useUserStore } from '@/stores'; import { useUserStore } from '@/stores';
import { getAppEnvConfig, RequestClient } from '@/utils'; import { createHttpClient, getAppEnvConfig } from '@/utils';
import type { AxiosError } from 'axios'; import type { AxiosError } from 'axios';
export const userClient = new RequestClient({ export const userClient = createHttpClient({
requestInterceptor: (config) => { requestInterceptor: (config) => {
const userStore = useUserStore(); const userStore = useUserStore();
const { lampAuthorization, lampClientId, lampClientSecret } = getAppEnvConfig(); const { lampAuthorization, lampClientId, lampClientSecret } = getAppEnvConfig();

View File

@@ -3,4 +3,5 @@ export interface Station {
name: string; name: string;
online: boolean; online: boolean;
ip: string; ip: string;
occ?: boolean; // 是否为控制中心
} }

View File

@@ -0,0 +1,21 @@
import type { BaseModel, ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO } from '@/apis';
import type { Nullable, Optional } from '@/types';
export interface BaseEmployee extends BaseModel {
userId: string;
realName: string;
defUser: Nullable<
{
username: string;
nickName: string;
} & BaseModel
>;
}
export type BaseEmployeeResultVO = Nullable<BaseEmployee>;
export type BaseEmployeeSaveVO = Partial<Omit<BaseEmployee, ReduceForSaveVO>>;
export type BaseEmployeeUpdateVO = Optional<Omit<BaseEmployee, ReduceForUpdateVO>>;
export type BaseEmployeePageQuery = Partial<Omit<BaseEmployee, ReduceForPageQuery>>;

View File

@@ -1,3 +1 @@
export * from './model'; export * from './base-employee';
export * from './page';
export * from './reduce';

View File

@@ -1,5 +1,5 @@
import type { Nullable, Optional } from '@/types'; import type { Nullable, Optional } from '@/types';
import type { ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO } from '../../base'; import type { ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO } from '../../schema';
import type { NdmAlarmHost } from './alarm'; import type { NdmAlarmHost } from './alarm';
import type { NdmSecurityBox, NdmSwitch } from './other'; import type { NdmSecurityBox, NdmSwitch } from './other';
import type { NdmNvr } from './storage'; import type { NdmNvr } from './storage';

View File

@@ -1,5 +1,6 @@
export * from './ndm-call-log'; export * from './ndm-call-log';
export * from './ndm-device-alarm-log'; export * from './ndm-device-alarm-log';
export * from './ndm-device-alarm-snap-log';
export * from './ndm-icmp-log'; export * from './ndm-icmp-log';
export * from './ndm-record-check'; export * from './ndm-record-check';
export * from './ndm-snmp-log'; export * from './ndm-snmp-log';

View File

@@ -2,11 +2,38 @@ import type { BaseModel, ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO
import type { Nullable } from '@/types'; import type { Nullable } from '@/types';
export interface NdmCallLog extends BaseModel { export interface NdmCallLog extends BaseModel {
/**
* 调用者国标码
*/
sourceGbId: string; sourceGbId: string;
/**
* 用户所属类别
*/
sourceType: string;
/**
* 被调用设备国标码
*/
targetGbId: string; targetGbId: string;
/**
* 被调用设备名称
*/
targetName: string;
/**
* 调用方法
*/
method: string; method: string;
/**
* message类型
*/
messageType: string; messageType: string;
/**
* 操作类型
*/
cmdType: string; cmdType: string;
/**
* 日志类型
*/
logType: string;
} }
export type NdmCallLogResultVO = Nullable<NdmCallLog>; export type NdmCallLogResultVO = Nullable<NdmCallLog>;

View File

@@ -0,0 +1,16 @@
import type { BaseModel, ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO } from '@/apis';
import type { Nullable } from '@/types';
export interface NdmDeviceAlarmSnapLog extends BaseModel {
absoluteFilePath: string;
path: string;
url: string;
}
export type NdmDeviceAlarmSnapLogResultVO = Nullable<NdmDeviceAlarmSnapLog>;
export type NdmDeviceAlarmSnapLogSaveVO = Partial<Omit<NdmDeviceAlarmSnapLog, ReduceForSaveVO>>;
export type NdmDeviceAlarmSnapLogUpdateVO = Partial<Omit<NdmDeviceAlarmSnapLog, ReduceForUpdateVO>>;
export type NdmDeviceAlarmSnapLogPageQuery = Partial<Omit<NdmDeviceAlarmSnapLog, ReduceForPageQuery>>;

View File

@@ -2,18 +2,57 @@ import type { BaseModel, ReduceForSaveVO, ReduceForUpdateVO, ReduceForPageQuery
import type { Nullable } from '@/types'; import type { Nullable } from '@/types';
export interface NdmVimpLog extends BaseModel { export interface NdmVimpLog extends BaseModel {
/**
* 请求IP
*/
requestIp: string; requestIp: string;
/**
* 操作内容
*/
description: string; description: string;
/**
* 类路径
*/
classPath: string; classPath: string;
/**
* 函数名
*/
methodName: string; methodName: string;
/**
* 起始时间
*/
startTime: string; startTime: string;
/**
* 结束时间
*/
endTime: string; endTime: string;
/**
* 消耗时间
*/
consumedTime: string; consumedTime: string;
/**
* 操作参数
*/
params: string; params: string;
/**
* 操作结果
*/
result: string; result: string;
/**
* 请求类型
*/
httpMethod: string; httpMethod: string;
/**
* 请求用户
*/
userId: string; userId: string;
/**
* 日志类型
*/
logType: number; logType: number;
/**
* 目标国标码
*/
targetCode: string; targetCode: string;
} }

View File

@@ -1,2 +1,3 @@
export * from './ndm-permission';
export * from './ndm-security-box'; export * from './ndm-security-box';
export * from './ndm-switch'; export * from './ndm-switch';

View File

@@ -0,0 +1,34 @@
import type { BaseModel, ReduceForPageQuery, ReduceForSaveVO, ReduceForUpdateVO, Station } from '@/apis';
import type { PermissionType } from '@/enums';
import type { Nullable, Optional } from '@/types';
export interface NdmPermission extends BaseModel {
/**
* 员工ID
*/
employeeId: string;
/**
* 服务器IP地址
*/
ipAddress: string;
/**
* 站号
*/
stationCode: Station['code'];
/**
* 站名
*/
name: string;
/**
* 权限类型
*/
type: PermissionType;
}
export type NdmPermissionResultVO = Nullable<NdmPermission>;
export type NdmPermissionSaveVO = Partial<Omit<NdmPermission, ReduceForSaveVO>>;
export type NdmPermissionUpdateVO = Optional<Omit<NdmPermission, ReduceForUpdateVO>>;
export type NdmPermissionPageQuery = Partial<Omit<NdmPermission, ReduceForPageQuery>>;

View File

@@ -1 +1,3 @@
export * from './invite-stream-type';
export * from './send-rtp-info';
export * from './snap-result'; export * from './snap-result';

View File

@@ -0,0 +1 @@
export type InviteStreamType = 'PLAY' | 'PLAYBACK' | 'DOWNLOAD' | 'PUSH' | 'PROXY' | 'CLOUD_RECORD_PUSH' | 'CLOUD_RECORD_PROXY';

View File

@@ -0,0 +1,51 @@
import type { InviteStreamType } from '@/apis';
import type { Nullable } from '@/types';
export type SendRtpInfo = Nullable<{
ip: string;
port: number;
ssrc: string;
platformId: string;
deviceId: string;
channelId: string;
app: string;
streamId: string;
/**
* 推流状态
* 0 等待设备推流上来
* 1 等待上级平台回复ack
* 2 推流中
*/
status: number;
/**
* 是否为tcp
*/
tcp: boolean;
/**
* 是否为tcp主动模式
*/
tcpActive: boolean;
localPort: number;
mediaServerId: string;
serverId: string;
callId: string;
fromTag: string;
toTag: string;
/**
* 发送时rtp的ptuint8_t,不传时默认为96
*/
pt: number;
/**
* 发送时rtp的负载类型。为true时负载为ps为false时为es
*/
usePs: boolean;
/**
* 当usePs 为false时有效。为1时发送音频为0时发送视频不传时默认为0
*/
onlyAudio: boolean;
/**
* 是否开启rtcp保活
*/
rtcp: boolean;
playType: InviteStreamType;
}>;

View File

@@ -1,4 +1,5 @@
export * from './base'; export * from './base';
export * from './biz'; export * from './biz';
export * from './common'; export * from './common';
export * from './schema';
export * from './system'; export * from './system';

View File

@@ -0,0 +1,3 @@
export * from './model';
export * from './page';
export * from './reduce';

View File

@@ -0,0 +1,21 @@
import type { BaseEmployeePageQuery, BaseEmployeeResultVO, PageParams, PageResult } from '@/apis';
import { userClient } from '@/apis/client';
import { unwrapResponse } from '@/utils';
export const pageBaseEmployeeApi = async (pageQuery: PageParams<BaseEmployeePageQuery>, options?: { signal?: AbortSignal }) => {
const { signal } = options ?? {};
const client = userClient;
const endpoint = '/api/base/baseEmployee/page';
const resp = await client.post<PageResult<BaseEmployeeResultVO>>(endpoint, pageQuery, { signal });
const data = unwrapResponse(resp);
return data;
};
export const detailBaseEmployeeApi = async (id: string, options?: { signal?: AbortSignal }) => {
const { signal } = options ?? {};
const client = userClient;
const endpoint = `/api/base/baseEmployee/detail`;
const resp = await client.get<BaseEmployeeResultVO>(endpoint, { params: { id }, signal });
const data = unwrapResponse(resp);
return data;
};

View File

@@ -0,0 +1 @@
export * from './base-employee';

View File

@@ -1,7 +1,7 @@
import { initStationDevices, ndmClient, userClient, type StationDevices } from '@/apis'; import { initStationDevices, ndmClient, userClient, type Station, type StationDevices } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse } from '@/utils';
export const getAllDevicesApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => { export const getAllDevicesApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';

View File

@@ -1,5 +1,5 @@
import { ndmClient, userClient, type Station } from '@/apis'; import { ndmClient, userClient, type Station } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapVoidResponse } from '@/utils';
export const resetMonitorScheduleApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const resetMonitorScheduleApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
@@ -7,5 +7,5 @@ export const resetMonitorScheduleApi = async (options?: { stationCode?: Station[
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmConstant/anyTenant/resetMonitorSchedule`; const endpoint = `${prefix}/api/ndm/ndmConstant/anyTenant/resetMonitorSchedule`;
const resp = await client.get<void>(endpoint, { signal }); const resp = await client.get<void>(endpoint, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };

View File

@@ -1,5 +1,5 @@
import { ndmClient, userClient, type Station } from '@/apis'; import { ndmClient, userClient, type Station } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapVoidResponse } from '@/utils';
export const verifyApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const verifyApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
@@ -7,5 +7,5 @@ export const verifyApi = async (options?: { stationCode?: Station['code']; signa
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmKeepAlive/verify`; const endpoint = `${prefix}/api/ndm/ndmKeepAlive/verify`;
const resp = await client.post<void>(endpoint, {}, { retRaw: true, timeout: 5000, signal }); const resp = await client.post<void>(endpoint, {}, { retRaw: true, timeout: 5000, signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };

View File

@@ -6,4 +6,5 @@ export * from './icmp';
export * from './log'; export * from './log';
export * from './storage'; export * from './storage';
export * from './other'; export * from './other';
export * from './upper-ndm';
export * from './video'; export * from './video';

View File

@@ -1,5 +1,6 @@
export * from './ndm-call-log'; export * from './ndm-call-log';
export * from './ndm-device-alarm-log'; export * from './ndm-device-alarm-log';
export * from './ndm-device-alarm-snap-log';
export * from './ndm-icmp-log'; export * from './ndm-icmp-log';
export * from './ndm-snmp-log'; export * from './ndm-snmp-log';
export * from './ndm-record-check'; export * from './ndm-record-check';

View File

@@ -0,0 +1,62 @@
import {
ndmClient,
userClient,
type NdmDeviceAlarmSnapLogPageQuery,
type NdmDeviceAlarmSnapLogResultVO,
type NdmDeviceAlarmSnapLogSaveVO,
type NdmDeviceAlarmSnapLogUpdateVO,
type PageParams,
type PageResult,
type Station,
} from '@/apis';
import { unwrapResponse } from '@/utils';
export const pageDeviceAlarmSnapLogApi = async (pageQuery: PageParams<NdmDeviceAlarmSnapLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog/page`;
const resp = await client.post<PageResult<NdmDeviceAlarmSnapLogResultVO>>(endpoint, pageQuery, { signal });
const data = unwrapResponse(resp);
return data;
};
export const detailDeviceAlarmSnapLogApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog/detail`;
const resp = await client.get<NdmDeviceAlarmSnapLogResultVO>(endpoint, { params: { id }, signal });
const data = unwrapResponse(resp);
return data;
};
export const saveDeviceAlarmSnapLogApi = async (saveVO: NdmDeviceAlarmSnapLogSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog`;
const resp = await client.post<NdmDeviceAlarmSnapLogResultVO>(endpoint, saveVO, { signal });
const data = unwrapResponse(resp);
return data;
};
export const updateDeviceAlarmSnapLogApi = async (updateVO: NdmDeviceAlarmSnapLogUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog`;
const resp = await client.put<NdmDeviceAlarmSnapLogResultVO>(endpoint, updateVO, { signal });
const data = unwrapResponse(resp);
return data;
};
export const deleteDeviceAlarmSnapLogApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmSnapLog`;
const resp = await client.delete<boolean>(endpoint, ids, { signal });
const data = unwrapResponse(resp);
return data;
};

View File

@@ -1,8 +1,8 @@
import { ndmClient, userClient, type ClientChannel, type NdmNvrResultVO, type NdmRecordCheck } from '@/apis'; import { ndmClient, userClient, type ClientChannel, type NdmNvrResultVO, type NdmRecordCheck, type Station } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse } from '@/utils';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
export const getChannelListApi = async (ndmNvr: NdmNvrResultVO, options?: { stationCode?: string; signal?: AbortSignal }) => { export const getChannelListApi = async (ndmNvr: NdmNvrResultVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -12,7 +12,7 @@ export const getChannelListApi = async (ndmNvr: NdmNvrResultVO, options?: { stat
return data; return data;
}; };
export const getRecordCheckApi = async (ndmNvr: NdmNvrResultVO, lastDays: number, gbCodeList: string[], options?: { stationCode?: string; signal?: AbortSignal }) => { export const getRecordCheckApi = async (ndmNvr: NdmNvrResultVO, lastDays: number, gbCodeList: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -27,7 +27,7 @@ export const getRecordCheckApi = async (ndmNvr: NdmNvrResultVO, lastDays: number
return data; return data;
}; };
export const reloadRecordCheckApi = async (channel: ClientChannel, dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => { export const reloadRecordCheckApi = async (channel: ClientChannel, dayOffset: number, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -37,7 +37,7 @@ export const reloadRecordCheckApi = async (channel: ClientChannel, dayOffset: nu
return data; return data;
}; };
export const reloadAllRecordCheckApi = async (dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => { export const reloadAllRecordCheckApi = async (dayOffset: number, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -48,3 +48,13 @@ export const reloadAllRecordCheckApi = async (dayOffset: number, options?: { sta
if (!data) throw new Error(`${data}`); if (!data) throw new Error(`${data}`);
return data; return data;
}; };
export const batchExportRecordCheckApi = async (params: { checkDuration: number; gapSeconds: number; stationCode: Station['code'][] }, options?: { signal?: AbortSignal }) => {
const { signal } = options ?? {};
const { checkDuration, gapSeconds, stationCode } = params;
const client = userClient;
const endpoint = `/api/ndm/ndmRecordCheck/batchExportByTemplate`;
const resp = await client.post<Blob>(endpoint, { checkDuration, gapSeconds, stationCode }, { responseType: 'blob', retRaw: true, signal });
const data = unwrapResponse(resp);
return data;
};

View File

@@ -1,3 +1,4 @@
export * from './ndm-permission';
export * from './ndm-security-box'; export * from './ndm-security-box';
export * from './ndm-service-available'; export * from './ndm-service-available';
export * from './ndm-switch'; export * from './ndm-switch';

View File

@@ -0,0 +1,83 @@
import {
ndmClient,
userClient,
type NdmPermissionPageQuery,
type NdmPermissionResultVO,
type NdmPermissionSaveVO,
type NdmPermissionUpdateVO,
type PageParams,
type PageResult,
type Station,
} from '@/apis';
import type { PermissionTypeEnum } from '@/enums';
import { unwrapResponse } from '@/utils';
export const permissionTypesApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmPermission/types`;
const resp = await client.get<PermissionTypeEnum>(endpoint, { signal });
const data = unwrapResponse(resp);
return data;
};
export const pagePermissionApi = async (pageQuery: PageParams<NdmPermissionPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmPermission/page`;
const resp = await client.post<PageResult<NdmPermissionResultVO>>(endpoint, pageQuery, { signal });
const data = unwrapResponse(resp);
return data;
};
export const detailPermissionApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmPermission/detail`;
const resp = await client.get<NdmPermissionResultVO>(endpoint, { params: { id }, signal });
const data = unwrapResponse(resp);
return data;
};
export const savePermissionApi = async (saveVO: NdmPermissionSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmPermission`;
const resp = await client.post<NdmPermissionResultVO>(endpoint, saveVO, { signal });
const result = unwrapResponse(resp);
return result;
};
export const updatePermissionApi = async (updateVO: NdmPermissionUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmPermission`;
const resp = await client.put<NdmPermissionResultVO>(endpoint, updateVO, { signal });
const result = unwrapResponse(resp);
return result;
};
export const deletePermissionApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmPermission`;
const resp = await client.delete<boolean>(endpoint, ids, { signal });
const result = unwrapResponse(resp);
return result;
};
export const modifyPermissionApi = async (params: { employeeId: string; saveList: NdmPermissionSaveVO[]; removeList: string[] }, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmPermission/modify`;
const resp = await client.post<boolean>(endpoint, params, { signal });
const result = unwrapResponse(resp);
return result;
};

View File

@@ -10,7 +10,7 @@ import {
type PageResult, type PageResult,
type Station, type Station,
} from '@/apis'; } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse, unwrapVoidResponse } from '@/utils';
export const pageSecurityBoxApi = async (pageQuery: PageParams<NdmSecurityBoxPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const pageSecurityBoxApi = async (pageQuery: PageParams<NdmSecurityBoxPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
@@ -90,7 +90,7 @@ export const probeSecurityBoxApi = async (ids: string[], options?: { stationCode
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/probeByIds`; const endpoint = `${prefix}/api/ndm/ndmSecurityBox/probeByIds`;
const resp = await client.post<void>(endpoint, ids, { signal }); const resp = await client.post<void>(endpoint, ids, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };
export const turnCitcuitStatusApi = async (ipAddress: string, circuitIndex: number, status: number, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const turnCitcuitStatusApi = async (ipAddress: string, circuitIndex: number, status: number, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {

View File

@@ -1,6 +1,16 @@
import { ndmClient, userClient, type MediaServerStatus, type Station } from '@/apis'; import { ndmClient, userClient, type MediaServerStatus, type SendRtpInfo, type Station } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse } from '@/utils';
export const getAllPushApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmServiceAvailable/mediaServer/getAllPush`;
const resp = await client.get<SendRtpInfo[]>(endpoint, { signal });
const data = unwrapResponse(resp);
return data;
};
export const isMediaServerAliveApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const isMediaServerAliveApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;

View File

@@ -10,11 +10,11 @@ import {
type PageResult, type PageResult,
type Station, type Station,
} from '@/apis'; } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse, unwrapVoidResponse } from '@/utils';
export const pageSwitchApi = async (pageQuery: PageParams<NdmSwitchPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const pageSwitchApi = async (pageQuery: PageParams<NdmSwitchPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : ndmClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSwitch/page`; const endpoint = `${prefix}/api/ndm/ndmSwitch/page`;
const resp = await client.post<PageResult<NdmSwitchResultVO>>(endpoint, pageQuery, { signal }); const resp = await client.post<PageResult<NdmSwitchResultVO>>(endpoint, pageQuery, { signal });
@@ -24,7 +24,7 @@ export const pageSwitchApi = async (pageQuery: PageParams<NdmSwitchPageQuery>, o
export const detailSwitchApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const detailSwitchApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : ndmClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSwitch/detail`; const endpoint = `${prefix}/api/ndm/ndmSwitch/detail`;
const resp = await client.get<NdmSwitchResultVO>(endpoint, { params: { id }, signal }); const resp = await client.get<NdmSwitchResultVO>(endpoint, { params: { id }, signal });
@@ -34,7 +34,7 @@ export const detailSwitchApi = async (id: string, options?: { stationCode?: Stat
export const saveSwitchApi = async (saveVO: NdmSwitchSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const saveSwitchApi = async (saveVO: NdmSwitchSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : ndmClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSwitch`; const endpoint = `${prefix}/api/ndm/ndmSwitch`;
const resp = await client.post<NdmSwitchResultVO>(endpoint, saveVO, { signal }); const resp = await client.post<NdmSwitchResultVO>(endpoint, saveVO, { signal });
@@ -44,7 +44,7 @@ export const saveSwitchApi = async (saveVO: NdmSwitchSaveVO, options?: { station
export const updateSwitchApi = async (updateVO: NdmSwitchUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const updateSwitchApi = async (updateVO: NdmSwitchUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : ndmClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSwitch`; const endpoint = `${prefix}/api/ndm/ndmSwitch`;
const resp = await client.put<NdmSwitchResultVO>(endpoint, updateVO, { signal }); const resp = await client.put<NdmSwitchResultVO>(endpoint, updateVO, { signal });
@@ -54,7 +54,7 @@ export const updateSwitchApi = async (updateVO: NdmSwitchUpdateVO, options?: { s
export const deleteSwitchApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const deleteSwitchApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : ndmClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSwitch`; const endpoint = `${prefix}/api/ndm/ndmSwitch`;
const resp = await client.delete<boolean>(endpoint, ids, { signal }); const resp = await client.delete<boolean>(endpoint, ids, { signal });
@@ -64,7 +64,7 @@ export const deleteSwitchApi = async (ids: string[], options?: { stationCode?: S
export const exportSwitchApi = async (pageQuery: PageParams<NdmSwitchPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const exportSwitchApi = async (pageQuery: PageParams<NdmSwitchPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : ndmClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSwitch/defaultExportByTemplate`; const endpoint = `${prefix}/api/ndm/ndmSwitch/defaultExportByTemplate`;
const resp = await client.post<Blob>(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal }); const resp = await client.post<Blob>(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal });
@@ -86,9 +86,9 @@ export const importSwitchApi = async (file: File, options?: { stationCode?: Stat
export const probeSwitchApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const probeSwitchApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : ndmClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSwitch/probeByIds`; const endpoint = `${prefix}/api/ndm/ndmSwitch/probeByIds`;
const resp = await client.post<void>(endpoint, ids, { signal }); const resp = await client.post<void>(endpoint, ids, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };

View File

@@ -1,5 +1,5 @@
import { ndmClient, userClient, type ImportMsg, type NdmNvrPageQuery, type NdmNvrResultVO, type NdmNvrSaveVO, type NdmNvrUpdateVO, type PageParams, type PageResult, type Station } from '@/apis'; import { ndmClient, userClient, type ImportMsg, type NdmNvrPageQuery, type NdmNvrResultVO, type NdmNvrSaveVO, type NdmNvrUpdateVO, type PageParams, type PageResult, type Station } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse, unwrapVoidResponse } from '@/utils';
export const pageNvrPageApi = async (pageQuery: PageParams<NdmNvrPageQuery>, options?: { stationCode: Station['code']; signal?: AbortSignal }) => { export const pageNvrPageApi = async (pageQuery: PageParams<NdmNvrPageQuery>, options?: { stationCode: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
@@ -79,7 +79,7 @@ export const probeNvrApi = async (ids: string[], options?: { stationCode?: Stati
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmNvr/probeByIds`; const endpoint = `${prefix}/api/ndm/ndmNvr/probeByIds`;
const resp = await client.post<void>(endpoint, ids, { signal }); const resp = await client.post<void>(endpoint, ids, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };
export const syncNvrChannelsApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => { export const syncNvrChannelsApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => {
@@ -88,5 +88,5 @@ export const syncNvrChannelsApi = async (options?: { stationCode?: string; signa
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmNvr/syncNvrChannels`; const endpoint = `${prefix}/api/ndm/ndmNvr/syncNvrChannels`;
const resp = await client.get<void>(endpoint, { signal }); const resp = await client.get<void>(endpoint, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };

View File

@@ -0,0 +1 @@
export * from './upper-ndm';

View File

@@ -0,0 +1,20 @@
import { ndmClient, userClient, type Station } from '@/apis';
import { unwrapResponse } from '@/utils';
export async function snapStatusApi(method: 'get', options?: { stationCode?: Station['code']; signal?: AbortSignal }): Promise<boolean>;
export async function snapStatusApi(method: 'post', options: { doSnap: boolean; stationCode?: Station['code']; signal?: AbortSignal }): Promise<boolean>;
export async function snapStatusApi(method: 'get' | 'post', options?: { doSnap?: boolean; stationCode?: Station['code']; signal?: AbortSignal }) {
const { doSnap, stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/anyTenant/snapStatus`;
if (method === 'get') {
const resp = await client.get<boolean>(endpoint, { signal });
const data = unwrapResponse(resp);
return data;
} else {
const resp = await client.post<boolean>(endpoint, doSnap, { signal });
const data = unwrapResponse(resp);
return data;
}
}

View File

@@ -3,4 +3,5 @@ export * from './ndm-camera-ignore';
export * from './ndm-decoder'; export * from './ndm-decoder';
export * from './ndm-keyboard'; export * from './ndm-keyboard';
export * from './ndm-media-server'; export * from './ndm-media-server';
export * from './ndm-snap';
export * from './ndm-video-server'; export * from './ndm-video-server';

View File

@@ -1,7 +1,17 @@
import { ndmClient, userClient, type NdmCameraIgnorePageQuery, type NdmCameraIgnoreResultVO, type NdmCameraIgnoreSaveVO, type NdmCameraIgnoreUpdateVO, type PageParams, type PageResult } from '@/apis'; import {
ndmClient,
userClient,
type NdmCameraIgnorePageQuery,
type NdmCameraIgnoreResultVO,
type NdmCameraIgnoreSaveVO,
type NdmCameraIgnoreUpdateVO,
type PageParams,
type PageResult,
type Station,
} from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse } from '@/utils';
export const pageCameraIgnoreApi = async (pageQuery: PageParams<NdmCameraIgnorePageQuery>, options?: { stationCode?: string; signal?: AbortSignal }) => { export const pageCameraIgnoreApi = async (pageQuery: PageParams<NdmCameraIgnorePageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -11,7 +21,7 @@ export const pageCameraIgnoreApi = async (pageQuery: PageParams<NdmCameraIgnoreP
return data; return data;
}; };
export const detailCameraIgnoreApi = async (id: string, options?: { stationCode?: string; signal?: AbortSignal }) => { export const detailCameraIgnoreApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -21,7 +31,7 @@ export const detailCameraIgnoreApi = async (id: string, options?: { stationCode?
return data; return data;
}; };
export const saveCameraIgnoreApi = async (saveVO: NdmCameraIgnoreSaveVO, options?: { stationCode?: string; signal?: AbortSignal }) => { export const saveCameraIgnoreApi = async (saveVO: NdmCameraIgnoreSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -31,7 +41,7 @@ export const saveCameraIgnoreApi = async (saveVO: NdmCameraIgnoreSaveVO, options
return data; return data;
}; };
export const updateCameraIgnoreApi = async (updateVO: NdmCameraIgnoreUpdateVO, options?: { stationCode?: string; signal?: AbortSignal }) => { export const updateCameraIgnoreApi = async (updateVO: NdmCameraIgnoreUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
@@ -41,7 +51,7 @@ export const updateCameraIgnoreApi = async (updateVO: NdmCameraIgnoreUpdateVO, o
return data; return data;
}; };
export const deleteCameraIgnoreApi = async (ids: string[], options?: { stationCode?: string; signal?: AbortSignal }) => { export const deleteCameraIgnoreApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';

View File

@@ -93,7 +93,7 @@ export const getCameraSnapApi = async (deviceId: string, options?: { signal?: Ab
return data; return data;
}; };
export const syncCameraApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => { export const syncCameraApi = async (options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient; const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';

View File

@@ -10,7 +10,7 @@ import {
type PageResult, type PageResult,
type Station, type Station,
} from '@/apis'; } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse, unwrapVoidResponse } from '@/utils';
export const pageDecoderApi = async (pageQuery: PageParams<NdmDecoderPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const pageDecoderApi = async (pageQuery: PageParams<NdmDecoderPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
@@ -90,5 +90,5 @@ export const probeDecoderApi = async (ids: string[], options?: { stationCode?: S
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDecoder/probeByIds`; const endpoint = `${prefix}/api/ndm/ndmDecoder/probeByIds`;
const resp = await client.post<void>(endpoint, ids, { signal }); const resp = await client.post<void>(endpoint, ids, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };

View File

@@ -10,7 +10,7 @@ import {
type PageResult, type PageResult,
type Station, type Station,
} from '@/apis'; } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse, unwrapVoidResponse } from '@/utils';
export const postNdmMediaServerPage = async (pageQuery: PageParams<NdmMediaServerPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const postNdmMediaServerPage = async (pageQuery: PageParams<NdmMediaServerPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
@@ -90,5 +90,5 @@ export const probeMediaServerApi = async (ids: string[], options?: { stationCode
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmMediaServer/probeByIds`; const endpoint = `${prefix}/api/ndm/ndmMediaServer/probeByIds`;
const resp = await client.post<void>(endpoint, ids, { signal }); const resp = await client.post<void>(endpoint, ids, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };

View File

@@ -0,0 +1,20 @@
import { ndmClient, userClient, type Station } from '@/apis';
import { unwrapResponse } from '@/utils';
export async function retentionDaysApi(method: 'get', options?: { stationCode?: Station['code']; signal?: AbortSignal }): Promise<number>;
export async function retentionDaysApi(method: 'post', options: { days: number; stationCode?: Station['code']; signal?: AbortSignal }): Promise<number>;
export async function retentionDaysApi(method: 'get' | 'post', options?: { days?: number; stationCode?: Station['code']; signal?: AbortSignal }) {
const { days, stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmSnap/retentionDays`;
if (method === 'get') {
const resp = await client.get<number>(endpoint, { signal });
const data = unwrapResponse(resp);
return data;
} else {
const resp = await client.post<number>(endpoint, days, { signal });
const data = unwrapResponse(resp);
return data;
}
}

View File

@@ -10,7 +10,7 @@ import {
type PageResult, type PageResult,
type Station, type Station,
} from '@/apis'; } from '@/apis';
import { unwrapResponse } from '@/utils'; import { unwrapResponse, unwrapVoidResponse } from '@/utils';
export const pageVideoServerApi = async (pageQuery: PageParams<NdmVideoServerPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { export const pageVideoServerApi = async (pageQuery: PageParams<NdmVideoServerPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {}; const { stationCode, signal } = options ?? {};
@@ -90,5 +90,5 @@ export const probeVideoServerApi = async (ids: string[], options?: { stationCode
const prefix = stationCode ? `/${stationCode}` : ''; const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmVideoServer/probeByIds`; const endpoint = `${prefix}/api/ndm/ndmVideoServer/probeByIds`;
const resp = await client.post<void>(endpoint, ids, { signal }); const resp = await client.post<void>(endpoint, ids, { signal });
unwrapResponse(resp); unwrapVoidResponse(resp);
}; };

View File

@@ -1,2 +1,3 @@
export * from './base';
export * from './biz'; export * from './biz';
export * from './system'; export * from './system';

View File

@@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ClockCircleOutlined, CodeOutlined, FireOutlined, SaveOutlined } from '@vicons/antd'; import { ClockCheckIcon, CpuIcon, HardDriveIcon, MemoryStickIcon } from 'lucide-vue-next';
import { NCard, NFlex, NIcon, NProgress, type ProgressStatus } from 'naive-ui'; import { NCard, NFlex, NIcon, NProgress, type ProgressStatus } from 'naive-ui';
import { computed, toRefs } from 'vue'; import { computed, toRefs } from 'vue';
@@ -17,7 +17,7 @@ const props = defineProps<{
const { cpuUsage, memUsage, diskUsage, runningTime, cpuUsageLabel, memUsageLabel, diskUsageLabel, runningTimeLabel } = toRefs(props); const { cpuUsage, memUsage, diskUsage, runningTime, cpuUsageLabel, memUsageLabel, diskUsageLabel, runningTimeLabel } = toRefs(props);
const showCard = computed(() => { const showCard = computed(() => {
return Object.values({ cpuUsage, memUsage, diskUsage, runningTime }).some((value) => !!value); return Object.values({ cpuUsage, memUsage, diskUsage, runningTime }).some((refValue) => !!refValue.value);
}); });
const cpuPercent = computed(() => { const cpuPercent = computed(() => {
@@ -54,22 +54,22 @@ const getProgressStatus = (percent: number): ProgressStatus => {
<template #default> <template #default>
<NFlex vertical> <NFlex vertical>
<NFlex v-if="cpuUsage" style="width: 100%" align="center" :wrap="false"> <NFlex v-if="cpuUsage" style="width: 100%" align="center" :wrap="false">
<NIcon :component="FireOutlined" /> <NIcon :component="CpuIcon" />
<span style="word-break: keep-all">{{ cpuUsageLabel || 'CPU' }}</span> <span style="word-break: keep-all">{{ cpuUsageLabel || 'CPU' }}</span>
<NProgress :percentage="cpuPercent" :status="getProgressStatus(cpuPercent)">{{ cpuPercent }}%</NProgress> <NProgress :percentage="cpuPercent" :status="getProgressStatus(cpuPercent)">{{ cpuPercent }}%</NProgress>
</NFlex> </NFlex>
<NFlex v-if="memUsage" style="width: 100%" align="center" :wrap="false"> <NFlex v-if="memUsage" style="width: 100%" align="center" :wrap="false">
<NIcon :component="CodeOutlined" /> <NIcon :component="MemoryStickIcon" />
<span style="word-break: keep-all">{{ memUsageLabel || '内存' }}</span> <span style="word-break: keep-all">{{ memUsageLabel || '内存' }}</span>
<NProgress :percentage="memPercent" :status="getProgressStatus(memPercent)">{{ memPercent }}%</NProgress> <NProgress :percentage="memPercent" :status="getProgressStatus(memPercent)">{{ memPercent }}%</NProgress>
</NFlex> </NFlex>
<NFlex v-if="diskUsage" style="width: 100%" align="center" :wrap="false"> <NFlex v-if="diskUsage" style="width: 100%" align="center" :wrap="false">
<NIcon :component="SaveOutlined" /> <NIcon :component="HardDriveIcon" />
<span style="word-break: keep-all">{{ diskUsageLabel || '磁盘' }}</span> <span style="word-break: keep-all">{{ diskUsageLabel || '磁盘' }}</span>
<NProgress :percentage="diskPercent" :status="getProgressStatus(diskPercent)">{{ diskPercent }}%</NProgress> <NProgress :percentage="diskPercent" :status="getProgressStatus(diskPercent)">{{ diskPercent }}%</NProgress>
</NFlex> </NFlex>
<NFlex v-if="runningTime" style="width: 100%" align="center" :wrap="false"> <NFlex v-if="runningTime" style="width: 100%" align="center" :wrap="false">
<NIcon :component="ClockCircleOutlined" /> <NIcon :component="ClockCheckIcon" />
<span>{{ runningTimeLabel || '运行时间' }}</span> <span>{{ runningTimeLabel || '运行时间' }}</span>
<span>{{ formattedRunningTime }}</span> <span>{{ formattedRunningTime }}</span>
</NFlex> </NFlex>

View File

@@ -5,9 +5,9 @@ import { DEVICE_TYPE_LITERALS, DEVICE_TYPE_NAMES, tryGetDeviceType } from '@/enu
import { useDeviceStore } from '@/stores'; import { useDeviceStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
import { ApiOutlined, ReloadOutlined } from '@vicons/antd';
import { isCancel } from 'axios'; import { isCancel } from 'axios';
import destr from 'destr'; import destr from 'destr';
import { LinkIcon, RotateCwIcon } from 'lucide-vue-next';
import { NButton, NCard, NFlex, NIcon, NTag, NTooltip } from 'naive-ui'; import { NButton, NCard, NFlex, NIcon, NTag, NTooltip } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { computed, inject, onBeforeUnmount, ref, toRefs } from 'vue'; import { computed, inject, onBeforeUnmount, ref, toRefs } from 'vue';
@@ -152,7 +152,7 @@ onBeforeUnmount(() => {
<template #trigger> <template #trigger>
<NButton size="small" quaternary circle :loading="probing" @click="() => probeDevice()"> <NButton size="small" quaternary circle :loading="probing" @click="() => probeDevice()">
<template #icon> <template #icon>
<NIcon :component="ApiOutlined" /> <NIcon :component="LinkIcon" />
</template> </template>
</NButton> </NButton>
</template> </template>
@@ -164,7 +164,7 @@ onBeforeUnmount(() => {
<template #trigger> <template #trigger>
<NButton size="small" quaternary circle :loading="loading" @click="() => detailDevice()"> <NButton size="small" quaternary circle :loading="loading" @click="() => detailDevice()">
<template #icon> <template #icon>
<NIcon :component="ReloadOutlined" /> <NIcon :component="RotateCwIcon" />
</template> </template>
</NButton> </NButton>
</template> </template>

View File

@@ -1,34 +1,58 @@
<script setup lang="ts"> <script setup lang="ts">
import { getChannelListApi, getRecordCheckApi, reloadAllRecordCheckApi, reloadRecordCheckApi, type NdmNvrResultVO, type NdmRecordCheck, type RecordItem, type Station } from '@/apis'; import { getChannelListApi, getRecordCheckApi, reloadAllRecordCheckApi, reloadRecordCheckApi, type NdmNvrResultVO, type RecordItem, type Station } from '@/apis';
import { exportRecordDiagCsv, transformRecordChecks } from '@/helpers'; import { exportRecordDiagCsv, transformRecordChecks } from '@/helpers';
import { useStationStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query';
import { DownloadOutlined, ReloadOutlined } from '@vicons/antd';
import { isCancel } from 'axios'; import { isCancel } from 'axios';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { DownloadIcon, RotateCwIcon } from 'lucide-vue-next';
import { NButton, NCard, NFlex, NIcon, NPagination, NPopconfirm, NPopover, NRadioButton, NRadioGroup, NTooltip, useThemeVars } from 'naive-ui'; import { NButton, NCard, NFlex, NIcon, NPagination, NPopconfirm, NPopover, NRadioButton, NRadioGroup, NTooltip, useThemeVars } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { computed, onBeforeUnmount, onMounted, ref, toRefs, watch } from 'vue'; import { computed, onBeforeUnmount, ref, toRefs, watch } from 'vue';
const props = defineProps<{ const props = defineProps<{
ndmDevice: NdmNvrResultVO; ndmDevice: NdmNvrResultVO;
station: Station; station: Station;
}>(); }>();
const settingStore = useSettingStore();
const { activeRequests } = storeToRefs(settingStore);
const themeVars = useThemeVars(); const themeVars = useThemeVars();
const stationStore = useStationStore(); const queryClient = useQueryClient();
const { stations } = storeToRefs(stationStore);
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
const recordChecks = ref<NdmRecordCheck[]>([]);
const lossInput = ref<number>(0); const lossInput = ref<number>(0);
const abortController = ref<AbortController>(new AbortController());
const NVR_RECORD_CHECK_KEY = 'nvr_record_check_query';
const {
data: recordChecks,
isFetching: loading,
refetch: refetchRecordChecks,
} = useQuery({
queryKey: computed(() => [NVR_RECORD_CHECK_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
enabled: computed(() => activeRequests.value),
refetchInterval: 30 * 1000,
gcTime: 0,
queryFn: async ({ signal }) => {
const checks = await getRecordCheckApi(ndmDevice.value, 90, [], { stationCode: station.value.code, signal });
return checks;
},
});
watch(activeRequests, (active) => {
if (!active) {
queryClient.cancelQueries({ queryKey: [NVR_RECORD_CHECK_KEY] });
}
});
const recordDiags = computed(() => { const recordDiags = computed(() => {
return transformRecordChecks(recordChecks.value).filter((recordDiag) => { return transformRecordChecks(recordChecks.value ?? []).filter((recordDiag) => {
if (lossInput.value === 0) { if (lossInput.value === 0) {
return true; return true;
} else if (lossInput.value === 1) { } else if (lossInput.value === 1) {
@@ -40,26 +64,6 @@ const recordDiags = computed(() => {
}); });
}); });
const abortController = ref<AbortController>(new AbortController());
const { mutate: getRecordCheckByParentId, isPending: loading } = useMutation({
mutationFn: async () => {
abortController.value.abort();
abortController.value = new AbortController();
const checks = await getRecordCheckApi(ndmDevice.value, 90, [], { stationCode: station.value.code, signal: abortController.value.signal });
return checks;
},
onSuccess: (checks) => {
recordChecks.value = checks;
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
},
});
const { mutate: reloadAllRecordCheck, isPending: reloading } = useMutation({ const { mutate: reloadAllRecordCheck, isPending: reloading } = useMutation({
mutationFn: async () => { mutationFn: async () => {
abortController.value.abort(); abortController.value.abort();
@@ -78,9 +82,7 @@ const { mutate: reloadAllRecordCheck, isPending: reloading } = useMutation({
}); });
const onExportRecordCheck = () => { const onExportRecordCheck = () => {
const code = station.value.code; exportRecordDiagCsv(recordDiags.value, station.value.name);
const stationName = stations.value.find((station) => station.code === code)?.name ?? '';
exportRecordDiagCsv(recordDiags.value, stationName);
}; };
const page = ref(1); const page = ref(1);
@@ -121,7 +123,7 @@ const { mutate: reloadRecordCheckByGbId } = useMutation({
} }
}, },
onSuccess: () => { onSuccess: () => {
getRecordCheckByParentId(); refetchRecordChecks();
}, },
onError: (error) => { onError: (error) => {
if (isCancel(error)) return; if (isCancel(error)) return;
@@ -131,19 +133,6 @@ const { mutate: reloadRecordCheckByGbId } = useMutation({
}, },
}); });
onMounted(() => {
getRecordCheckByParentId();
});
watch(
() => ndmDevice.value.id,
(devieDbId) => {
if (devieDbId) {
getRecordCheckByParentId();
}
},
);
onBeforeUnmount(() => { onBeforeUnmount(() => {
abortController.value.abort(); abortController.value.abort();
}); });
@@ -168,9 +157,9 @@ onBeforeUnmount(() => {
<NFlex> <NFlex>
<NTooltip trigger="hover"> <NTooltip trigger="hover">
<template #trigger> <template #trigger>
<NButton size="small" quaternary circle :loading="loading" @click="() => getRecordCheckByParentId()"> <NButton size="small" quaternary circle :loading="loading" @click="() => refetchRecordChecks()">
<template #icon> <template #icon>
<NIcon :component="ReloadOutlined" /> <NIcon :component="RotateCwIcon" />
</template> </template>
</NButton> </NButton>
</template> </template>
@@ -182,7 +171,7 @@ onBeforeUnmount(() => {
<template #trigger> <template #trigger>
<NButton size="small" quaternary circle @click="onExportRecordCheck"> <NButton size="small" quaternary circle @click="onExportRecordCheck">
<template #icon> <template #icon>
<NIcon :component="DownloadOutlined" /> <NIcon :component="DownloadIcon" />
</template> </template>
</NButton> </NButton>
</template> </template>

View File

@@ -13,15 +13,17 @@ import {
type Station, type Station,
} from '@/apis'; } from '@/apis';
import { SecurityBoxCircuitLinkModal } from '@/components'; import { SecurityBoxCircuitLinkModal } from '@/components';
import { usePermission } from '@/composables';
import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants'; import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useDeviceStore, useSettingStore } from '@/stores'; import { useDeviceStore, useSettingStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
import { PoweroffOutlined } from '@vicons/antd';
import { watchImmediate } from '@vueuse/core'; import { watchImmediate } from '@vueuse/core';
import { isCancel } from 'axios'; import { isCancel } from 'axios';
import destr from 'destr'; import destr from 'destr';
import { cloneDeep, isFunction } from 'es-toolkit'; import { cloneDeep, isFunction } from 'es-toolkit';
import { PowerIcon } from 'lucide-vue-next';
import { NButton, NCard, NDescriptions, NDescriptionsItem, NDropdown, NFlex, NIcon, NPopconfirm, NPopover, NSwitch, NTag, useThemeVars, type DropdownOption, type TagProps } from 'naive-ui'; import { NButton, NCard, NDescriptions, NDescriptionsItem, NDropdown, NFlex, NIcon, NPopconfirm, NPopover, NSwitch, NTag, useThemeVars, type DropdownOption, type TagProps } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { computed, inject, ref, toRefs } from 'vue'; import { computed, inject, ref, toRefs } from 'vue';
@@ -38,7 +40,9 @@ const deviceStore = useDeviceStore();
const { lineDevices } = storeToRefs(deviceStore); const { lineDevices } = storeToRefs(deviceStore);
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore); const { useLocalDB } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station, circuits } = toRefs(props); const { ndmDevice, station, circuits } = toRefs(props);
@@ -223,6 +227,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
const onContextmenu = (payload: PointerEvent, circuitIndex: number) => { const onContextmenu = (payload: PointerEvent, circuitIndex: number) => {
payload.stopPropagation(); payload.stopPropagation();
payload.preventDefault(); payload.preventDefault();
if (!hasPermission(station.value.code, PERMISSION_TYPE_LITERALS.OPERATION)) return;
const { clientX, clientY } = payload; const { clientX, clientY } = payload;
contextmenu.value = { x: clientX, y: clientY, circuitIndex }; contextmenu.value = { x: clientX, y: clientY, circuitIndex };
showContextmenu.value = true; showContextmenu.value = true;
@@ -258,8 +263,8 @@ const { mutate: unlinkDevice } = useMutation({
delete modifiedUpperLinkDescription.downstream?.[circuitIndex]; delete modifiedUpperLinkDescription.downstream?.[circuitIndex];
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription); modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
// 3. 发起update请求并获取最新的设备详情离线模式下直接修改本地数据) // 3. 发起update请求并获取最新的设备详情使用本地数据库时直接修改本地数据)
if (offlineDev.value) { if (useLocalDB.value) {
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
} }
const stationCode = station.value.code; const stationCode = station.value.code;
@@ -313,7 +318,7 @@ const { mutate: unlinkDevice } = useMutation({
<NFlex align="center"> <NFlex align="center">
<NTag class="pointer-cursor" size="small" :type="getCircuitStatusTagType(circuit)"> <NTag class="pointer-cursor" size="small" :type="getCircuitStatusTagType(circuit)">
<template #icon> <template #icon>
<NIcon :component="PoweroffOutlined" /> <NIcon :component="PowerIcon" />
</template> </template>
<template #default> <template #default>
<span>{{ getCircuitStatusText(circuit) }}</span> <span>{{ getCircuitStatusText(circuit) }}</span>

View File

@@ -23,7 +23,7 @@ const show = defineModel<boolean>('show', { default: false });
const deviceStore = useDeviceStore(); const deviceStore = useDeviceStore();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore); const { useLocalDB } = storeToRefs(settingStore);
const { ndmDevice, station, circuitIndex } = toRefs(props); const { ndmDevice, station, circuitIndex } = toRefs(props);
@@ -68,7 +68,9 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({
const lowerDeviceDbId = lowerDevice.value?.id; const lowerDeviceDbId = lowerDevice.value?.id;
if (!lowerDeviceDbId) throw new Error('该设备没有ID'); if (!lowerDeviceDbId) throw new Error('该设备没有ID');
// 0. 检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备 // 0. 检查是否会导致循环关联,
if (upperDeviceDbId === lowerDeviceDbId) throw new Error('不能关联到自身');
// 以及检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备
const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => { const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => {
return deviceStoreIndex.deviceDbId === lowerDeviceDbId; return deviceStoreIndex.deviceDbId === lowerDeviceDbId;
}); });
@@ -148,8 +150,8 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({
} }
modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription); modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription);
// 3. 发起update请求并获取最新的设备详情离线模式下直接修改本地数据) // 3. 发起update请求并获取最新的设备详情使用本地数据库时直接修改本地数据)
if (offlineDev.value) { if (useLocalDB.value) {
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
} }
const stationCode = station.value.code; const stationCode = station.value.code;

View File

@@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ThunderboltOutlined } from '@vicons/antd'; import { DropletIcon, FanIcon, ShieldIcon, ThermometerIcon, ZapIcon } from 'lucide-vue-next';
import { ApertureOutline, LockOpenOutline, ThermometerOutline, WaterOutline } from '@vicons/ionicons5';
import { NCard, NFlex, NIcon, NTag } from 'naive-ui'; import { NCard, NFlex, NIcon, NTag } from 'naive-ui';
import { computed, toRefs } from 'vue'; import { computed, toRefs } from 'vue';
@@ -52,7 +51,7 @@ const formattedFanSpeeds = computed(() => {
<NFlex vertical> <NFlex vertical>
<NTag> <NTag>
<template #icon> <template #icon>
<NIcon :component="ThermometerOutline" /> <NIcon :component="ThermometerIcon" />
</template> </template>
<template #default> <template #default>
<span>温度: {{ temperature }}</span> <span>温度: {{ temperature }}</span>
@@ -60,7 +59,7 @@ const formattedFanSpeeds = computed(() => {
</NTag> </NTag>
<NTag> <NTag>
<template #icon> <template #icon>
<NIcon :component="WaterOutline" /> <NIcon :component="DropletIcon" />
</template> </template>
<template #default> <template #default>
<span>湿度: {{ humidity }}%</span> <span>湿度: {{ humidity }}%</span>
@@ -68,7 +67,7 @@ const formattedFanSpeeds = computed(() => {
</NTag> </NTag>
<NTag> <NTag>
<template #icon> <template #icon>
<NIcon :component="ApertureOutline" /> <NIcon :component="FanIcon" />
</template> </template>
<template #default> <template #default>
<span>风扇: {{ formattedFanSpeeds }}</span> <span>风扇: {{ formattedFanSpeeds }}</span>
@@ -76,7 +75,7 @@ const formattedFanSpeeds = computed(() => {
</NTag> </NTag>
<NTag :type="getStatusTagType(accessControlStatus)"> <NTag :type="getStatusTagType(accessControlStatus)">
<template #icon> <template #icon>
<NIcon :component="LockOpenOutline" /> <NIcon :component="ShieldIcon" />
</template> </template>
<template #default> <template #default>
<span>门禁: {{ accessControlStatus }}</span> <span>门禁: {{ accessControlStatus }}</span>
@@ -84,7 +83,7 @@ const formattedFanSpeeds = computed(() => {
</NTag> </NTag>
<NTag :type="getStatusTagType(lightningProtectionStatus)"> <NTag :type="getStatusTagType(lightningProtectionStatus)">
<template #icon> <template #icon>
<NIcon :component="ThunderboltOutlined" /> <NIcon :component="ZapIcon" />
</template> </template>
<template #default> <template #default>
<span>防雷: {{ lightningProtectionStatus }}</span> <span>防雷: {{ lightningProtectionStatus }}</span>

View File

@@ -1,7 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { detailDeviceApi, updateDeviceApi, type LinkDescription, type NdmDeviceResultVO, type NdmSwitchLinkDescription, type NdmSwitchPortInfo, type NdmSwitchResultVO, type Station } from '@/apis'; import { detailDeviceApi, updateDeviceApi, type LinkDescription, type NdmDeviceResultVO, type NdmSwitchLinkDescription, type NdmSwitchPortInfo, type NdmSwitchResultVO, type Station } from '@/apis';
import { SwitchPortLinkModal } from '@/components'; import { SwitchPortLinkModal } from '@/components';
import { usePermission } from '@/composables';
import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants'; import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { getPortStatusValue, transformPortSpeed } from '@/helpers'; import { getPortStatusValue, transformPortSpeed } from '@/helpers';
import { useDeviceStore, useSettingStore } from '@/stores'; import { useDeviceStore, useSettingStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
@@ -25,7 +27,9 @@ const deviceStore = useDeviceStore();
const { lineDevices } = storeToRefs(deviceStore); const { lineDevices } = storeToRefs(deviceStore);
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore); const { useLocalDB } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station, ports } = toRefs(props); const { ndmDevice, station, ports } = toRefs(props);
@@ -172,6 +176,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
const onContextmenu = (payload: PointerEvent, port: NdmSwitchPortInfo) => { const onContextmenu = (payload: PointerEvent, port: NdmSwitchPortInfo) => {
payload.stopPropagation(); payload.stopPropagation();
payload.preventDefault(); payload.preventDefault();
if (!hasPermission(station.value.code, PERMISSION_TYPE_LITERALS.OPERATION)) return;
const { clientX, clientY } = payload; const { clientX, clientY } = payload;
contextmenu.value = { x: clientX, y: clientY, port }; contextmenu.value = { x: clientX, y: clientY, port };
showContextmenu.value = true; showContextmenu.value = true;
@@ -208,8 +213,8 @@ const { mutate: unlinkDevice } = useMutation({
delete modifiedUpperLinkDescription.downstream?.[port.portName]; delete modifiedUpperLinkDescription.downstream?.[port.portName];
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription); modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
// 3. 发起update请求并获取最新的设备详情离线模式下直接修改本地数据) // 3. 发起update请求并获取最新的设备详情使用本地数据库时直接修改本地数据)
if (offlineDev.value) { if (useLocalDB.value) {
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
} }
const stationCode = station.value.code; const stationCode = station.value.code;

View File

@@ -32,7 +32,7 @@ const show = defineModel<boolean>('show', { default: false });
const deviceStore = useDeviceStore(); const deviceStore = useDeviceStore();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore); const { useLocalDB } = storeToRefs(settingStore);
const { ndmDevice, station, port } = toRefs(props); const { ndmDevice, station, port } = toRefs(props);
@@ -78,7 +78,9 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({
const lowerDeviceDbId = lowerDevice.value?.id; const lowerDeviceDbId = lowerDevice.value?.id;
if (!lowerDeviceDbId) throw new Error('该设备没有ID'); if (!lowerDeviceDbId) throw new Error('该设备没有ID');
// 0. 检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备 // 0. 检查是否会导致循环关联,
if (upperDeviceDbId === lowerDeviceDbId) throw new Error('不能关联到自身');
// 以及检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备
const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => { const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => {
return deviceStoreIndex.deviceDbId === lowerDeviceDbId; return deviceStoreIndex.deviceDbId === lowerDeviceDbId;
}); });
@@ -158,8 +160,8 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({
} }
modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription); modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription);
// 3. 发起update请求并获取最新的设备详情离线模式下直接修改本地数据) // 3. 发起update请求并获取最新的设备详情使用本地数据库时直接修改本地数据)
if (offlineDev.value) { if (useLocalDB.value) {
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
} }
const stationCode = station.value.code; const stationCode = station.value.code;

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmAlarmHostResultVO, Station } from '@/apis'; import type { NdmAlarmHostResultVO, Station } from '@/apis';
import { AlarmHostCurrentDiag, AlarmHostHistoryDiag, AlarmHostUpdate, DeviceRawCard } from '@/components'; import { AlarmHostCurrentDiag, AlarmHostHistoryDiag, AlarmHostUpdate, DeviceRawCard } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmCameraResultVO, Station } from '@/apis'; import type { NdmCameraResultVO, Station } from '@/apis';
import { CameraCurrentDiag, CameraHistoryDiag, CameraUpdate, DeviceRawCard } from '@/components'; import { CameraCurrentDiag, CameraHistoryDiag, CameraUpdate, DeviceRawCard } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -31,7 +31,7 @@ const props = defineProps<{
}>(); }>();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore); const { activeRequests } = storeToRefs(settingStore);
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@@ -49,7 +49,7 @@ const QUERY_KEY = 'camera-installation-area-query';
const { data: installationArea } = useQuery({ const { data: installationArea } = useQuery({
queryKey: computed(() => [QUERY_KEY, ndmDevice.value.gbCode, station.value.code]), queryKey: computed(() => [QUERY_KEY, ndmDevice.value.gbCode, station.value.code]),
enabled: computed(() => !offlineDev.value), enabled: computed(() => activeRequests.value),
gcTime: 0, gcTime: 0,
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
const UNKNOWN_NAME = '-'; const UNKNOWN_NAME = '-';
@@ -107,8 +107,8 @@ const { data: installationArea } = useQuery({
return `${tier1Area.name}-${tier2Area.name}`; return `${tier1Area.name}-${tier2Area.name}`;
}, },
}); });
watch(offlineDev, (offline) => { watch(activeRequests, (active) => {
if (offline) { if (!active) {
queryClient.cancelQueries({ queryKey: [QUERY_KEY] }); queryClient.cancelQueries({ queryKey: [QUERY_KEY] });
} }
}); });

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmDecoderResultVO, Station } from '@/apis'; import type { NdmDecoderResultVO, Station } from '@/apis';
import { DecoderCurrentDiag, DecoderHistoryDiag, DecoderUpdate, DeviceRawCard } from '@/components'; import { DecoderCurrentDiag, DecoderHistoryDiag, DecoderUpdate, DeviceRawCard } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmKeyboardResultVO, Station } from '@/apis'; import type { NdmKeyboardResultVO, Station } from '@/apis';
import { DeviceRawCard, KeyboardCurrentDiag, KeyboardHistoryDiag, KeyboardUpdate } from '@/components'; import { DeviceRawCard, KeyboardCurrentDiag, KeyboardHistoryDiag, KeyboardUpdate } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmNvrResultVO, Station } from '@/apis'; import type { NdmNvrResultVO, Station } from '@/apis';
import { DeviceRawCard, NvrCurrentDiag, NvrHistoryDiag, NvrUpdate } from '@/components'; import { DeviceRawCard, NvrCurrentDiag, NvrHistoryDiag, NvrUpdate } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmSecurityBoxResultVO, Station } from '@/apis'; import type { NdmSecurityBoxResultVO, Station } from '@/apis';
import { DeviceRawCard, SecurityBoxCurrentDiag, SecurityBoxHistoryDiag, SecurityBoxUpdate } from '@/components'; import { DeviceRawCard, SecurityBoxCurrentDiag, SecurityBoxHistoryDiag, SecurityBoxUpdate } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -2,6 +2,7 @@ import ServerAlive from './server-alive.vue';
import ServerCard from './server-card.vue'; import ServerCard from './server-card.vue';
import ServerCurrentDiag from './server-current-diag.vue'; import ServerCurrentDiag from './server-current-diag.vue';
import ServerHistoryDiag from './server-history-diag.vue'; import ServerHistoryDiag from './server-history-diag.vue';
import ServerStreamPush from './server-stream-push.vue';
import ServerUpdate from './server-update.vue'; import ServerUpdate from './server-update.vue';
export { ServerAlive, ServerCard, ServerCurrentDiag, ServerHistoryDiag, ServerUpdate }; export { ServerAlive, ServerCard, ServerCurrentDiag, ServerHistoryDiag, ServerUpdate, ServerStreamPush };

View File

@@ -13,7 +13,7 @@ const props = defineProps<{
}>(); }>();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore); const { activeRequests } = storeToRefs(settingStore);
const queryClient = useQueryClient(); const queryClient = useQueryClient();
@@ -25,7 +25,7 @@ const MEDIA_SERVER_ALIVE_QUERY_KEY = 'media-server-alive-query';
const VIDEO_SERVER_ALIVE_QUERY_KEY = 'video-server-alive-query'; const VIDEO_SERVER_ALIVE_QUERY_KEY = 'video-server-alive-query';
const { data: isMediaServerAlive } = useQuery({ const { data: isMediaServerAlive } = useQuery({
queryKey: computed(() => [MEDIA_SERVER_ALIVE_QUERY_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]), queryKey: computed(() => [MEDIA_SERVER_ALIVE_QUERY_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
enabled: computed(() => !offlineDev.value && deviceType.value === DEVICE_TYPE_LITERALS.ndmMediaServer), enabled: computed(() => activeRequests.value && deviceType.value === DEVICE_TYPE_LITERALS.ndmMediaServer),
refetchInterval: 30 * 1000, refetchInterval: 30 * 1000,
gcTime: 0, gcTime: 0,
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
@@ -35,15 +35,15 @@ const { data: isMediaServerAlive } = useQuery({
}); });
const { data: isSipServerAlive } = useQuery({ const { data: isSipServerAlive } = useQuery({
queryKey: computed(() => [VIDEO_SERVER_ALIVE_QUERY_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]), queryKey: computed(() => [VIDEO_SERVER_ALIVE_QUERY_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
enabled: computed(() => !offlineDev.value && deviceType.value === DEVICE_TYPE_LITERALS.ndmVideoServer), enabled: computed(() => activeRequests.value && deviceType.value === DEVICE_TYPE_LITERALS.ndmVideoServer),
refetchInterval: 30 * 1000, refetchInterval: 30 * 1000,
gcTime: 0, gcTime: 0,
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
return await isSipServerAliveApi({ stationCode: station.value.code, signal }); return await isSipServerAliveApi({ stationCode: station.value.code, signal });
}, },
}); });
watch(offlineDev, (offline) => { watch(activeRequests, (active) => {
if (offline) { if (!active) {
queryClient.cancelQueries({ queryKey: [MEDIA_SERVER_ALIVE_QUERY_KEY] }); queryClient.cancelQueries({ queryKey: [MEDIA_SERVER_ALIVE_QUERY_KEY] });
queryClient.cancelQueries({ queryKey: [VIDEO_SERVER_ALIVE_QUERY_KEY] }); queryClient.cancelQueries({ queryKey: [VIDEO_SERVER_ALIVE_QUERY_KEY] });
} }
@@ -56,20 +56,29 @@ watch(offlineDev, (offline) => {
<span>服务状态</span> <span>服务状态</span>
</template> </template>
<template #default> <template #default>
<div v-if="deviceType === DEVICE_TYPE_LITERALS.ndmMediaServer"> <template v-if="!activeRequests">
<span>-</span>
</template>
<template v-else>
<template v-if="deviceType === DEVICE_TYPE_LITERALS.ndmMediaServer">
<span>流媒体服务状态</span> <span>流媒体服务状态</span>
<template v-if="!!isMediaServerAlive"> <template v-if="!!isMediaServerAlive">
<NTag size="small" :type="isMediaServerAlive.online ? 'success' : 'error'">{{ isMediaServerAlive.online ? '在线' : '离线' }}</NTag> <NTag size="small" :type="isMediaServerAlive.online ? 'success' : 'error'">{{ isMediaServerAlive.online ? '在线' : '离线' }}</NTag>
</template> </template>
<span v-else>-</span> <template v-else>
</div> <span>-</span>
<div v-if="deviceType === DEVICE_TYPE_LITERALS.ndmVideoServer"> </template>
</template>
<template v-if="deviceType === DEVICE_TYPE_LITERALS.ndmVideoServer">
<span>信令服务状态</span> <span>信令服务状态</span>
<template v-if="isSipServerAlive !== undefined"> <template v-if="isSipServerAlive !== undefined">
<NTag size="small" :type="isSipServerAlive ? 'success' : 'error'">{{ isSipServerAlive ? '在线' : '离线' }}</NTag> <NTag size="small" :type="isSipServerAlive ? 'success' : 'error'">{{ isSipServerAlive ? '在线' : '离线' }}</NTag>
</template> </template>
<span v-else>-</span> <template v-else>
</div> <span>-</span>
</template>
</template>
</template>
</template> </template>
</NCard> </NCard>
</template> </template>

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmServerResultVO, Station } from '@/apis'; import type { NdmServerResultVO, Station } from '@/apis';
import { DeviceRawCard, ServerCurrentDiag, ServerHistoryDiag, ServerUpdate } from '@/components'; import { DeviceRawCard, ServerCurrentDiag, ServerHistoryDiag, ServerUpdate } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type NdmServerDiagInfo, type NdmServerResultVO, type Station } from '@/apis'; import { type NdmServerDiagInfo, type NdmServerResultVO, type Station } from '@/apis';
import { DeviceHardwareCard, DeviceHeaderCard, ServerAlive } from '@/components'; import { DeviceHardwareCard, DeviceHeaderCard, ServerAlive, ServerStreamPush } from '@/components';
import destr from 'destr'; import destr from 'destr';
import { NFlex } from 'naive-ui'; import { NFlex } from 'naive-ui';
import { computed, toRefs } from 'vue'; import { computed, toRefs } from 'vue';
@@ -30,6 +30,7 @@ const runningTime = computed(() => lastDiagInfo.value?.commInfo?.系统运行时
<DeviceHeaderCard :ndm-device="ndmDevice" :station="station" /> <DeviceHeaderCard :ndm-device="ndmDevice" :station="station" />
<DeviceHardwareCard running-time-label="服务器运行时间" :cpu-usage="cpuUsage" :mem-usage="memUsage" :disk-usage="diskUsage" :running-time="runningTime" /> <DeviceHardwareCard running-time-label="服务器运行时间" :cpu-usage="cpuUsage" :mem-usage="memUsage" :disk-usage="diskUsage" :running-time="runningTime" />
<ServerAlive :ndm-device="ndmDevice" :station="station" /> <ServerAlive :ndm-device="ndmDevice" :station="station" />
<ServerStreamPush :ndm-device="ndmDevice" :station="station" />
</NFlex> </NFlex>
</template> </template>

View File

@@ -0,0 +1,100 @@
<script setup lang="ts">
import { getAllPushApi, type NdmServerResultVO, type Station } from '@/apis';
import { DEVICE_TYPE_LITERALS, tryGetDeviceType } from '@/enums';
import { useSettingStore } from '@/stores';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import { NCard, NCollapse, NCollapseItem, NFlex, NTag, NText } from 'naive-ui';
import { storeToRefs } from 'pinia';
import { computed, toRefs, watch } from 'vue';
const props = defineProps<{
ndmDevice: NdmServerResultVO;
station: Station;
}>();
const settingStore = useSettingStore();
const { activeRequests } = storeToRefs(settingStore);
const queryClient = useQueryClient();
const { ndmDevice, station } = toRefs(props);
const deviceType = computed(() => tryGetDeviceType(ndmDevice.value.deviceType));
const showCard = computed(() => deviceType.value === DEVICE_TYPE_LITERALS.ndmMediaServer);
const SERVER_STREAM_PUSH_KEY = 'server-stream-push-query';
const { data: streamPushes } = useQuery({
queryKey: computed(() => [SERVER_STREAM_PUSH_KEY, ndmDevice.value.id, ndmDevice.value.lastDiagTime]),
enabled: computed(() => activeRequests.value && showCard.value),
refetchInterval: 30 * 1000,
gcTime: 0,
queryFn: async ({ signal }) => {
const streamPushes = await getAllPushApi({ stationCode: station.value.code, signal });
return streamPushes;
},
});
watch(activeRequests, (active) => {
if (!active) {
queryClient.cancelQueries({ queryKey: [SERVER_STREAM_PUSH_KEY] });
}
});
interface StreamPushStat {
ip: string;
port: number | null;
ssrc: string | null;
channelIds: string[];
}
const streamPushStat = computed(() => {
const stat: StreamPushStat[] = [];
streamPushes.value?.forEach((push) => {
if (!push.ip || !push.channelId) return;
const existIndex = stat.findIndex((item) => item.ip === push.ip);
if (existIndex === -1) {
stat.push({ ip: push.ip, port: push.port, ssrc: push.ssrc, channelIds: [push.channelId] });
} else {
const statItem = stat[existIndex];
if (!statItem) return;
statItem.channelIds.push(push.channelId);
}
});
return stat;
});
</script>
<template>
<NCard v-if="showCard" hoverable size="small">
<template #header>
<span>推流统计</span>
</template>
<template #default>
<template v-if="!activeRequests">
<span>-</span>
</template>
<template v-else>
<NFlex vertical>
<NText depth="3"> {{ streamPushStat.length }} 个推流目标</NText>
<NCollapse v-if="streamPushStat.length > 0">
<NCollapseItem v-for="{ ip, port, ssrc, channelIds } in streamPushStat" :key="`${ip}:${port}:${ssrc}`" :name="`${ip}:${port}:${ssrc}`">
<template #header>
<span>{{ ip }}</span>
</template>
<template #header-extra>
<span>{{ channelIds.length }} </span>
</template>
<template #default>
<NFlex>
<NTag v-for="channelId in channelIds" :key="channelId" size="small" type="info" :bordered="false">{{ channelId }}</NTag>
</NFlex>
</template>
</NCollapseItem>
</NCollapse>
</NFlex>
</template>
</template>
</NCard>
</template>
<style scoped lang="scss"></style>

View File

@@ -1,6 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NdmSwitchResultVO, Station } from '@/apis'; import type { NdmSwitchResultVO, Station } from '@/apis';
import { DeviceRawCard, SwitchCurrentDiag, SwitchHistoryDiag, SwitchUpdate } from '@/components'; import { DeviceRawCard, SwitchCurrentDiag, SwitchHistoryDiag, SwitchUpdate } from '@/components';
import { usePermission } from '@/composables';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore } from '@/stores'; import { useSettingStore } from '@/stores';
import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui'; import { NCard, NPageHeader, NScrollbar, NTab, NTabs } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
@@ -16,7 +18,9 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { debugModeEnabled } = storeToRefs(settingStore); const { showDeviceRawData } = storeToRefs(settingStore);
const { hasPermission } = usePermission();
const { ndmDevice, station } = toRefs(props); const { ndmDevice, station } = toRefs(props);
@@ -31,8 +35,8 @@ const activeTabName = ref('当前诊断');
const onTabChange = (name: string) => { const onTabChange = (name: string) => {
activeTabName.value = name; activeTabName.value = name;
}; };
watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { watch([ndmDevice, showDeviceRawData], ([newDevice, showRaw], [oldDevice]) => {
if (newDevice.id !== oldDevice.id || !enabled) { if (newDevice.id !== oldDevice.id || (!showRaw && activeTabName.value === '原始数据')) {
activeTabName.value = '当前诊断'; activeTabName.value = '当前诊断';
} }
}); });
@@ -45,8 +49,8 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => {
<NTabs :value="activeTabName" @update:value="onTabChange"> <NTabs :value="activeTabName" @update:value="onTabChange">
<NTab name="当前诊断">当前诊断</NTab> <NTab name="当前诊断">当前诊断</NTab>
<NTab name="历史诊断">历史诊断</NTab> <NTab name="历史诊断">历史诊断</NTab>
<NTab name="修改设备">修改设备</NTab> <NTab v-if="hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)" name="修改设备">修改设备</NTab>
<NTab v-if="debugModeEnabled" name="原始数据">原始数据</NTab> <NTab v-if="showDeviceRawData" name="原始数据">原始数据</NTab>
</NTabs> </NTabs>
</template> </template>
<template #default> <template #default>

View File

@@ -1,10 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { initStationDevices, type NdmDeviceResultVO, type NdmNvrResultVO, type Station } from '@/apis'; import { initStationDevices, type NdmDeviceResultVO, type NdmNvrResultVO, type Station } from '@/apis';
import { useDeviceTree, type UseDeviceTreeReturn } from '@/composables'; import { useDeviceTree, usePermission, type UseDeviceTreeReturn } from '@/composables';
import { DEVICE_TYPE_NAMES, DEVICE_TYPE_LITERALS, tryGetDeviceType, type DeviceType } from '@/enums'; import { DEVICE_TYPE_NAMES, DEVICE_TYPE_LITERALS, tryGetDeviceType, type DeviceType, PERMISSION_TYPE_LITERALS } from '@/enums';
import { isNvrCluster } from '@/helpers'; import { isNvrCluster } from '@/helpers';
import { useDeviceStore, useStationStore } from '@/stores'; import { useDeviceStore, usePermissionStore } from '@/stores';
import { watchImmediate } from '@vueuse/core'; import { watchDebounced, watchImmediate } from '@vueuse/core';
import destr from 'destr'; import destr from 'destr';
import { isFunction } from 'es-toolkit'; import { isFunction } from 'es-toolkit';
import { import {
@@ -27,7 +27,7 @@ import {
type TreeProps, type TreeProps,
} from 'naive-ui'; } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { computed, h, nextTick, onBeforeUnmount, ref, toRefs, useTemplateRef, watch, type CSSProperties } from 'vue'; import { computed, h, nextTick, onBeforeUnmount, onMounted, ref, toRefs, useTemplateRef, watch, type CSSProperties } from 'vue';
const props = defineProps<{ const props = defineProps<{
/** /**
@@ -60,20 +60,22 @@ const { station, events, syncRoute, devicePrefixLabel } = toRefs(props);
const themeVars = useThemeVars(); const themeVars = useThemeVars();
const { hasPermission } = usePermission();
const { const {
// 设备选择 // 设备选择
selectedStationCode, selectedStationCode,
selectedDeviceType, selectedDeviceType,
selectedDevice, selectedDevice,
syncFromRoute,
syncToRoute,
selectDevice, selectDevice,
// 设备管理 // 设备管理
exportDevice, exportDevice,
exportDeviceTemplate, exportDeviceTemplate,
importDevice, importDevice,
deleteDevice, deleteDevice,
} = useDeviceTree({ } = useDeviceTree();
syncRoute: computed(() => !!syncRoute.value),
});
// 将 `selectDevice` 函数暴露给父组件 // 将 `selectDevice` 函数暴露给父组件
emit('exposeSelectDeviceFn', selectDevice); emit('exposeSelectDeviceFn', selectDevice);
@@ -87,8 +89,9 @@ const onSelectDevice = (device: NdmDeviceResultVO, stationCode: Station['code'])
emit('afterSelectDevice', device, stationCode); emit('afterSelectDevice', device, stationCode);
}; };
const stationStore = useStationStore(); const permissionStore = usePermissionStore();
const { stations } = storeToRefs(stationStore); const stations = computed(() => permissionStore.stations.VIEW ?? []);
const deviceStore = useDeviceStore(); const deviceStore = useDeviceStore();
const { lineDevices } = storeToRefs(deviceStore); const { lineDevices } = storeToRefs(deviceStore);
@@ -220,13 +223,17 @@ const nodeProps: TreeProps['nodeProps'] = ({ option }) => {
payload.stopPropagation(); payload.stopPropagation();
payload.preventDefault(); payload.preventDefault();
// 仅当事件列表包含 `manage` 时才显示右键菜单 // 如果事件列表包含 `manage`,则直接结束逻辑
if (!events.value?.includes('manage')) return; if (!events.value?.includes('manage')) return;
const { clientX, clientY } = payload;
const stationCode = option['stationCode'] as Station['code']; const stationCode = option['stationCode'] as Station['code'];
// 仅当用户在该车站拥有操作权限时才显示右键菜单
if (!hasPermission(stationCode, PERMISSION_TYPE_LITERALS.OPERATION)) return;
const deviceType = option['deviceType'] as DeviceType | undefined; const deviceType = option['deviceType'] as DeviceType | undefined;
const device = option['device'] as NdmDeviceResultVO | undefined; const device = option['device'] as NdmDeviceResultVO | undefined;
const { clientX, clientY } = payload;
contextmenu.value = { x: clientX, y: clientY, stationCode, deviceType, device }; contextmenu.value = { x: clientX, y: clientY, stationCode, deviceType, device };
showContextmenu.value = true; showContextmenu.value = true;
}, },
@@ -252,7 +259,7 @@ const renderIcmpStatistics = (onlineCount: number, offlineCount: number, count:
]); ]);
}; };
const renderDeviceNodePrefix = (device: NdmDeviceResultVO, stationCode: Station['code']) => { const renderDeviceNodePrefix = (device: NdmDeviceResultVO, stationCode: Station['code']) => {
const renderViewDeviceButton = (device: NdmDeviceResultVO, stationCode: string) => { const renderViewDeviceButton = (device: NdmDeviceResultVO, stationCode: Station['code']) => {
if (!devicePrefixLabel.value) return null; if (!devicePrefixLabel.value) return null;
return h( return h(
NButton, NButton,
@@ -477,11 +484,38 @@ const onLocateDeviceTree = async () => {
animated.value = true; animated.value = true;
}; };
// 渲染全线设备树时,当选择的设备发生变化,则定位设备树
// 当选择的设备发生变化时,定位设备树,并同步选中状态到路由参数
// 暂时不考虑多次执行的问题,因为当选择的设备在设备树视口内时,不会发生滚动 // 暂时不考虑多次执行的问题,因为当选择的设备在设备树视口内时,不会发生滚动
watch(selectedDevice, async () => { watch(selectedDevice, async (newDevice, oldDevice) => {
if (!!station.value) return; if (!!station.value) return;
await onLocateDeviceTree(); if (newDevice?.id === oldDevice?.id) return;
// console.log('selectedDevice changed');
onLocateDeviceTree();
syncToRoute();
});
// 当全线设备发生变化时,从路由参数同步选中状态
// 但lineDevices是shallowRef因此需要深度侦听才能获取内部变化
// 而单纯的深度侦听又可能会引发性能问题,因此尝试使用防抖侦听
watchDebounced(
lineDevices,
(newLineDevices) => {
if (syncRoute.value) {
// console.log('lineDevices changed');
syncFromRoute(newLineDevices);
}
},
{
debounce: 500,
deep: true,
},
);
onMounted(() => {
if (syncRoute.value) {
syncFromRoute(lineDevices.value);
}
}); });
</script> </script>

View File

@@ -1,27 +1,33 @@
<script setup lang="ts"> <script setup lang="ts">
import type { LineAlarms, LineDevices, Station, VersionInfo } from '@/apis'; import { retentionDaysApi, snapStatusApi, type LineAlarms, type LineDevices, type Station, type VersionInfo } from '@/apis';
import { ThemeSwitch } from '@/components'; import { ThemeSwitch } from '@/components';
import { usePermission } from '@/composables';
import { NDM_ALARM_STORE_ID, NDM_DEVICE_STORE_ID, NDM_STATION_STORE_ID } from '@/constants'; import { NDM_ALARM_STORE_ID, NDM_DEVICE_STORE_ID, NDM_STATION_STORE_ID } from '@/constants';
import { usePollingStore, useSettingStore } from '@/stores'; import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { useSettingStore, useStationStore } from '@/stores';
import { downloadByData, getAppEnvConfig, parseErrorFeedback, sleep } from '@/utils'; import { downloadByData, getAppEnvConfig, parseErrorFeedback, sleep } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
import { DeleteOutlined, ExportOutlined, ImportOutlined } from '@vicons/antd';
import { useEventListener } from '@vueuse/core'; import { useEventListener } from '@vueuse/core';
import axios from 'axios'; import axios, { isCancel } from 'axios';
import destr from 'destr'; import destr from 'destr';
import { isFunction } from 'es-toolkit'; import { isFunction } from 'es-toolkit';
import localforage from 'localforage'; import localforage from 'localforage';
import { NButton, NDivider, NDrawer, NDrawerContent, NDropdown, NFlex, NFormItem, NIcon, NInput, NInputNumber, NModal, NSwitch, NText, type DropdownOption } from 'naive-ui'; import { DownloadIcon, Trash2Icon, UploadIcon } from 'lucide-vue-next';
import { NButton, NButtonGroup, NDivider, NDrawer, NDrawerContent, NDropdown, NFlex, NFormItem, NIcon, NInput, NInputNumber, NModal, NSwitch, NText, type DropdownOption } from 'naive-ui';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { onMounted, ref } from 'vue'; import { computed, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
const route = useRoute();
const show = defineModel<boolean>('show', { default: false }); const show = defineModel<boolean>('show', { default: false });
const stationStore = useStationStore();
const { stations } = storeToRefs(stationStore);
const occStation = computed(() => stations.value.find((station) => !!station.occ));
const settingsStore = useSettingStore(); const settingsStore = useSettingStore();
const { menuCollpased, stationGridCols, debugModeEnabled, offlineDev } = storeToRefs(settingsStore); const { menuCollpased, stationGridCols, debugMode, showDeviceRawData, pollingStations, activeRequests, subscribeMessages, mockUser, useLocalDB } = storeToRefs(settingsStore);
const { hasPermission } = usePermission();
const versionInfo = ref<VersionInfo>({ version: '', buildTime: '' }); const versionInfo = ref<VersionInfo>({ version: '', buildTime: '' });
@@ -40,6 +46,83 @@ const { mutate: getVersionInfo } = useMutation({
}, },
}); });
const abortControllers = ref({
retentionDays: new AbortController(),
snapStatus: new AbortController(),
});
const retentionDays = ref(0);
const { mutate: getRetentionDays, isPending: retentionDaysLoading } = useMutation({
mutationFn: async () => {
abortControllers.value.retentionDays.abort();
abortControllers.value.retentionDays = new AbortController();
const signal = abortControllers.value.retentionDays.signal;
const days = await retentionDaysApi('get', { signal });
return days;
},
onSuccess: (days) => {
retentionDays.value = days;
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
},
});
const { mutate: saveRetentionDays, isPending: retentionDaysSaving } = useMutation({
mutationFn: async () => {
abortControllers.value.retentionDays.abort();
abortControllers.value.retentionDays = new AbortController();
const signal = abortControllers.value.retentionDays.signal;
await retentionDaysApi('post', { days: retentionDays.value, signal });
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
// 修改失败,刷新 retentionDays
getRetentionDays();
},
});
const snapStatus = ref(false);
const { mutate: getSnapStatus, isPending: snapStatusLoading } = useMutation({
mutationFn: async () => {
abortControllers.value.snapStatus.abort();
abortControllers.value.snapStatus = new AbortController();
const signal = abortControllers.value.snapStatus.signal;
const status = await snapStatusApi('get', { signal });
return status;
},
onSuccess: (status) => {
snapStatus.value = status;
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
},
});
const { mutate: saveSnapStatus, isPending: snapStatusSaving } = useMutation({
mutationFn: async () => {
abortControllers.value.snapStatus.abort();
abortControllers.value.snapStatus = new AbortController();
const signal = abortControllers.value.snapStatus.signal;
await snapStatusApi('post', { doSnap: snapStatus.value, signal });
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
// 修改失败,刷新 snapStatus
getSnapStatus();
},
});
const showDebugCodeModal = ref(false); const showDebugCodeModal = ref(false);
const debugCode = ref(''); const debugCode = ref('');
const enableDebugMode = () => { const enableDebugMode = () => {
@@ -49,11 +132,11 @@ const enableDebugMode = () => {
return; return;
} }
showDebugCodeModal.value = false; showDebugCodeModal.value = false;
settingsStore.enableDebugMode(); debugMode.value = true;
}; };
const disableDebugMode = () => { const disableDebugMode = () => {
showDebugCodeModal.value = false; showDebugCodeModal.value = false;
settingsStore.disableDebugMode(); debugMode.value = false;
}; };
useEventListener('keydown', (event) => { useEventListener('keydown', (event) => {
const { ctrlKey, altKey, code } = event; const { ctrlKey, altKey, code } = event;
@@ -64,28 +147,18 @@ useEventListener('keydown', (event) => {
const expectToShowDebugCodeInput = ref(false); const expectToShowDebugCodeInput = ref(false);
const onModalAfterEnter = () => { const onModalAfterEnter = () => {
expectToShowDebugCodeInput.value = !debugModeEnabled.value; expectToShowDebugCodeInput.value = !debugMode.value;
}; };
const onModalAfterLeave = () => { const onModalAfterLeave = () => {
expectToShowDebugCodeInput.value = false; expectToShowDebugCodeInput.value = false;
debugCode.value = ''; debugCode.value = '';
}; };
const pollingStore = usePollingStore();
const { pollingEnabled } = storeToRefs(pollingStore);
const onPollingEnabledUpdate = (enabled: boolean) => {
if (enabled) {
pollingStore.startPolling();
} else {
pollingStore.stopPolling();
}
};
type IndexedDbStoreId = typeof NDM_STATION_STORE_ID | typeof NDM_DEVICE_STORE_ID | typeof NDM_ALARM_STORE_ID; type IndexedDbStoreId = typeof NDM_STATION_STORE_ID | typeof NDM_DEVICE_STORE_ID | typeof NDM_ALARM_STORE_ID;
type IndexedDbStoreStates = { type IndexedDbStoreStates = {
[NDM_STATION_STORE_ID]: { stations: Station[] }; [NDM_STATION_STORE_ID]: { stations: Station[] };
[NDM_DEVICE_STORE_ID]: { lineDevices: LineDevices }; [NDM_DEVICE_STORE_ID]: { lineDevices: LineDevices };
[NDM_ALARM_STORE_ID]: { lineAlarms: LineAlarms; unreadLineAlarms: LineAlarms }; [NDM_ALARM_STORE_ID]: { lineAlarms: LineAlarms };
}; };
const exportFromIndexedDB = async <K extends IndexedDbStoreId>(storeId: K, options?: { errorMsg?: string }) => { const exportFromIndexedDB = async <K extends IndexedDbStoreId>(storeId: K, options?: { errorMsg?: string }) => {
const { errorMsg } = options ?? {}; const { errorMsg } = options ?? {};
@@ -98,8 +171,9 @@ const exportFromIndexedDB = async <K extends IndexedDbStoreId>(storeId: K, optio
}; };
const importToIndexedDB = async <K extends IndexedDbStoreId>(storeId: K, options?: { successMsg?: string; errorMsg?: string }) => { const importToIndexedDB = async <K extends IndexedDbStoreId>(storeId: K, options?: { successMsg?: string; errorMsg?: string }) => {
const { successMsg, errorMsg } = options ?? {}; const { successMsg, errorMsg } = options ?? {};
pollingStore.stopPolling(); pollingStations.value = false;
offlineDev.value = true; activeRequests.value = false;
subscribeMessages.value = false;
const fileInput = document.createElement('input'); const fileInput = document.createElement('input');
fileInput.type = 'file'; fileInput.type = 'file';
fileInput.accept = '.json'; fileInput.accept = '.json';
@@ -122,8 +196,9 @@ const importToIndexedDB = async <K extends IndexedDbStoreId>(storeId: K, options
}; };
}; };
const deleteFromIndexedDB = async (storeId: IndexedDbStoreId) => { const deleteFromIndexedDB = async (storeId: IndexedDbStoreId) => {
pollingStore.stopPolling(); pollingStations.value = false;
offlineDev.value = true; activeRequests.value = false;
subscribeMessages.value = false;
await localforage.removeItem(storeId).catch((error) => { await localforage.removeItem(storeId).catch((error) => {
window.$message.error(`${error}`); window.$message.error(`${error}`);
return; return;
@@ -192,13 +267,27 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
} }
}; };
onMounted(() => { watch([activeRequests, show], ([active, entered]) => {
getVersionInfo(); if (!active) return;
if (entered) {
getRetentionDays();
getSnapStatus();
} else {
abortControllers.value.retentionDays.abort();
abortControllers.value.snapStatus.abort();
}
}); });
const onDrawerAfterEnter = () => {
getVersionInfo();
};
const onDrawerAfterLeave = () => {
abortControllers.value.retentionDays.abort();
abortControllers.value.snapStatus.abort();
};
</script> </script>
<template> <template>
<NDrawer v-model:show="show" :width="560" :auto-focus="false"> <NDrawer v-model:show="show" :width="560" :auto-focus="false" @after-enter="onDrawerAfterEnter" @after-leave="onDrawerAfterLeave">
<NDrawerContent closable title="系统设置" :native-scrollbar="false"> <NDrawerContent closable title="系统设置" :native-scrollbar="false">
<NFlex vertical> <NFlex vertical>
<NDivider>主题</NDivider> <NDivider>主题</NDivider>
@@ -210,26 +299,64 @@ onMounted(() => {
<NFormItem label="折叠菜单" label-placement="left"> <NFormItem label="折叠菜单" label-placement="left">
<NSwitch size="small" v-model:value="menuCollpased" /> <NSwitch size="small" v-model:value="menuCollpased" />
</NFormItem> </NFormItem>
<template v-if="route.path === '/station'">
<NFormItem label="车站列数" label-placement="left"> <NFormItem label="车站列数" label-placement="left">
<NInputNumber v-model:value="stationGridCols" :min="1" :max="10" /> <NInputNumber v-model:value="stationGridCols" :min="1" :max="10" />
</NFormItem> </NFormItem>
<template v-if="!!occStation && hasPermission(occStation.code, PERMISSION_TYPE_LITERALS.OPERATION)">
<NDivider>告警</NDivider>
<NFormItem label="告警画面截图保留天数" label-placement="left">
<NFlex justify="space-between" align="center" style="width: 100%">
<NInputNumber v-model:value="retentionDays" :min="1" :max="15" />
<NButtonGroup>
<NButton secondary size="small" :disabled="retentionDaysSaving" :loading="retentionDaysLoading" @click="() => getRetentionDays()">刷新</NButton>
<NButton secondary size="small" :disabled="retentionDaysLoading" :loading="retentionDaysSaving" @click="() => saveRetentionDays()">保存</NButton>
</NButtonGroup>
</NFlex>
</NFormItem>
<NFormItem label="自动获取告警画面截图" label-placement="left">
<NFlex justify="space-between" align="center" style="width: 100%">
<NSwitch size="small" v-model:value="snapStatus" />
<NButtonGroup>
<NButton secondary size="small" :disabled="snapStatusSaving" :loading="snapStatusLoading" @click="() => getSnapStatus()">刷新</NButton>
<NButton secondary size="small" :disabled="snapStatusLoading" :loading="snapStatusSaving" @click="() => saveSnapStatus()">保存</NButton>
</NButtonGroup>
</NFlex>
</NFormItem>
</template> </template>
<template v-if="debugModeEnabled"> <template v-if="debugMode">
<NDivider title-placement="center">调试</NDivider> <NDivider title-placement="center">调试</NDivider>
<NFormItem label="启用轮询" label-placement="left"> <NFormItem label="调试模式" label-placement="left">
<NSwitch size="small" :value="pollingEnabled" @update:value="onPollingEnabledUpdate" /> <NSwitch size="small" v-model:value="debugMode" />
</NFormItem> </NFormItem>
<NFormItem label="离线开发" label-placement="left"> <NDivider title-placement="left" dashed>数据设置</NDivider>
<NSwitch size="small" v-model:value="offlineDev" /> <NFormItem label="显示设备原始数据" label-placement="left">
<NSwitch size="small" v-model:value="showDeviceRawData" />
</NFormItem> </NFormItem>
<NFormItem label="本地数据库" label-placement="left"> <NDivider title-placement="left" dashed>网络设置</NDivider>
<NFormItem label="轮询车站" label-placement="left">
<NSwitch size="small" v-model:value="pollingStations" />
</NFormItem>
<NFormItem label="主动请求" label-placement="left">
<NSwitch size="small" v-model:value="activeRequests" />
</NFormItem>
<NFormItem label="订阅消息" label-placement="left">
<NSwitch size="small" v-model:value="subscribeMessages" />
</NFormItem>
<NFormItem label="模拟用户" label-placement="left">
<NSwitch size="small" v-model:value="mockUser" />
</NFormItem>
<NDivider title-placement="left" dashed>数据库设置</NDivider>
<NFormItem label="直接操作本地数据库" label-placement="left">
<NSwitch size="small" v-model:value="useLocalDB" />
</NFormItem>
<NFormItem label="数据操作" label-placement="left">
<NFlex> <NFlex>
<NDropdown trigger="click" :options="exportDropdownOptions" @select="onSelectDropdownOption"> <NDropdown trigger="click" :options="exportDropdownOptions" @select="onSelectDropdownOption">
<NButton secondary size="small"> <NButton secondary size="small">
<template #icon> <template #icon>
<NIcon :component="ExportOutlined" /> <NIcon :component="DownloadIcon" />
</template> </template>
<template #default>导出</template> <template #default>导出</template>
</NButton> </NButton>
@@ -237,7 +364,7 @@ onMounted(() => {
<NDropdown trigger="click" :options="importDropdownOptions" @select="onSelectDropdownOption"> <NDropdown trigger="click" :options="importDropdownOptions" @select="onSelectDropdownOption">
<NButton secondary size="small"> <NButton secondary size="small">
<template #icon> <template #icon>
<NIcon :component="ImportOutlined" /> <NIcon :component="UploadIcon" />
</template> </template>
<template #default>导入</template> <template #default>导入</template>
</NButton> </NButton>
@@ -245,7 +372,7 @@ onMounted(() => {
<NDropdown trigger="click" :options="deleteDropdownOptions" @select="onSelectDropdownOption"> <NDropdown trigger="click" :options="deleteDropdownOptions" @select="onSelectDropdownOption">
<NButton secondary size="small"> <NButton secondary size="small">
<template #icon> <template #icon>
<NIcon :component="DeleteOutlined" /> <NIcon :component="Trash2Icon" />
</template> </template>
<template #default>删除</template> <template #default>删除</template>
</NButton> </NButton>
@@ -264,7 +391,7 @@ onMounted(() => {
<NModal v-model:show="showDebugCodeModal" preset="dialog" type="info" @after-enter="onModalAfterEnter" @after-leave="onModalAfterLeave"> <NModal v-model:show="showDebugCodeModal" preset="dialog" type="info" @after-enter="onModalAfterEnter" @after-leave="onModalAfterLeave">
<template #header> <template #header>
<NText v-if="!debugModeEnabled">请输入调试码</NText> <NText v-if="!debugMode">请输入调试码</NText>
<NText v-else>确认关闭调试模式</NText> <NText v-else>确认关闭调试模式</NText>
</template> </template>
<template #default> <template #default>
@@ -272,7 +399,7 @@ onMounted(() => {
</template> </template>
<template #action> <template #action>
<NButton @click="showDebugCodeModal = false">取消</NButton> <NButton @click="showDebugCodeModal = false">取消</NButton>
<NButton v-if="!debugModeEnabled" type="primary" @click="enableDebugMode">启用</NButton> <NButton v-if="!debugMode" type="primary" @click="enableDebugMode">启用</NButton>
<NButton v-else type="primary" @click="disableDebugMode">确认</NButton> <NButton v-else type="primary" @click="disableDebugMode">确认</NButton>
</template> </template>
</NModal> </NModal>

View File

@@ -5,14 +5,14 @@ import { storeToRefs } from 'pinia';
import type { ComponentInstance } from 'vue'; import type { ComponentInstance } from 'vue';
const settingsStore = useSettingStore(); const settingsStore = useSettingStore();
const { darkThemeEnabled } = storeToRefs(settingsStore); const { darkMode } = storeToRefs(settingsStore);
// 使外部能够获取NSwitch的类型提示 // 使外部能够获取NSwitch的类型提示
defineExpose({} as ComponentInstance<typeof NSwitch>); defineExpose({} as ComponentInstance<typeof NSwitch>);
</script> </script>
<template> <template>
<NSwitch v-model:value="darkThemeEnabled"> <NSwitch v-model:value="darkMode">
<template #unchecked-icon> <template #unchecked-icon>
<NIcon> <NIcon>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">

View File

@@ -1,3 +1,4 @@
export * from './device'; export * from './device';
export * from './global'; export * from './global';
export * from './permission';
export * from './station'; export * from './station';

View File

@@ -0,0 +1,6 @@
import type { ComponentInstance } from 'vue';
import PermissionConfigModal from './permission-config-modal.vue';
export type PermissionConfigModalProps = ComponentInstance<typeof PermissionConfigModal>['$props'];
export { PermissionConfigModal };

View File

@@ -0,0 +1,302 @@
<script setup lang="ts">
import { detailBaseEmployeeApi, modifyPermissionApi, pagePermissionApi, type BaseEmployeeResultVO, type NdmPermissionResultVO, type NdmPermissionSaveVO, type Station } from '@/apis';
import { PERMISSION_TYPE_LITERALS, PERMISSION_TYPE_NAMES, type PermissionType } from '@/enums';
import { useStationStore } from '@/stores';
import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query';
import { objectEntries } from '@vueuse/core';
import { isCancel } from 'axios';
import { cloneDeep } from 'es-toolkit';
import { NButton, NCheckbox, NDataTable, NFlex, NModal, NText, type DataTableColumn, type DataTableColumns } from 'naive-ui';
import { storeToRefs } from 'pinia';
import { computed, h, ref, toRefs } from 'vue';
type NdmPermissionSaveOrResultVO = NdmPermissionSaveVO | NdmPermissionResultVO;
const props = defineProps<{
employeeId?: string;
}>();
const stationStore = useStationStore();
const { stations } = storeToRefs(stationStore);
const show = defineModel<boolean>('show', { default: false });
const { employeeId } = toRefs(props);
const abortController = ref<AbortController>(new AbortController());
const employee = ref<BaseEmployeeResultVO>();
const { mutateAsync: getEmployeeAsync } = useMutation({
mutationFn: async () => {
abortController.value.abort();
abortController.value = new AbortController();
if (!employeeId.value) return;
const signal = abortController.value.signal;
const data = await detailBaseEmployeeApi(employeeId.value, { signal });
return data;
},
onSuccess: (data) => {
if (!data) return;
employee.value = data;
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
},
});
// 从后端获取的原始权限列表
const originalList = ref<NdmPermissionResultVO[]>([]);
// 当前用户配置的权限列表
const currentList = ref<NdmPermissionSaveOrResultVO[]>([]);
const { mutate: getPermissions, isPending: permissionsLoading } = useMutation({
mutationFn: async () => {
if (!employeeId.value) throw new Error('员工ID不能为空');
abortController.value.abort();
abortController.value = new AbortController();
const signal = abortController.value.signal;
const data = await pagePermissionApi(
{
model: {
employeeId: employeeId.value,
},
current: 1,
size: Object.keys(PERMISSION_TYPE_LITERALS).length * stations.value.length,
},
{ signal },
);
return data;
},
onSuccess: (data) => {
if (!data) return;
const { records } = data;
originalList.value = cloneDeep(records);
currentList.value = cloneDeep(records);
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
},
});
const onUpdatePermissionChecked = (checked: boolean, stationCode: Station['code'], permissionType: PermissionType) => {
if (!employeeId.value) return;
if (checked) {
const existed = currentList.value.some((permission) => permission.stationCode === stationCode && permission.type === permissionType);
if (!existed) {
const saveVO: NdmPermissionSaveVO = {
employeeId: employeeId.value,
stationCode,
type: permissionType,
};
currentList.value.push(saveVO);
}
} else {
const index = currentList.value.findIndex((permission) => permission.stationCode === stationCode && permission.type === permissionType);
if (index !== -1) {
currentList.value.splice(index, 1);
}
}
};
const tableColumns = computed<DataTableColumns<Station>>(() => {
return [
{
title: () => {
const permissionCount = currentList.value.length;
const permissionTypeCount = objectEntries(PERMISSION_TYPE_LITERALS).length;
const checked = permissionCount === stations.value.length * permissionTypeCount;
const indeterminate = permissionCount > 0 && permissionCount < stations.value.length * permissionTypeCount;
return h(NCheckbox, {
checked,
indeterminate,
onUpdateChecked: (checked) => {
objectEntries(PERMISSION_TYPE_LITERALS).forEach(([permissionType]) => {
stations.value.forEach((station) => {
onUpdatePermissionChecked(checked, station.code, permissionType);
});
});
},
});
},
key: 'row-check',
align: 'center',
width: 60,
fixed: 'left',
render: (rowData) => {
const { code: stationCode } = rowData;
const permissionTypeCount = objectEntries(PERMISSION_TYPE_LITERALS).length;
const stationCheckedPermissions = currentList.value.filter((permission) => permission.stationCode === stationCode);
const checked = stationCheckedPermissions.length === permissionTypeCount;
const indeterminate = stationCheckedPermissions.length > 0 && stationCheckedPermissions.length < permissionTypeCount;
return h(NCheckbox, {
checked,
indeterminate,
onUpdateChecked: (checked) => {
objectEntries(PERMISSION_TYPE_LITERALS).forEach(([permissionType]) => {
onUpdatePermissionChecked(checked, stationCode, permissionType);
});
},
});
},
},
{ title: '车站编号', key: 'code', align: 'center', width: 120 },
{ title: '车站名称', key: 'name', align: 'center', width: 360 },
// 「权限」列
...objectEntries(PERMISSION_TYPE_NAMES).map<DataTableColumn<Station>>(([permissionType, title]) => ({
title: () => {
const permissionCount = currentList.value.filter((permission) => permission.type === permissionType).length;
const checked = permissionCount === stations.value.length;
const indeterminate = permissionCount > 0 && permissionCount < stations.value.length;
return h(
NFlex,
{
justify: 'center',
align: 'center',
},
{
default: () => [
h(NCheckbox, {
checked,
indeterminate,
onUpdateChecked: (checked) => {
stations.value.forEach((station) => {
onUpdatePermissionChecked(checked, station.code, permissionType);
});
},
}),
h('span', title),
],
},
);
},
key: permissionType,
align: 'center',
render: (rowData) => {
const { code: stationCode } = rowData;
return h(NCheckbox, {
checked: currentList.value.some((permission) => permission.stationCode === stationCode && permission.type === permissionType),
onUpdateChecked: (checked) => onUpdatePermissionChecked(checked, stationCode, permissionType),
});
},
})),
];
});
const { mutate: savePermissions, isPending: permissionsSaving } = useMutation({
mutationFn: async () => {
if (!employeeId.value) throw new Error('员工ID不能为空');
abortController.value.abort();
abortController.value = new AbortController();
const signal = abortController.value.signal;
// 执行diff计算生成需要保存的权限列表和需要删除的权限ID列表
const saveList: NdmPermissionSaveVO[] = [];
const removeList: string[] = [];
// 遍历当前状态,如果权限不在原始权限列表中,说明是需要新增的权限
currentList.value.forEach((permission) => {
const { stationCode, type } = permission;
if (!stationCode || !type) return;
if (!originalList.value.some((permission) => permission.stationCode === stationCode && permission.type === type)) {
saveList.push({
employeeId: employeeId.value,
stationCode,
type,
});
}
});
// 遍历原始状态,如果权限不在当前状态中,说明是需要删除的权限
originalList.value.forEach((permission) => {
const { id, stationCode, type } = permission;
if (!id) return;
if (!currentList.value.some((permission) => permission.stationCode === stationCode && permission.type === type)) {
removeList.push(id);
}
});
await modifyPermissionApi(
{
employeeId: employeeId.value,
saveList,
removeList,
},
{
signal,
},
);
},
onSuccess: () => {
window.$message.success('权限配置保存成功');
getPermissions();
},
onError: (error) => {
if (isCancel(error)) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback);
},
});
const onAfterEnter = () => {
getEmployeeAsync().then(() => getPermissions());
};
const onAfterLeave = () => {
employee.value = undefined;
originalList.value = [];
currentList.value = [];
};
const onClose = () => {
abortController.value.abort();
show.value = false;
};
</script>
<template>
<NModal
v-model:show="show"
preset="card"
style="width: 100vw; height: 100vh"
:content-style="{ height: '100%', overflow: 'hidden' }"
:close-on-esc="false"
:mask-closable="false"
:auto-focus="false"
@after-enter="onAfterEnter"
@after-leave="onAfterLeave"
@close="onClose"
>
<template #header>
<span>{{ `配置权限 - ${employee?.realName ?? ''}` }}</span>
</template>
<template #default>
<NDataTable flex-height style="height: 100%" :columns="tableColumns" :data="stations" :loading="permissionsLoading" :single-line="false" />
</template>
<template #footer>
<NText depth="3" style="font-size: smaller">*未勾选任何权限的用户将被认为拥有所有权限</NText>
</template>
<template #action>
<NFlex justify="end">
<NButton size="small" @click="onClose">取消</NButton>
<NButton type="primary" size="small" :loading="permissionsSaving" @click="() => savePermissions()">保存</NButton>
</NFlex>
</template>
</NModal>
</template>
<style scoped lang="scss"></style>

View File

@@ -59,7 +59,7 @@ const tableColumns = ref<DataTableBaseColumn<NdmDeviceAlarmLogResultVO>[]>([
const stationDevices = lineDevices.value[stationCode]; const stationDevices = lineDevices.value[stationCode];
if (!stationDevices) return; if (!stationDevices) return;
const classified = stationDevices[deviceType]; const classified = stationDevices[deviceType];
const device = classified.find((device) => device.deviceId === rowData.deviceId); const device = classified.find((device) => !!device.deviceId && device.deviceId === rowData.deviceId);
if (!device) return; if (!device) return;
const deviceDbId = device.id; const deviceDbId = device.id;
router.push({ router.push({

View File

@@ -1,13 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import { getRecordCheckApi, type NdmNvrResultVO, type Station } from '@/apis'; import { batchExportRecordCheckApi, pageDefParameterApi, type Station } from '@/apis';
import { exportRecordDiagCsv, isNvrCluster, transformRecordChecks } from '@/helpers'; import { downloadByData, parseErrorFeedback } from '@/utils';
import { useDeviceStore } from '@/stores';
import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
import { isCancel } from 'axios'; import { isCancel } from 'axios';
import { NButton, NGrid, NGridItem, NModal, NScrollbar, NSpin } from 'naive-ui'; import dayjs from 'dayjs';
import { storeToRefs } from 'pinia'; import { NButton, NFlex, NGrid, NGridItem, NModal, NScrollbar, NSpin } from 'naive-ui';
import { computed, ref, toRefs } from 'vue'; import { ref, toRefs } from 'vue';
const props = defineProps<{ const props = defineProps<{
stations: Station[]; stations: Station[];
@@ -19,50 +17,66 @@ const emit = defineEmits<{
const show = defineModel<boolean>('show'); const show = defineModel<boolean>('show');
const deviceStore = useDeviceStore();
const { lineDevices } = storeToRefs(deviceStore);
const { stations } = toRefs(props); const { stations } = toRefs(props);
const nvrClusterRecord = computed(() => {
const clusterMap: Record<Station['code'], { stationName: Station['name']; clusters: NdmNvrResultVO[] }> = {};
stations.value.forEach((station) => {
clusterMap[station.code] = {
stationName: station.name,
clusters: [],
};
const stationDevices = lineDevices.value[station.code];
const nvrs = stationDevices?.['ndmNvr'] ?? [];
nvrs.forEach((nvr) => {
if (isNvrCluster(nvr)) {
clusterMap[station.code]?.clusters?.push(nvr);
}
});
});
return clusterMap;
});
const abortController = ref<AbortController>(new AbortController()); const abortController = ref<AbortController>(new AbortController());
const { mutate: exportRecordDiags, isPending: exporting } = useMutation({ const { mutate: batchExportRecordCheck, isPending: batchExporting } = useMutation({
mutationFn: async (params: { clusters: NdmNvrResultVO[]; stationCode: Station['code'] }) => { mutationFn: async (params: { stations: Station[] }) => {
const { clusters, stationCode } = params; const timer = setTimeout(() => {
if (clusters.length === 0) { if (!batchExporting.value) return;
const stationName = nvrClusterRecord.value[stationCode]?.stationName ?? ''; window.$message.info('导出耗时较长,请耐心等待...', { duration: 0 });
window.$message.info(`${stationName} 没有录像诊断数据`); }, 3000);
return;
} try {
const cluster = clusters.at(0);
if (!cluster) return;
abortController.value.abort(); abortController.value.abort();
abortController.value = new AbortController(); abortController.value = new AbortController();
const checks = await getRecordCheckApi(cluster, 90, [], { stationCode: stationCode, signal: abortController.value.signal }); const { records = [] } = await pageDefParameterApi(
return checks; {
model: {
key: 'NVR_GAP_SECONDS',
}, },
onSuccess: (checks, { stationCode }) => { extra: {},
if (!checks || checks.length === 0) return; current: 1,
const recordDiags = transformRecordChecks(checks); size: 1,
exportRecordDiagCsv(recordDiags, nvrClusterRecord.value[stationCode]?.stationName ?? ''); sort: 'id',
order: 'descending',
},
{
signal: abortController.value.signal,
},
);
const gapSeconds = parseInt(records.at(0)?.value ?? '5');
abortController.value.abort();
abortController.value = new AbortController();
const data = await batchExportRecordCheckApi(
{
checkDuration: 90,
gapSeconds,
stationCode: params.stations.map((station) => station.code),
},
{
signal: abortController.value.signal,
},
);
return data;
} finally {
window.$message.destroyAll();
clearTimeout(timer);
}
},
onSuccess: (data, { stations }) => {
const time = dayjs().format('YYYY-MM-DD_HH-mm-ss');
let stationName = '';
if (stations.length === 1) {
const name = stations.at(0)?.name;
if (!!name) {
stationName = `${name}_`;
}
}
downloadByData(data, `${stationName}录像缺失记录_${time}.xlsx`);
}, },
onError: (error) => { onError: (error) => {
if (isCancel(error)) return; if (isCancel(error)) return;
@@ -73,6 +87,7 @@ const { mutate: exportRecordDiags, isPending: exporting } = useMutation({
}); });
const onAfterLeave = () => { const onAfterLeave = () => {
abortController.value.abort();
emit('afterLeave'); emit('afterLeave');
}; };
</script> </script>
@@ -81,17 +96,22 @@ const onAfterLeave = () => {
<NModal v-model:show="show" preset="card" title="导出录像诊断" @after-leave="onAfterLeave" style="width: 800px"> <NModal v-model:show="show" preset="card" title="导出录像诊断" @after-leave="onAfterLeave" style="width: 800px">
<template #default> <template #default>
<NScrollbar style="height: 300px"> <NScrollbar style="height: 300px">
<NSpin size="small" :show="exporting"> <NSpin size="small" :show="batchExporting">
<NGrid :cols="6"> <NGrid :cols="6">
<template v-for="({ stationName, clusters }, code) in nvrClusterRecord" :key="code"> <template v-for="station in stations" :key="station.code">
<NGridItem> <NGridItem>
<NButton text type="info" style="height: 30px" @click="() => exportRecordDiags({ clusters, stationCode: code })">{{ stationName }}</NButton> <NButton text type="info" style="height: 30px" @click="() => batchExportRecordCheck({ stations: [station] })">{{ station.name }}</NButton>
</NGridItem> </NGridItem>
</template> </template>
</NGrid> </NGrid>
</NSpin> </NSpin>
</NScrollbar> </NScrollbar>
</template> </template>
<template #action>
<NFlex justify="flex-end" align="center">
<NButton secondary :loading="batchExporting" @click="() => batchExportRecordCheck({ stations })">导出全部</NButton>
</NFlex>
</template>
</NModal> </NModal>
</template> </template>

View File

@@ -1,10 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Station, StationAlarms, StationDevices } from '@/apis'; import type { Station, StationAlarms, StationDevices } from '@/apis';
import { DEVICE_TYPE_LITERALS } from '@/enums'; import { usePermission } from '@/composables';
import { EllipsisOutlined, MoreOutlined } from '@vicons/antd'; import { DEVICE_TYPE_LITERALS, PERMISSION_TYPE_LITERALS } from '@/enums';
import axios from 'axios'; import axios from 'axios';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { isFunction } from 'es-toolkit'; import { isFunction } from 'es-toolkit';
import { MoreHorizontalIcon, MoreVerticalIcon } from 'lucide-vue-next';
import { NButton, NCard, NCheckbox, NDropdown, NFlex, NIcon, NTag, NTooltip, useThemeVars, type DropdownOption } from 'naive-ui'; import { NButton, NCard, NCheckbox, NDropdown, NFlex, NIcon, NTag, NTooltip, useThemeVars, type DropdownOption } from 'naive-ui';
import { computed, toRefs } from 'vue'; import { computed, toRefs } from 'vue';
@@ -24,6 +25,8 @@ const emit = defineEmits<{
clickConfig: [station: Station]; clickConfig: [station: Station];
}>(); }>();
const { hasPermission } = usePermission();
const { station, devices, alarms, selectable } = toRefs(props); const { station, devices, alarms, selectable } = toRefs(props);
const onlineDeviceCount = computed(() => { const onlineDeviceCount = computed(() => {
@@ -71,7 +74,7 @@ const openDeviceConfigModal = () => {
emit('clickConfig', station.value); emit('clickConfig', station.value);
}; };
const dropdownOptions: DropdownOption[] = [ const dropdownOptions = computed<DropdownOption[]>(() => [
{ {
label: '视频平台', label: '视频平台',
key: 'video-platform', key: 'video-platform',
@@ -80,9 +83,10 @@ const dropdownOptions: DropdownOption[] = [
{ {
label: '设备配置', label: '设备配置',
key: 'device-config', key: 'device-config',
show: hasPermission(station.value.code, PERMISSION_TYPE_LITERALS.OPERATION),
onSelect: openDeviceConfigModal, onSelect: openDeviceConfigModal,
}, },
]; ]);
const onSelectDropdownOption = (key: string, option: DropdownOption) => { const onSelectDropdownOption = (key: string, option: DropdownOption) => {
const onSelect = option['onSelect']; const onSelect = option['onSelect'];
@@ -116,7 +120,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
<NDropdown trigger="click" :options="dropdownOptions" @select="onSelectDropdownOption"> <NDropdown trigger="click" :options="dropdownOptions" @select="onSelectDropdownOption">
<NButton quaternary size="tiny" :focusable="false"> <NButton quaternary size="tiny" :focusable="false">
<template #icon> <template #icon>
<NIcon :component="MoreOutlined" /> <NIcon :component="MoreVerticalIcon" />
</template> </template>
</NButton> </NButton>
</NDropdown> </NDropdown>
@@ -129,7 +133,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
<span>{{ deviceCount }} 台设备</span> <span>{{ deviceCount }} 台设备</span>
<NButton quaternary size="tiny" :focusable="false" @click="() => emit('clickDetail', 'device', station)"> <NButton quaternary size="tiny" :focusable="false" @click="() => emit('clickDetail', 'device', station)">
<template #icon> <template #icon>
<NIcon :component="EllipsisOutlined" /> <NIcon :component="MoreHorizontalIcon" />
</template> </template>
</NButton> </NButton>
</NFlex> </NFlex>
@@ -143,7 +147,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
<!-- 占位按钮对齐布局 --> <!-- 占位按钮对齐布局 -->
<NButton quaternary size="tiny" :focusable="false" style="visibility: hidden"> <NButton quaternary size="tiny" :focusable="false" style="visibility: hidden">
<template #icon> <template #icon>
<NIcon :component="EllipsisOutlined" /> <NIcon :component="MoreHorizontalIcon" />
</template> </template>
</NButton> </NButton>
</NFlex> </NFlex>
@@ -153,7 +157,7 @@ const onSelectDropdownOption = (key: string, option: DropdownOption) => {
<span :style="{ color: alarmCount > 0 ? themeVars.warningColor : '' }">今日 {{ alarmCount }} 条告警</span> <span :style="{ color: alarmCount > 0 ? themeVars.warningColor : '' }">今日 {{ alarmCount }} 条告警</span>
<NButton quaternary size="tiny" :focusable="false" @click="() => emit('clickDetail', 'alarm', station)"> <NButton quaternary size="tiny" :focusable="false" @click="() => emit('clickDetail', 'alarm', station)">
<template #icon> <template #icon>
<NIcon :component="EllipsisOutlined" /> <NIcon :component="MoreHorizontalIcon" />
</template> </template>
</NButton> </NButton>
</NFlex> </NFlex>

View File

@@ -1,11 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import type { Station, SyncCameraResult } from '@/apis';
import { usePermissionStore } from '@/stores';
import { watchDebounced } from '@vueuse/core'; import { watchDebounced } from '@vueuse/core';
import { EditIcon, PlusCircleIcon, Trash2Icon } from 'lucide-vue-next';
import { NFlex, NIcon, NList, NListItem, NModal, NScrollbar, NStatistic, NText, NThing } from 'naive-ui'; import { NFlex, NIcon, NList, NListItem, NModal, NScrollbar, NStatistic, NText, NThing } from 'naive-ui';
import { computed, ref, toRefs } from 'vue'; import { computed, ref, toRefs } from 'vue';
import { useStationStore } from '@/stores';
import { storeToRefs } from 'pinia';
import type { Station, SyncCameraResult } from '@/apis';
import { DeleteFilled, EditFilled, PlusCircleFilled } from '@vicons/antd';
const props = defineProps<{ const props = defineProps<{
syncCameraResult: Record<Station['code'], SyncCameraResult>; syncCameraResult: Record<Station['code'], SyncCameraResult>;
@@ -15,8 +14,8 @@ const emit = defineEmits<{
afterLeave: []; afterLeave: [];
}>(); }>();
const stationStore = useStationStore(); const permissionStore = usePermissionStore();
const { stations } = storeToRefs(stationStore); const stations = computed(() => permissionStore.stations.VIEW ?? []);
const { syncCameraResult } = toRefs(props); const { syncCameraResult } = toRefs(props);
@@ -61,19 +60,19 @@ const syncList = computed(() => {
<NFlex justify="space-around" :size="24" style="margin-top: 8px"> <NFlex justify="space-around" :size="24" style="margin-top: 8px">
<NStatistic label="新增"> <NStatistic label="新增">
<template #prefix> <template #prefix>
<NIcon :component="PlusCircleFilled" /> <NIcon :component="PlusCircleIcon" />
</template> </template>
{{ insertList.length }} {{ insertList.length }}
</NStatistic> </NStatistic>
<NStatistic label="更新"> <NStatistic label="更新">
<template #prefix> <template #prefix>
<NIcon :component="EditFilled" /> <NIcon :component="EditIcon" />
</template> </template>
{{ updateList.length }} {{ updateList.length }}
</NStatistic> </NStatistic>
<NStatistic label="删除"> <NStatistic label="删除">
<template #prefix> <template #prefix>
<NIcon :component="DeleteFilled" /> <NIcon :component="Trash2Icon" />
</template> </template>
{{ deleteList.length }} {{ deleteList.length }}
</NStatistic> </NStatistic>

View File

@@ -1,11 +1,14 @@
import { usePermission } from '../permission';
import { deleteCameraIgnoreApi, pageCameraIgnoreApi, saveCameraIgnoreApi, updateDeviceAlarmLogApi, type NdmDeviceAlarmLogResultVO } from '@/apis'; import { deleteCameraIgnoreApi, pageCameraIgnoreApi, saveCameraIgnoreApi, updateDeviceAlarmLogApi, type NdmDeviceAlarmLogResultVO } from '@/apis';
import { DEVICE_TYPE_LITERALS, tryGetDeviceType } from '@/enums'; import { DEVICE_TYPE_LITERALS, PERMISSION_TYPE_LITERALS, tryGetDeviceType } from '@/enums';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
import { NButton, NFlex, NPopconfirm, type DataTableColumn, type DataTableRowData } from 'naive-ui'; import { NButton, NFlex, NPopconfirm, type DataTableColumn, type DataTableRowData } from 'naive-ui';
import { h, type Ref } from 'vue'; import { h, type Ref } from 'vue';
export const useAlarmActionColumn = (tableData: Ref<DataTableRowData[]>) => { export const useAlarmActionColumn = (tableData: Ref<DataTableRowData[]>) => {
const { hasPermission } = usePermission();
const { mutate: confirmAlarm } = useMutation({ const { mutate: confirmAlarm } = useMutation({
mutationFn: async (params: { id: string | null }) => { mutationFn: async (params: { id: string | null }) => {
const { id } = params; const { id } = params;
@@ -115,7 +118,9 @@ export const useAlarmActionColumn = (tableData: Ref<DataTableRowData[]>) => {
default: () => '确认告警?', default: () => '确认告警?',
}, },
), ),
tryGetDeviceType(rowData.deviceType) === DEVICE_TYPE_LITERALS.ndmCamera && [ tryGetDeviceType(rowData.deviceType) === DEVICE_TYPE_LITERALS.ndmCamera &&
rowData.stationCode &&
hasPermission(rowData.stationCode, PERMISSION_TYPE_LITERALS.OPERATION) && [
h( h(
NPopconfirm, NPopconfirm,
{ {

View File

@@ -1,4 +1,4 @@
import { getCameraSnapApi, type NdmDeviceAlarmLogResultVO } from '@/apis'; import { detailDeviceAlarmSnapLogApi, type NdmDeviceAlarmLogResultVO } from '@/apis';
import { tryGetDeviceType, DEVICE_TYPE_LITERALS } from '@/enums'; import { tryGetDeviceType, DEVICE_TYPE_LITERALS } from '@/enums';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { useMutation } from '@tanstack/vue-query'; import { useMutation } from '@tanstack/vue-query';
@@ -7,11 +7,9 @@ import { h, ref, watch, type Ref } from 'vue';
export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => { export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
const { mutateAsync: getSnapByDeviceId } = useMutation({ const { mutateAsync: getSnapByDeviceId } = useMutation({
mutationFn: async (params: { deviceAlarmLog: NdmDeviceAlarmLogResultVO }) => { mutationFn: async (params: { id: string }) => {
const { deviceAlarmLog } = params; const { id } = params;
const { deviceId } = deviceAlarmLog; const snap = await detailDeviceAlarmSnapLogApi(id);
if (!deviceId) throw new Error('设备ID不能为空');
const snap = await getCameraSnapApi(deviceId);
return snap; return snap;
}, },
onError: (error) => { onError: (error) => {
@@ -28,15 +26,15 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
}); });
const cameraSnapColumn: DataTableColumn<NdmDeviceAlarmLogResultVO & { snapUrl?: string }> = { const cameraSnapColumn: DataTableColumn<NdmDeviceAlarmLogResultVO & { snapUrl?: string }> = {
title: '实时画面截图', title: '告警画面截图',
key: 'snapUrl', key: 'snapUrl',
align: 'center', align: 'center',
render: (rowData) => { render: (rowData) => {
const { deviceType: deviceTypeCode, snapUrl } = rowData; const { id, deviceType: deviceTypeCode, snapUrl } = rowData;
if (!id) return null;
const deviceType = tryGetDeviceType(deviceTypeCode); const deviceType = tryGetDeviceType(deviceTypeCode);
if (deviceType !== DEVICE_TYPE_LITERALS.ndmCamera) return null; if (deviceType !== DEVICE_TYPE_LITERALS.ndmCamera) return null;
if (!snapUrl) { if (!snapUrl) {
const id = rowData.id ?? '';
return h( return h(
NButton, NButton,
{ {
@@ -46,8 +44,9 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
onClick: async () => { onClick: async () => {
loadingMap.value[id] = true; loadingMap.value[id] = true;
try { try {
const snap = await getSnapByDeviceId({ deviceAlarmLog: rowData }); const snap = await getSnapByDeviceId({ id });
rowData.snapUrl = snap.data.url; if (!snap.url) return;
rowData.snapUrl = snap.url;
} finally { } finally {
loadingMap.value[id] = false; loadingMap.value[id] = false;
} }
@@ -60,6 +59,7 @@ export const useCameraSnapColumn = (tableData: Ref<DataTableRowData[]>) => {
} }
}, },
}; };
return { return {
cameraSnapColumn, cameraSnapColumn,
}; };

View File

@@ -1,39 +1,33 @@
import type { LineDevices, NdmDeviceResultVO, Station } from '@/apis'; import type { LineDevices, NdmDeviceResultVO, Station } from '@/apis';
import { tryGetDeviceType, type DeviceType } from '@/enums'; import { tryGetDeviceType, type DeviceType } from '@/enums';
import { useDeviceStore } from '@/stores'; import { ref } from 'vue';
import { watchDebounced } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { onMounted, ref, toValue, watch, type MaybeRefOrGetter } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
export const useDeviceSelection = (options?: { syncRoute?: MaybeRefOrGetter<boolean> }) => { export const useDeviceSelection = () => {
const { syncRoute } = options ?? {};
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const deviceStore = useDeviceStore();
const { lineDevices } = storeToRefs(deviceStore);
const selectedStationCode = ref<Station['code']>(); const selectedStationCode = ref<Station['code']>();
const selectedDeviceType = ref<DeviceType>(); const selectedDeviceType = ref<DeviceType>();
const selectedDevice = ref<NdmDeviceResultVO>(); const selectedDevice = ref<NdmDeviceResultVO>();
const initFromRoute = (lineDevices: LineDevices) => { // 从路由参数同步选中的车站、设备类型以及设备
const { stationCode, deviceType, deviceDbId } = route.query; const syncFromRoute = (lineDevices: LineDevices) => {
if (stationCode) { // console.log('sync from route');
selectedStationCode.value = stationCode as Station['code']; const { stationCode: routeStationCode, deviceType: routeDeviceType, deviceDbId: routeDeviceDbId } = route.query;
if (routeStationCode) {
selectedStationCode.value = routeStationCode as Station['code'];
} }
if (deviceType) { if (routeDeviceType) {
selectedDeviceType.value = deviceType as DeviceType; selectedDeviceType.value = routeDeviceType as DeviceType;
} }
if (deviceDbId && selectedStationCode.value && selectedDeviceType.value) { if (routeDeviceDbId && selectedStationCode.value && selectedDeviceType.value) {
const selectedDeviceDbId = deviceDbId as string; const selectedDeviceDbId = routeDeviceDbId as string;
const stationDevices = lineDevices[selectedStationCode.value]; const stationDevices = lineDevices[selectedStationCode.value];
if (stationDevices) { if (stationDevices) {
const devices = stationDevices[selectedDeviceType.value]; const classifiedDevices = stationDevices[selectedDeviceType.value];
if (devices) { if (classifiedDevices) {
const device = devices.find((device) => device.id === selectedDeviceDbId); const device = classifiedDevices.find((device) => device.id === selectedDeviceDbId);
if (device) { if (device) {
selectedDevice.value = device; selectedDevice.value = device;
} }
@@ -51,7 +45,9 @@ export const useDeviceSelection = (options?: { syncRoute?: MaybeRefOrGetter<bool
} }
}; };
// 将选中的车站、设备类型以及设备ID同步到路由参数
const syncToRoute = () => { const syncToRoute = () => {
// console.log('sync to route');
const query = { ...route.query }; const query = { ...route.query };
// 当选中的设备发生变化时删除fromPage参数 // 当选中的设备发生变化时删除fromPage参数
if (selectedDevice.value?.id && route.query.deviceDbId !== selectedDevice.value.id) { if (selectedDevice.value?.id && route.query.deviceDbId !== selectedDevice.value.id) {
@@ -69,39 +65,13 @@ export const useDeviceSelection = (options?: { syncRoute?: MaybeRefOrGetter<bool
router.replace({ query }); router.replace({ query });
}; };
watch(selectedDevice, () => {
if (toValue(syncRoute)) {
syncToRoute();
}
});
// lineDevices是shallowRef因此需要深度侦听才能获取内部变化
// 而单纯的深度侦听又可能会引发性能问题,因此尝试使用防抖侦听
watchDebounced(
lineDevices,
(newLineDevices) => {
if (toValue(syncRoute)) {
initFromRoute(newLineDevices);
}
},
{
debounce: 500,
deep: true,
},
);
onMounted(() => {
if (toValue(syncRoute)) {
initFromRoute(lineDevices.value);
}
});
return { return {
selectedStationCode, selectedStationCode,
selectedDeviceType, selectedDeviceType,
selectedDevice, selectedDevice,
initFromRoute, syncFromRoute,
syncToRoute,
selectDevice, selectDevice,
}; };
}; };

View File

@@ -1,11 +1,8 @@
import type { MaybeRefOrGetter } from 'vue';
import { useDeviceManagement } from './use-device-management'; import { useDeviceManagement } from './use-device-management';
import { useDeviceSelection } from './use-device-selection'; import { useDeviceSelection } from './use-device-selection';
export const useDeviceTree = (options?: { syncRoute?: MaybeRefOrGetter<boolean> }) => { export const useDeviceTree = () => {
const { syncRoute } = options ?? {}; const deviceSelection = useDeviceSelection();
const deviceSelection = useDeviceSelection({ syncRoute });
const deviceManagement = useDeviceManagement(); const deviceManagement = useDeviceManagement();
return { return {

View File

@@ -1,4 +1,6 @@
export * from './alarm'; export * from './alarm';
export * from './device'; export * from './device';
export * from './permission';
export * from './query'; export * from './query';
export * from './station';
export * from './stomp'; export * from './stomp';

View File

@@ -0,0 +1 @@
export * from './use-permission';

View File

@@ -0,0 +1,14 @@
import type { PermissionType } from '@/enums';
import { usePermissionStore } from '@/stores';
export const usePermission = () => {
const permissionStore = usePermissionStore();
const hasPermission = (stationCode: string, permissionType: PermissionType) => {
return !!permissionStore.permissions[stationCode]?.includes(permissionType);
};
return {
hasPermission,
};
};

View File

@@ -1,5 +1,6 @@
export * from './use-line-alarms-query'; export * from './use-line-alarms-query';
export * from './use-line-devices-query'; export * from './use-line-devices-query';
export * from './use-line-stations-query'; export * from './use-line-stations-query';
export * from './use-user-permission-query';
export * from './use-verify-user-query'; export * from './use-verify-user-query';
export * from './use-version-check-query'; export * from './use-version-check-query';

View File

@@ -1,12 +1,11 @@
import { initStationAlarms, pageDeviceAlarmLogApi, type Station } from '@/apis'; import { initStationAlarms, pageDeviceAlarmLogApi, type Station } from '@/apis';
import { LINE_ALARMS_QUERY_KEY, STATION_ALARMS_MUTATION_KEY } from '@/constants'; import { LINE_ALARMS_QUERY_KEY, STATION_ALARMS_MUTATION_KEY } from '@/constants';
import { tryGetDeviceType } from '@/enums'; import { tryGetDeviceType } from '@/enums';
import { useAlarmStore, useStationStore } from '@/stores'; import { useAlarmStore, usePermissionStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { CancelledError, useMutation, useQuery } from '@tanstack/vue-query'; import { CancelledError, useMutation, useQuery } from '@tanstack/vue-query';
import { isCancel } from 'axios'; import { isCancel } from 'axios';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { storeToRefs } from 'pinia';
import { computed } from 'vue'; import { computed } from 'vue';
export const useStationAlarmsMutation = () => { export const useStationAlarmsMutation = () => {
@@ -56,8 +55,8 @@ export const useStationAlarmsMutation = () => {
alarmStore.setStationAlarms(station.code, stationAlarms); alarmStore.setStationAlarms(station.code, stationAlarms);
}, },
onError: (error) => { onError: (error) => {
console.error(error);
if (isCancel(error) || error instanceof CancelledError) return; if (isCancel(error) || error instanceof CancelledError) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error); const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback); window.$message.error(errorFeedback);
}, },
@@ -69,19 +68,22 @@ export const useStationAlarmsMutation = () => {
* @see [use-line-stations-query.ts](./use-line-stations-query.ts) * @see [use-line-stations-query.ts](./use-line-stations-query.ts)
*/ */
export const useLineAlarmsQuery = () => { export const useLineAlarmsQuery = () => {
const stationStore = useStationStore(); const permissionStore = usePermissionStore();
const { stations } = storeToRefs(stationStore); const stations = computed(() => permissionStore.stations.VIEW ?? []);
const { mutateAsync: getStationAlarms } = useStationAlarmsMutation(); const { mutateAsync: getStationAlarms } = useStationAlarmsMutation();
return useQuery({ return useQuery({
queryKey: computed(() => [LINE_ALARMS_QUERY_KEY]), queryKey: computed(() => [LINE_ALARMS_QUERY_KEY]),
enabled: false, enabled: false,
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
console.time(LINE_ALARMS_QUERY_KEY); const startTime = performance.now();
for (const station of stations.value) { for (const station of stations.value) {
await getStationAlarms({ station, signal }).catch(() => {}); await getStationAlarms({ station, signal }).catch(() => {});
} }
console.timeEnd(LINE_ALARMS_QUERY_KEY); const endTime = performance.now();
console.log(`${LINE_ALARMS_QUERY_KEY}: ${endTime - startTime} ms`);
return null; return null;
}, },
}); });

View File

@@ -1,10 +1,9 @@
import { getAllDevicesApi, initStationDevices, type Station } from '@/apis'; import { getAllDevicesApi, initStationDevices, type Station } from '@/apis';
import { LINE_DEVICES_QUERY_KEY, STATION_DEVICES_MUTATION_KEY } from '@/constants'; import { LINE_DEVICES_QUERY_KEY, STATION_DEVICES_MUTATION_KEY } from '@/constants';
import { useDeviceStore, useStationStore } from '@/stores'; import { useDeviceStore, usePermissionStore } from '@/stores';
import { parseErrorFeedback } from '@/utils'; import { parseErrorFeedback } from '@/utils';
import { CancelledError, useMutation, useQuery } from '@tanstack/vue-query'; import { CancelledError, useMutation, useQuery } from '@tanstack/vue-query';
import { isCancel } from 'axios'; import { isCancel } from 'axios';
import { storeToRefs } from 'pinia';
import { computed } from 'vue'; import { computed } from 'vue';
export const useStationDevicesMutation = () => { export const useStationDevicesMutation = () => {
@@ -23,8 +22,8 @@ export const useStationDevicesMutation = () => {
deviceStore.setStationDevices(station.code, devices); deviceStore.setStationDevices(station.code, devices);
}, },
onError: (error) => { onError: (error) => {
console.error(error);
if (isCancel(error) || error instanceof CancelledError) return; if (isCancel(error) || error instanceof CancelledError) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error); const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback); window.$message.error(errorFeedback);
}, },
@@ -36,19 +35,22 @@ export const useStationDevicesMutation = () => {
* @see [use-line-stations-query.ts](./use-line-stations-query.ts) * @see [use-line-stations-query.ts](./use-line-stations-query.ts)
*/ */
export const useLineDevicesQuery = () => { export const useLineDevicesQuery = () => {
const stationStore = useStationStore(); const permissionStore = usePermissionStore();
const { stations } = storeToRefs(stationStore); const stations = computed(() => permissionStore.stations.VIEW ?? []);
const { mutateAsync: getStationDevices } = useStationDevicesMutation(); const { mutateAsync: getStationDevices } = useStationDevicesMutation();
return useQuery({ return useQuery({
queryKey: computed(() => [LINE_DEVICES_QUERY_KEY]), queryKey: computed(() => [LINE_DEVICES_QUERY_KEY]),
enabled: false, enabled: false,
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
console.time(LINE_DEVICES_QUERY_KEY); const startTime = performance.now();
for (const station of stations.value) { for (const station of stations.value) {
await getStationDevices({ station, signal }).catch(() => {}); await getStationDevices({ station, signal }).catch(() => {});
} }
console.timeEnd(LINE_DEVICES_QUERY_KEY); const endTime = performance.now();
console.log(`${LINE_DEVICES_QUERY_KEY}: ${endTime - startTime} ms`);
return null; return null;
}, },
}); });

View File

@@ -1,14 +1,12 @@
import { batchVerifyApi, type Station } from '@/apis'; import { batchVerifyApi, type Station } from '@/apis';
import { LINE_STATIONS_MUTATION_KEY, LINE_STATIONS_QUERY_KEY } from '@/constants'; import { LINE_STATIONS_MUTATION_KEY, LINE_STATIONS_QUERY_KEY } from '@/constants';
import { usePollingStore, useStationStore } from '@/stores'; import { useSettingStore, useStationStore } from '@/stores';
import { getAppEnvConfig, parseErrorFeedback } from '@/utils'; import { getAppEnvConfig, parseErrorFeedback } from '@/utils';
import { CancelledError, useMutation, useQuery } from '@tanstack/vue-query'; import { CancelledError, useMutation, useQuery } from '@tanstack/vue-query';
import axios, { isCancel } from 'axios'; import axios, { isCancel } from 'axios';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { computed } from 'vue'; import { computed } from 'vue';
import { useLineDevicesQuery } from './use-line-devices-query';
import { useLineAlarmsQuery } from './use-line-alarms-query';
export const useLineStationsMutation = () => { export const useLineStationsMutation = () => {
const stationStore = useStationStore(); const stationStore = useStationStore();
@@ -17,12 +15,13 @@ export const useLineStationsMutation = () => {
mutationKey: [LINE_STATIONS_MUTATION_KEY], mutationKey: [LINE_STATIONS_MUTATION_KEY],
mutationFn: async (params: { signal?: AbortSignal }) => { mutationFn: async (params: { signal?: AbortSignal }) => {
const { signal } = params; const { signal } = params;
const { data: ndmStationList } = await axios.get<{ code: string; name: string }[]>(`/minio/ndm/ndm-stations.json?_t=${dayjs().unix()}`, { signal }); const { data: ndmStationList } = await axios.get<Omit<Station, 'online' | 'ip'>[]>(`/minio/ndm/ndm-stations.json?_t=${dayjs().unix()}`, { signal });
const stations = ndmStationList.map<Station>((station) => ({ const stations = ndmStationList.map<Station>((station) => ({
code: station.code ?? '', code: station.code ?? '',
name: station.name ?? '', name: station.name ?? '',
online: false, online: false,
ip: '', ip: '',
occ: station.occ,
})); }));
const verifyList = await batchVerifyApi({ signal }); const verifyList = await batchVerifyApi({ signal });
return stations.map((station) => ({ return stations.map((station) => ({
@@ -35,8 +34,8 @@ export const useLineStationsMutation = () => {
stationStore.setStations(stations); stationStore.setStations(stations);
}, },
onError: (error) => { onError: (error) => {
console.error(error);
if (isCancel(error) || error instanceof CancelledError) return; if (isCancel(error) || error instanceof CancelledError) return;
console.error(error);
const errorFeedback = parseErrorFeedback(error); const errorFeedback = parseErrorFeedback(error);
window.$message.error(errorFeedback); window.$message.error(errorFeedback);
}, },
@@ -44,28 +43,21 @@ export const useLineStationsMutation = () => {
}; };
export const useLineStationsQuery = () => { export const useLineStationsQuery = () => {
const pollingStore = usePollingStore(); const settingStore = useSettingStore();
const { pollingEnabled } = storeToRefs(pollingStore); const { pollingStations } = storeToRefs(settingStore);
const { requestInterval } = getAppEnvConfig(); const { requestInterval } = getAppEnvConfig();
const { mutateAsync: getLineStations } = useLineStationsMutation(); const { mutateAsync: getLineStations } = useLineStationsMutation();
const { refetch: refetchLineDevicesQuery } = useLineDevicesQuery();
const { refetch: refetchLineAlarmsQuery } = useLineAlarmsQuery();
return useQuery({ return useQuery({
queryKey: computed(() => [LINE_STATIONS_QUERY_KEY]), queryKey: computed(() => [LINE_STATIONS_QUERY_KEY]),
enabled: computed(() => pollingEnabled.value), enabled: computed(() => pollingStations.value),
refetchInterval: requestInterval * 1000, refetchInterval: requestInterval * 1000,
staleTime: (requestInterval * 1000) / 2, staleTime: (requestInterval * 1000) / 2,
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
console.time(LINE_STATIONS_QUERY_KEY); const startTime = performance.now();
await getLineStations({ signal }).catch(() => {}); await getLineStations({ signal }).catch(() => {});
console.timeEnd(LINE_STATIONS_QUERY_KEY); const endTime = performance.now();
console.log(`${LINE_STATIONS_QUERY_KEY}: ${endTime - startTime} ms`);
if (!pollingEnabled.value) return null;
await refetchLineDevicesQuery();
if (!pollingEnabled.value) return null;
await refetchLineAlarmsQuery();
return null; return null;
}, },

View File

@@ -0,0 +1,67 @@
import { useLineDevicesQuery } from './use-line-devices-query';
import { useLineAlarmsQuery } from './use-line-alarms-query';
import { pagePermissionApi } from '@/apis';
import { USER_PERMISSION_QUERY_KEY } from '@/constants';
import { PERMISSION_TYPE_LITERALS } from '@/enums';
import { usePermissionStore, useSettingStore, useStationStore, useUserStore } from '@/stores';
import { useQuery } from '@tanstack/vue-query';
import { storeToRefs } from 'pinia';
import { computed, watch } from 'vue';
import { useLineStationsQuery } from './use-line-stations-query';
export const useUserPermissionQuery = () => {
const settingStore = useSettingStore();
const { pollingStations, activeRequests } = storeToRefs(settingStore);
const userStore = useUserStore();
const { userInfo } = storeToRefs(userStore);
const stationStore = useStationStore();
const { stations } = storeToRefs(stationStore);
const permissionStore = usePermissionStore();
const { permissions } = storeToRefs(permissionStore);
const { dataUpdatedAt: stationsUpdatedTime } = useLineStationsQuery();
const { refetch: refetchLineDevicesQuery } = useLineDevicesQuery();
const { refetch: refetchLineAlarmsQuery } = useLineAlarmsQuery();
watch([permissions, stationsUpdatedTime], async ([newPermissions, newUpdatedTime], [oldPermissions, oldUpdatedTime]) => {
const newPermissionsJson = JSON.stringify(newPermissions);
const oldPermissionsJson = JSON.stringify(oldPermissions);
if (newPermissionsJson === oldPermissionsJson && newUpdatedTime === oldUpdatedTime) return;
// 设备查询和告警查询依赖pollingEnabdled
// 当关闭轮询时,只会取消当前正在执行的查询,
// 所以如果在关闭轮询时refetch还未执行那么这一次取消就是无效的refetch依然会执行
// 所以在每个refetch被调用前都需要检查pollingEnabled否则就可能会取消失败
if (!pollingStations.value) return;
await refetchLineDevicesQuery();
if (!pollingStations.value) return;
await refetchLineAlarmsQuery();
});
return useQuery({
queryKey: computed(() => [USER_PERMISSION_QUERY_KEY]),
// 启用【车站轮询】或【主动请求】时,都认为查询被启用
enabled: computed(() => (pollingStations.value || activeRequests.value) && userInfo.value?.['employeeId'] && stations.value.length > 0),
// 当启用【车站轮询】时刷新间隔为10秒缓存时间为5秒
refetchInterval: computed(() => (pollingStations.value ? 10 * 1000 : undefined)),
staleTime: computed(() => (pollingStations.value ? 5 * 1000 : undefined)),
queryFn: async ({ signal }) => {
const { records } = await pagePermissionApi(
{
model: {
employeeId: userInfo.value['employeeId'],
},
current: 1,
size: Object.keys(PERMISSION_TYPE_LITERALS).length * stations.value.length,
},
{
signal,
},
);
permissionStore.setPermRecords(records);
return null;
},
});
};

View File

@@ -8,17 +8,17 @@ import { computed, watch } from 'vue';
export const useVerifyUserQuery = () => { export const useVerifyUserQuery = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const settingStore = useSettingStore(); const settingStore = useSettingStore();
const { offlineDev } = storeToRefs(settingStore); const { activeRequests } = storeToRefs(settingStore);
watch(offlineDev, (offline) => { watch(activeRequests, (active) => {
if (offline) { if (!active) {
queryClient.cancelQueries({ queryKey: [VERIFY_USER_QUERY_KEY] }); queryClient.cancelQueries({ queryKey: [VERIFY_USER_QUERY_KEY] });
} }
}); });
return useQuery({ return useQuery({
queryKey: [VERIFY_USER_QUERY_KEY], queryKey: [VERIFY_USER_QUERY_KEY],
enabled: computed(() => !offlineDev.value), enabled: computed(() => activeRequests.value),
refetchInterval: 10 * 1000, refetchInterval: 10 * 1000,
queryFn: async ({ signal }) => { queryFn: async ({ signal }) => {
await verifyApi({ signal }); await verifyApi({ signal });

View File

@@ -0,0 +1 @@
export * from './use-batch-actions';

View File

@@ -0,0 +1,139 @@
import { usePermission } from '../permission';
import { type Station } from '@/apis';
import { PERMISSION_TYPE_LITERALS, type PermissionType } from '@/enums';
import { objectEntries } from '@vueuse/core';
import type { CheckboxProps } from 'naive-ui';
import { computed, ref, watch, type Ref } from 'vue';
type BatchActionKey = 'export-icmp' | 'export-record' | 'sync-camera' | 'sync-nvr';
type BatchAction = {
label: string;
key: BatchActionKey;
permission: PermissionType;
active: boolean;
};
export const useBatchActions = (stations: Ref<Station[]>, abortController?: Ref<AbortController | undefined>) => {
const { hasPermission } = usePermission();
const batchActions = ref<BatchAction[]>([
{
label: '导出设备状态',
key: 'export-icmp',
permission: PERMISSION_TYPE_LITERALS.VIEW,
active: false,
},
{
label: '导出录像诊断',
key: 'export-record',
permission: PERMISSION_TYPE_LITERALS.VIEW,
active: false,
},
{
label: '同步摄像机',
key: 'sync-camera',
permission: PERMISSION_TYPE_LITERALS.OPERATION,
active: false,
},
{
label: '同步录像机通道',
key: 'sync-nvr',
permission: PERMISSION_TYPE_LITERALS.OPERATION,
active: false,
},
]);
const selectedAction = computed(() => {
return batchActions.value.find((action) => action.active);
});
const selectableStations = computed(() => {
if (!selectedAction.value) return [];
const result: Station[] = [];
if (selectedAction.value.permission === PERMISSION_TYPE_LITERALS.VIEW) {
result.push(...stations.value.filter((station) => hasPermission(station.code, PERMISSION_TYPE_LITERALS.VIEW)));
}
if (selectedAction.value.permission === PERMISSION_TYPE_LITERALS.OPERATION) {
result.push(...stations.value.filter((station) => hasPermission(station.code, PERMISSION_TYPE_LITERALS.OPERATION)));
}
return result;
});
const stationSelection = ref<Record<Station['code'], boolean>>({});
const selectionProps = computed<CheckboxProps>(() => {
const selectableStationsLength = selectableStations.value.length;
const selectedStationsLength = objectEntries(stationSelection.value).filter(([, selected]) => selected).length;
const disabled = selectableStationsLength === 0;
const checked = selectableStationsLength > 0 && selectedStationsLength === selectableStationsLength;
const indeterminate = selectableStationsLength > 0 && selectedStationsLength > 0 && selectedStationsLength < selectableStationsLength;
return {
disabled,
checked,
indeterminate,
};
});
const toggleSelectAction = (action: BatchAction) => {
batchActions.value.forEach((batchAction) => {
if (batchAction.key === action.key) {
if (batchAction.active) stationSelection.value = {};
batchAction.active = !batchAction.active;
} else {
batchAction.active = false;
}
});
};
const toggleSelectAllStations = (checked: boolean) => {
if (!checked) {
stationSelection.value = {};
return;
}
selectableStations.value.forEach((station) => {
stationSelection.value[station.code] = checked;
});
};
watch(selectedAction, () => {
toggleSelectAllStations(false);
});
const confirmAction = (callbacks: Record<BatchActionKey, () => void>) => {
const { key } = selectedAction.value ?? {};
if (!key) return;
const noStationSeleted = !Object.values(stationSelection.value).some((selected) => selected);
if (noStationSeleted) {
window.$message.warning('请选择车站');
return;
}
callbacks[key]();
};
const cancelAction = () => {
abortController?.value?.abort();
stationSelection.value = {};
batchActions.value.forEach((batchAction) => {
batchAction.active = false;
});
};
return {
batchActions,
selectedAction,
selectableStations,
stationSelection,
selectionProps,
toggleSelectAction,
toggleSelectAllStations,
confirmAction,
cancelAction,
};
};

Some files were not shown because too many files have changed in this diff Show More