Compare commits
81 Commits
d83968cfc4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db831e82ff | ||
|
|
6bf205f461 | ||
|
|
cf3d19d89d | ||
|
|
b020226538 | ||
|
|
b79b1df57e | ||
|
|
9b21beed0f | ||
|
|
aa4684273b | ||
|
|
36e839142a | ||
|
|
03006a8f06 | ||
|
|
0af52c62ce | ||
|
|
82789c78a9 | ||
|
|
6771abec31 | ||
|
|
b7b6b216fb | ||
|
|
97f05f21ae | ||
|
|
c4963b5b70 | ||
|
|
86775a6eb2 | ||
|
|
db3a6ddca5 | ||
|
|
b59b34e68b | ||
|
|
de35075be8 | ||
|
|
045f7a9a81 | ||
|
|
bd6ad9b932 | ||
|
|
b392328f37 | ||
|
|
c3692de19e | ||
|
|
c273ae21d9 | ||
|
|
653981c0e7 | ||
|
|
263dd5edfc | ||
|
|
fd70f63fc9 | ||
|
|
8566b06429 | ||
|
|
a00c736f33 | ||
|
|
85a6b73473 | ||
|
|
64c501f94c | ||
|
|
c81847ea0f | ||
|
|
080759c544 | ||
|
|
670054ca01 | ||
|
|
80e879e61f | ||
|
|
c259eabc22 | ||
|
|
286449b831 | ||
|
|
e112b01a21 | ||
|
|
054b2bcdac | ||
|
|
1f23588649 | ||
|
|
02e29eb4f3 | ||
|
|
118cc8be0b | ||
|
|
5170105ab8 | ||
|
|
420637352d | ||
|
|
abdbef2d05 | ||
|
|
cdd1f2113f | ||
|
|
73c2354a06 | ||
|
|
01b059fb7f | ||
|
|
fd7f1927ff | ||
|
|
ed2a4f78ff | ||
|
|
f99fe0f68e | ||
|
|
76aa654cde | ||
|
|
58b3d09d5d | ||
|
|
26d894ba1c | ||
|
|
05b94b2707 | ||
|
|
c0d49e345b | ||
|
|
426ca4947a | ||
|
|
bb140433d8 | ||
|
|
df304b06d3 | ||
|
|
9748b94046 | ||
|
|
4eb2a2ab3d | ||
|
|
7f07725935 | ||
|
|
e8ac939795 | ||
|
|
a7c36079cf | ||
|
|
f58ea93985 | ||
|
|
1e3810ba2d | ||
|
|
865147fdf8 | ||
|
|
f35810f907 | ||
|
|
92f0e832ca | ||
|
|
42b2eacef7 | ||
|
|
a598b9c1d3 | ||
|
|
2d977c5321 | ||
|
|
189f7a5d63 | ||
|
|
44f5f4d50b | ||
|
|
075f008b65 | ||
|
|
c8274a8c6b | ||
|
|
a90e788dc5 | ||
|
|
e7fdf911e7 | ||
|
|
c408d875f4 | ||
|
|
6183bfd4d7 | ||
|
|
9af76bacbb |
2
.env
2
.env
@@ -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
141
README.md
@@ -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
|
||||||
|
|
||||||
|
整个数据轮询流程采用“单点驱动 + 变更监听 + 级联触发”的模式,如下图所示。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
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
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
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
195971
docs/data/ndm-device-store.json
Normal file
File diff suppressed because one or more lines are too long
203
docs/data/ndm-station-store.json
Normal file
203
docs/data/ndm-station-store.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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
28
pnpm-lock.yaml
generated
@@ -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
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useVersionCheckQuery } from './composables';
|
|
||||||
import { GlobalFeedback } from '@/components';
|
import { GlobalFeedback } from '@/components';
|
||||||
|
import { useVersionCheckQuery } from '@/composables';
|
||||||
import { useSettingStore } from '@/stores';
|
import { useSettingStore } from '@/stores';
|
||||||
import { VueQueryDevtools } from '@tanstack/vue-query-devtools';
|
import { VueQueryDevtools } from '@tanstack/vue-query-devtools';
|
||||||
import { dateZhCN, NConfigProvider, NDialogProvider, NLoadingBarProvider, NMessageProvider, NNotificationProvider, zhCN } from 'naive-ui';
|
import { dateZhCN, NConfigProvider, NDialogProvider, NLoadingBarProvider, NMessageProvider, NNotificationProvider, zhCN } from 'naive-ui';
|
||||||
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>
|
||||||
|
|||||||
@@ -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);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -19,4 +19,12 @@ export interface NdmSwitchPortInfo {
|
|||||||
outFlow: number;
|
outFlow: number;
|
||||||
portName: string;
|
portName: string;
|
||||||
upDown: number;
|
upDown: number;
|
||||||
|
|
||||||
|
lastChangeTime: string;
|
||||||
|
|
||||||
|
opticalTemperature?: number;
|
||||||
|
opticalVoltage?: number;
|
||||||
|
opticalBiasCurrent?: number;
|
||||||
|
opticalReceivePower?: number;
|
||||||
|
opticalTransmitPower?: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
export * from './diag';
|
export * from './diag';
|
||||||
|
export * from './link-description';
|
||||||
export * from './station';
|
export * from './station';
|
||||||
|
|||||||
10
src/apis/domain/biz/link-description/index.ts
Normal file
10
src/apis/domain/biz/link-description/index.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { NdmCameraLinkDescription } from './ndm-camera-link-description';
|
||||||
|
import type { NdmSecurityBoxLinkDescription } from './ndm-security-box-link-description';
|
||||||
|
import type { NdmSwitchLinkDescription } from './ndm-switch-link-description';
|
||||||
|
|
||||||
|
export * from './link-description';
|
||||||
|
export * from './ndm-camera-link-description';
|
||||||
|
export * from './ndm-security-box-link-description';
|
||||||
|
export * from './ndm-switch-link-description';
|
||||||
|
|
||||||
|
export type NdmDeviceLinkDescription = NdmCameraLinkDescription | NdmSecurityBoxLinkDescription | NdmSwitchLinkDescription;
|
||||||
5
src/apis/domain/biz/link-description/link-description.ts
Normal file
5
src/apis/domain/biz/link-description/link-description.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import type { DeviceStoreIndex } from '@/apis';
|
||||||
|
|
||||||
|
export interface LinkDescription {
|
||||||
|
upstream?: DeviceStoreIndex[];
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import type { LinkDescription } from './link-description';
|
||||||
|
|
||||||
|
export interface NdmCameraLinkDescription extends LinkDescription {}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import type { DeviceStoreIndex } from '@/apis';
|
||||||
|
import type { LinkDescription } from './link-description';
|
||||||
|
|
||||||
|
export interface NdmSecurityBoxLinkDescription extends LinkDescription {
|
||||||
|
downstream?: {
|
||||||
|
[circuitIndex: number]: DeviceStoreIndex;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import type { DeviceStoreIndex } from '@/apis';
|
||||||
|
import type { LinkDescription } from './link-description';
|
||||||
|
|
||||||
|
export interface NdmSwitchLinkDescription extends LinkDescription {
|
||||||
|
downstream?: {
|
||||||
|
[portName: string]: DeviceStoreIndex;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -10,7 +10,13 @@ import type {
|
|||||||
NdmVideoServerResultVO,
|
NdmVideoServerResultVO,
|
||||||
Station,
|
Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
import { DEVICE_TYPE_LITERALS } from '@/enums';
|
import { DEVICE_TYPE_LITERALS, type DeviceType } from '@/enums';
|
||||||
|
|
||||||
|
export interface DeviceStoreIndex {
|
||||||
|
stationCode: Station['code'];
|
||||||
|
deviceType: DeviceType;
|
||||||
|
deviceDbId: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface StationDevices {
|
export interface StationDevices {
|
||||||
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: NdmAlarmHostResultVO[];
|
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: NdmAlarmHostResultVO[];
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ export interface Station {
|
|||||||
name: string;
|
name: string;
|
||||||
online: boolean;
|
online: boolean;
|
||||||
ip: string;
|
ip: string;
|
||||||
|
occ?: boolean; // 是否为控制中心
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/apis/model/base/base-employee.ts
Normal file
21
src/apis/model/base/base-employee.ts
Normal 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>>;
|
||||||
@@ -1,3 +1 @@
|
|||||||
export * from './model';
|
export * from './base-employee';
|
||||||
export * from './page';
|
|
||||||
export * from './reduce';
|
|
||||||
|
|||||||
@@ -1,32 +1,21 @@
|
|||||||
import type { Nullable } from '@/types';
|
import type { Nullable, Optional } from '@/types';
|
||||||
|
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';
|
||||||
import type {
|
import type { NdmCamera, NdmDecoder, NdmKeyboard, NdmMediaServer, NdmVideoServer } from './video';
|
||||||
NdmCamera,
|
|
||||||
NdmDecoder,
|
|
||||||
NdmKeyboard,
|
|
||||||
NdmMediaServer,
|
|
||||||
NdmMediaServerPageQuery,
|
|
||||||
NdmMediaServerResultVO,
|
|
||||||
NdmMediaServerSaveVO,
|
|
||||||
NdmMediaServerUpdateVO,
|
|
||||||
NdmVideoServer,
|
|
||||||
NdmVideoServerPageQuery,
|
|
||||||
NdmVideoServerResultVO,
|
|
||||||
NdmVideoServerSaveVO,
|
|
||||||
NdmVideoServerUpdateVO,
|
|
||||||
} from './video';
|
|
||||||
|
|
||||||
export type NdmDevice = NdmAlarmHost | NdmCamera | NdmDecoder | NdmKeyboard | NdmMediaServer | NdmNvr | NdmSecurityBox | NdmSwitch | NdmVideoServer;
|
export type NdmDevice = NdmAlarmHost | NdmCamera | NdmDecoder | NdmKeyboard | NdmMediaServer | NdmNvr | NdmSecurityBox | NdmSwitch | NdmVideoServer;
|
||||||
|
|
||||||
export type NdmDeviceResultVO = Nullable<NdmDevice>;
|
export type NdmDeviceResultVO = Nullable<NdmDevice>;
|
||||||
|
export type NdmDeviceSaveVO = Partial<Omit<NdmDevice, ReduceForSaveVO>>;
|
||||||
|
export type NdmDeviceUpdateVO = Optional<Omit<NdmDevice, ReduceForUpdateVO>>;
|
||||||
|
export type NdmDevicePageQuery = Partial<Omit<NdmDevice, ReduceForPageQuery>>;
|
||||||
|
|
||||||
export type NdmServer = NdmMediaServer | NdmVideoServer;
|
export type NdmServer = NdmMediaServer | NdmVideoServer;
|
||||||
export type NdmServerResultVO = NdmMediaServerResultVO | NdmVideoServerResultVO;
|
export type NdmServerResultVO = Nullable<NdmServer>;
|
||||||
export type NdmServerSaveVO = NdmMediaServerSaveVO | NdmVideoServerSaveVO;
|
export type NdmServerSaveVO = Partial<Omit<NdmServer, ReduceForSaveVO>>;
|
||||||
export type NdmServerUpdateVO = NdmMediaServerUpdateVO | NdmVideoServerUpdateVO;
|
export type NdmServerUpdateVO = Optional<Omit<NdmServer, ReduceForUpdateVO>>;
|
||||||
export type NdmServerPageQuery = NdmMediaServerPageQuery | NdmVideoServerPageQuery;
|
export type NdmServerPageQuery = Partial<Omit<NdmServer, ReduceForPageQuery>>;
|
||||||
|
|
||||||
export * from './alarm';
|
export * from './alarm';
|
||||||
export * from './icmp';
|
export * from './icmp';
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
@@ -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>;
|
||||||
|
|||||||
16
src/apis/model/biz/entity/log/ndm-device-alarm-snap-log.ts
Normal file
16
src/apis/model/biz/entity/log/ndm-device-alarm-snap-log.ts
Normal 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>>;
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
34
src/apis/model/biz/entity/other/ndm-permission.ts
Normal file
34
src/apis/model/biz/entity/other/ndm-permission.ts
Normal 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>>;
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
export * from './invite-stream-type';
|
||||||
|
export * from './send-rtp-info';
|
||||||
export * from './snap-result';
|
export * from './snap-result';
|
||||||
|
|||||||
1
src/apis/model/biz/vimp/invite-stream-type.ts
Normal file
1
src/apis/model/biz/vimp/invite-stream-type.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export type InviteStreamType = 'PLAY' | 'PLAYBACK' | 'DOWNLOAD' | 'PUSH' | 'PROXY' | 'CLOUD_RECORD_PUSH' | 'CLOUD_RECORD_PROXY';
|
||||||
51
src/apis/model/biz/vimp/send-rtp-info.ts
Normal file
51
src/apis/model/biz/vimp/send-rtp-info.ts
Normal 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的pt(uint8_t),不传时默认为96
|
||||||
|
*/
|
||||||
|
pt: number;
|
||||||
|
/**
|
||||||
|
* 发送时,rtp的负载类型。为true时,负载为ps;为false时,为es;
|
||||||
|
*/
|
||||||
|
usePs: boolean;
|
||||||
|
/**
|
||||||
|
* 当usePs 为false时,有效。为1时,发送音频;为0时,发送视频;不传时默认为0
|
||||||
|
*/
|
||||||
|
onlyAudio: boolean;
|
||||||
|
/**
|
||||||
|
* 是否开启rtcp保活
|
||||||
|
*/
|
||||||
|
rtcp: boolean;
|
||||||
|
playType: InviteStreamType;
|
||||||
|
}>;
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
export interface SnapResult {
|
export interface SnapResult {
|
||||||
absoluteFilePath: string;
|
code: number;
|
||||||
path: string;
|
msg: string;
|
||||||
url: string;
|
data: {
|
||||||
|
absoluteFilePath: string;
|
||||||
|
path: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/apis/model/common/import-msg.ts
Normal file
13
src/apis/model/common/import-msg.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
export interface ImportMsg {
|
||||||
|
wrongLines: WrongLine[];
|
||||||
|
wrongNum: number;
|
||||||
|
updateNum: number;
|
||||||
|
insertNum: number;
|
||||||
|
unchangedNum: number;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WrongLine {
|
||||||
|
rowNum: number;
|
||||||
|
msg: string;
|
||||||
|
}
|
||||||
1
src/apis/model/common/index.ts
Normal file
1
src/apis/model/common/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './import-msg';
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
export * from './base';
|
export * from './base';
|
||||||
export * from './biz';
|
export * from './biz';
|
||||||
|
export * from './common';
|
||||||
|
export * from './schema';
|
||||||
export * from './system';
|
export * from './system';
|
||||||
|
|||||||
3
src/apis/model/schema/index.ts
Normal file
3
src/apis/model/schema/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export * from './model';
|
||||||
|
export * from './page';
|
||||||
|
export * from './reduce';
|
||||||
21
src/apis/request/base/base-employee.ts
Normal file
21
src/apis/request/base/base-employee.ts
Normal 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;
|
||||||
|
};
|
||||||
1
src/apis/request/base/index.ts
Normal file
1
src/apis/request/base/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './base-employee';
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
type PageResult,
|
type PageResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageAlarmHostApi = async (pageQuery: PageParams<NdmAlarmHostPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageAlarmHostApi = async (pageQuery: PageParams<NdmAlarmHostPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -17,9 +18,7 @@ export const pageAlarmHostApi = async (pageQuery: PageParams<NdmAlarmHostPageQue
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmAlarmHost/page`;
|
const endpoint = `${prefix}/api/ndm/ndmAlarmHost/page`;
|
||||||
const resp = await client.post<PageResult<NdmAlarmHostResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmAlarmHostResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +28,7 @@ export const detailAlarmHostApi = async (id: string, options?: { stationCode?: S
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmAlarmHost/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmAlarmHost/detail`;
|
||||||
const resp = await client.get<NdmAlarmHostResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmAlarmHostResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,9 +38,7 @@ export const saveAlarmHostApi = async (saveVO: NdmAlarmHostSaveVO, options?: { s
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmAlarmHost`;
|
const endpoint = `${prefix}/api/ndm/ndmAlarmHost`;
|
||||||
const resp = await client.post<NdmAlarmHostResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmAlarmHostResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,9 +48,7 @@ export const updateAlarmHostApi = async (updateVO: NdmAlarmHostUpdateVO, options
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmAlarmHost`;
|
const endpoint = `${prefix}/api/ndm/ndmAlarmHost`;
|
||||||
const resp = await client.put<NdmAlarmHostResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmAlarmHostResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,9 +58,7 @@ export const deleteAlarmHostApi = async (ids: string[], options?: { stationCode?
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmAlarmHost`;
|
const endpoint = `${prefix}/api/ndm/ndmAlarmHost`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,9 +68,7 @@ export const exportAlarmHostApi = async (pageQuery: PageParams<NdmAlarmHostPageQ
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmAlarmHost/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmAlarmHost/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,8 +80,6 @@ export const importAlarmHostApi = async (file: File, options?: { stationCode?: S
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import { initStationDevices, ndmClient, userClient, type StationDevices } from '@/apis';
|
import { initStationDevices, ndmClient, userClient, type Station, type StationDevices } from '@/apis';
|
||||||
|
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDevices/all`;
|
const endpoint = `${prefix}/api/ndm/ndmDevices/all`;
|
||||||
const resp = await client.get<StationDevices>(endpoint, { retRaw: true, signal });
|
const resp = await client.get<StationDevices>(endpoint, { retRaw: true, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
// 由于各线路后端版本不一致,接口返回的设备类型可能不够完整,需要做一次合并
|
// 由于各线路后端版本不一致,接口返回的设备类型可能不够完整,需要做一次合并
|
||||||
return {
|
return {
|
||||||
...initStationDevices(),
|
...initStationDevices(),
|
||||||
|
|||||||
32
src/apis/request/biz/composed/delete-device.ts
Normal file
32
src/apis/request/biz/composed/delete-device.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import {
|
||||||
|
deleteAlarmHostApi,
|
||||||
|
deleteCameraApi,
|
||||||
|
deleteDecoderApi,
|
||||||
|
deleteKeyboardApi,
|
||||||
|
deleteMediaServerApi,
|
||||||
|
deleteNvrApi,
|
||||||
|
deleteSecurityBoxApi,
|
||||||
|
deleteSwitchApi,
|
||||||
|
deleteVideoServerApi,
|
||||||
|
type Station,
|
||||||
|
} from '@/apis';
|
||||||
|
import { DEVICE_TYPE_LITERALS, type DeviceType } from '@/enums';
|
||||||
|
|
||||||
|
export const deleteDeviceApi = async (deviceType: DeviceType, id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
|
const apiRecord = {
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: deleteAlarmHostApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmCamera]: deleteCameraApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmDecoder]: deleteDecoderApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmKeyboard]: deleteKeyboardApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmMediaServer]: deleteMediaServerApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmNvr]: deleteNvrApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: deleteSecurityBoxApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmSwitch]: deleteSwitchApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmVideoServer]: deleteVideoServerApi,
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteApi = apiRecord[deviceType];
|
||||||
|
if (!deleteApi) throw new Error('接口不存在');
|
||||||
|
|
||||||
|
return deleteApi([id], options);
|
||||||
|
};
|
||||||
@@ -20,40 +20,31 @@ export const detailDeviceApi = async (device: NdmDeviceResultVO, options?: { sta
|
|||||||
const deviceType = tryGetDeviceType(deviceTypeCode);
|
const deviceType = tryGetDeviceType(deviceTypeCode);
|
||||||
if (!deviceType) throw new Error('未知的设备');
|
if (!deviceType) throw new Error('未知的设备');
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmAlarmHost) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmAlarmHost) {
|
||||||
await detailAlarmHostApi(id, { stationCode, signal });
|
return await detailAlarmHostApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmCamera) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmCamera) {
|
||||||
await detailCameraApi(id, { stationCode, signal });
|
return await detailCameraApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmDecoder) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmDecoder) {
|
||||||
await detailDecoderApi(id, { stationCode, signal });
|
return await detailDecoderApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmKeyboard) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmKeyboard) {
|
||||||
await detailKeyboardApi(id, { stationCode, signal });
|
return await detailKeyboardApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmMediaServer) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmMediaServer) {
|
||||||
await detailMediaServerApi(id, { stationCode, signal });
|
return await detailMediaServerApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmNvr) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmNvr) {
|
||||||
await detailNvrApi(id, { stationCode, signal });
|
return await detailNvrApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmSecurityBox) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmSecurityBox) {
|
||||||
await detailSecurityBoxApi(id, { stationCode, signal });
|
return await detailSecurityBoxApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmSwitch) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmSwitch) {
|
||||||
await detailSwitchApi(id, { stationCode, signal });
|
return await detailSwitchApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (deviceType === DEVICE_TYPE_LITERALS.ndmVideoServer) {
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmVideoServer) {
|
||||||
await detailVideoServerApi(id, { stationCode, signal });
|
return await detailVideoServerApi(id, { stationCode, signal });
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|||||||
34
src/apis/request/biz/composed/export-device.ts
Normal file
34
src/apis/request/biz/composed/export-device.ts
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
import {
|
||||||
|
exportAlarmHostApi,
|
||||||
|
exportCameraApi,
|
||||||
|
exportDecoderApi,
|
||||||
|
exportKeyboardApi,
|
||||||
|
exportMediaServerApi,
|
||||||
|
exportNvrApi,
|
||||||
|
exportSecurityBoxApi,
|
||||||
|
exportSwitchApi,
|
||||||
|
exportVideoServerApi,
|
||||||
|
type NdmDevicePageQuery,
|
||||||
|
type PageParams,
|
||||||
|
type Station,
|
||||||
|
} from '@/apis';
|
||||||
|
import { DEVICE_TYPE_LITERALS, type DeviceType } from '@/enums';
|
||||||
|
|
||||||
|
export const exportDeviceApi = async (deviceType: DeviceType, pageQuery: PageParams<NdmDevicePageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
|
const apiRecord = {
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: exportAlarmHostApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmCamera]: exportCameraApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmDecoder]: exportDecoderApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmKeyboard]: exportKeyboardApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmMediaServer]: exportMediaServerApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmNvr]: exportNvrApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: exportSecurityBoxApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmSwitch]: exportSwitchApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmVideoServer]: exportVideoServerApi,
|
||||||
|
};
|
||||||
|
|
||||||
|
const exportApi = apiRecord[deviceType];
|
||||||
|
if (!exportApi) throw new Error('接口不存在');
|
||||||
|
|
||||||
|
return exportApi(pageQuery, options);
|
||||||
|
};
|
||||||
32
src/apis/request/biz/composed/import-device.ts
Normal file
32
src/apis/request/biz/composed/import-device.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import {
|
||||||
|
importAlarmHostApi,
|
||||||
|
importCameraApi,
|
||||||
|
importDecoderApi,
|
||||||
|
importKeyboardApi,
|
||||||
|
importMediaServerApi,
|
||||||
|
importNvrApi,
|
||||||
|
importSecurityBoxApi,
|
||||||
|
importSwitchApi,
|
||||||
|
importVideoServerApi,
|
||||||
|
type Station,
|
||||||
|
} from '@/apis';
|
||||||
|
import { DEVICE_TYPE_LITERALS, type DeviceType } from '@/enums';
|
||||||
|
|
||||||
|
export const importDeviceApi = async (deviceType: DeviceType, file: File, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
|
const apiRecord = {
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmAlarmHost]: importAlarmHostApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmCamera]: importCameraApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmDecoder]: importDecoderApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmKeyboard]: importKeyboardApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmMediaServer]: importMediaServerApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmNvr]: importNvrApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmSecurityBox]: importSecurityBoxApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmSwitch]: importSwitchApi,
|
||||||
|
[DEVICE_TYPE_LITERALS.ndmVideoServer]: importVideoServerApi,
|
||||||
|
};
|
||||||
|
|
||||||
|
const importApi = apiRecord[deviceType];
|
||||||
|
if (!importApi) throw new Error('接口不存在');
|
||||||
|
|
||||||
|
return importApi(file, options);
|
||||||
|
};
|
||||||
@@ -1,2 +1,6 @@
|
|||||||
|
export * from './delete-device';
|
||||||
export * from './detail-device';
|
export * from './detail-device';
|
||||||
|
export * from './export-device';
|
||||||
|
export * from './import-device';
|
||||||
export * from './probe-device';
|
export * from './probe-device';
|
||||||
|
export * from './update-device';
|
||||||
|
|||||||
59
src/apis/request/biz/composed/update-device.ts
Normal file
59
src/apis/request/biz/composed/update-device.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import {
|
||||||
|
updateAlarmHostApi,
|
||||||
|
updateCameraApi,
|
||||||
|
updateDecoderApi,
|
||||||
|
updateKeyboardApi,
|
||||||
|
updateMediaServerApi,
|
||||||
|
updateNvrApi,
|
||||||
|
updateSecurityBoxApi,
|
||||||
|
updateSwitchApi,
|
||||||
|
updateVideoServerApi,
|
||||||
|
type NdmDeviceResultVO,
|
||||||
|
type Station,
|
||||||
|
} from '@/apis';
|
||||||
|
import { DEVICE_TYPE_LITERALS, tryGetDeviceType } from '@/enums';
|
||||||
|
|
||||||
|
export const updateDeviceApi = async (device: NdmDeviceResultVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }): Promise<NdmDeviceResultVO | undefined> => {
|
||||||
|
const { stationCode, signal } = options ?? {};
|
||||||
|
const { id, deviceType: deviceTypeCode } = device;
|
||||||
|
if (!id || !deviceTypeCode) throw new Error('未知的设备');
|
||||||
|
const deviceType = tryGetDeviceType(deviceTypeCode);
|
||||||
|
if (!deviceType) throw new Error('未知的设备');
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmAlarmHost) {
|
||||||
|
await updateAlarmHostApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmCamera) {
|
||||||
|
await updateCameraApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmDecoder) {
|
||||||
|
await updateDecoderApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmKeyboard) {
|
||||||
|
await updateKeyboardApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmMediaServer) {
|
||||||
|
await updateMediaServerApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmNvr) {
|
||||||
|
await updateNvrApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmSecurityBox) {
|
||||||
|
await updateSecurityBoxApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmSwitch) {
|
||||||
|
await updateSwitchApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (deviceType === DEVICE_TYPE_LITERALS.ndmVideoServer) {
|
||||||
|
await updateVideoServerApi(device, { stationCode, signal });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ndmClient, userClient, type Station } from '@/apis';
|
import { ndmClient, userClient, type Station } from '@/apis';
|
||||||
|
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 ?? {};
|
||||||
@@ -6,6 +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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
import { userClient, type VerifyServer } from '@/apis';
|
import { userClient, type VerifyServer } from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const batchVerifyApi = async (options?: { signal?: AbortSignal }) => {
|
export const batchVerifyApi = async (options?: { signal?: AbortSignal }) => {
|
||||||
const { signal } = options ?? {};
|
const { signal } = options ?? {};
|
||||||
const endpoint = `/api/ndm/ndmKeepAlive/batchVerify`;
|
const endpoint = `/api/ndm/ndmKeepAlive/batchVerify`;
|
||||||
const resp = await userClient.post<VerifyServer[]>(endpoint, {}, { retRaw: true, timeout: 5000, signal });
|
const resp = await userClient.post<VerifyServer[]>(endpoint, {}, { retRaw: true, timeout: 5000, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ndmClient, userClient, type IcmpEntity, type Station } from '@/apis';
|
import { ndmClient, userClient, type IcmpEntity, type Station } from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const exportIcmpApi = async (status?: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const exportIcmpApi = async (status?: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -13,9 +14,7 @@ export const exportIcmpApi = async (status?: string, options?: { stationCode?: S
|
|||||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -36,9 +35,7 @@ export const exportIcmpByStationApi = async (stationCodes: Station['code'][], st
|
|||||||
signal,
|
signal,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,8 +45,6 @@ export const icmpEntityByDeviceId = async (deviceId: string, options?: { station
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmIcmpExport/icmpEntityByDeviceId`;
|
const endpoint = `${prefix}/api/ndm/ndmIcmpExport/icmpEntityByDeviceId`;
|
||||||
const resp = await client.get<IcmpEntity[]>(endpoint, { params: { deviceId }, signal, retRaw: true });
|
const resp = await client.get<IcmpEntity[]>(endpoint, { params: { deviceId }, signal, retRaw: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { ndmClient, userClient, type Station } from '@/apis';
|
import { ndmClient, userClient, type Station } from '@/apis';
|
||||||
|
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 ?? {};
|
||||||
const client = stationCode ? ndmClient : userClient;
|
const client = stationCode ? ndmClient : userClient;
|
||||||
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, {}, { timeout: 5000, signal });
|
const resp = await client.post<void>(endpoint, {}, { retRaw: true, timeout: 5000, signal });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ndmClient, userClient, type NdmCallLogPageQuery, type NdmCallLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
import { ndmClient, userClient, type NdmCallLogPageQuery, type NdmCallLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageCallLogApi = async (pageQuery: PageParams<NdmCallLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageCallLogApi = async (pageQuery: PageParams<NdmCallLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -6,9 +7,7 @@ export const pageCallLogApi = async (pageQuery: PageParams<NdmCallLogPageQuery>,
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCallLog/page`;
|
const endpoint = `${prefix}/api/ndm/ndmCallLog/page`;
|
||||||
const resp = await client.post<PageResult<NdmCallLogResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmCallLogResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,8 +17,6 @@ export const exportCallLogApi = async (pageQuery: PageParams<NdmCallLogPageQuery
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCallLog/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmCallLog/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ndmClient, userClient, type NdmDeviceAlarmLogPageQuery, type NdmDeviceAlarmLogResultVO, type NdmDeviceAlarmLogUpdateVO, type PageParams, type PageResult, type Station } from '@/apis';
|
import { ndmClient, userClient, type NdmDeviceAlarmLogPageQuery, type NdmDeviceAlarmLogResultVO, type NdmDeviceAlarmLogUpdateVO, type PageParams, type PageResult, type Station } from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageDeviceAlarmLogApi = async (pageQuery: PageParams<NdmDeviceAlarmLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageDeviceAlarmLogApi = async (pageQuery: PageParams<NdmDeviceAlarmLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -6,9 +7,7 @@ export const pageDeviceAlarmLogApi = async (pageQuery: PageParams<NdmDeviceAlarm
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog/page`;
|
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog/page`;
|
||||||
const resp = await client.post<PageResult<NdmDeviceAlarmLogResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmDeviceAlarmLogResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,9 +17,7 @@ export const updateDeviceAlarmLogApi = async (updateVO: NdmDeviceAlarmLogUpdateV
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog`;
|
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog`;
|
||||||
const resp = await client.put<NdmDeviceAlarmLogResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmDeviceAlarmLogResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,10 +25,8 @@ export const exportDeviceAlarmLogApi = async (pageQuery: PageParams<NdmDeviceAla
|
|||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog/exportByTemplateV2`;
|
||||||
const resp = await client.post<BlobPart>(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal });
|
const resp = await client.post<BlobPart>(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
62
src/apis/request/biz/log/ndm-device-alarm-snap-log.ts
Normal file
62
src/apis/request/biz/log/ndm-device-alarm-snap-log.ts
Normal 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;
|
||||||
|
};
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ndmClient, userClient, type NdmIcmpLogPageQuery, type NdmIcmpLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
import { ndmClient, userClient, type NdmIcmpLogPageQuery, type NdmIcmpLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageIcmpLogApi = async (pageQuery: PageParams<NdmIcmpLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageIcmpLogApi = async (pageQuery: PageParams<NdmIcmpLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -6,8 +7,6 @@ export const pageIcmpLogApi = async (pageQuery: PageParams<NdmIcmpLogPageQuery>,
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmIcmpLog/page`;
|
const endpoint = `${prefix}/api/ndm/ndmIcmpLog/page`;
|
||||||
const resp = await client.post<PageResult<NdmIcmpLogResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmIcmpLogResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
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 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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getChannelList`;
|
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getChannelList`;
|
||||||
const resp = await client.post<ClientChannel[]>(endpoint, { code: ndmNvr.gbCode, time: '' }, { signal });
|
const resp = await client.post<ClientChannel[]>(endpoint, { code: ndmNvr.gbCode, time: '' }, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
@@ -24,25 +23,21 @@ export const getRecordCheckApi = async (ndmNvr: NdmNvrResultVO, lastDays: number
|
|||||||
const end = endDateTime.format('YYYY-MM-DD');
|
const end = endDateTime.format('YYYY-MM-DD');
|
||||||
const parentId = ndmNvr.gbCode;
|
const parentId = ndmNvr.gbCode;
|
||||||
const resp = await client.post<NdmRecordCheck[]>(endpoint, { start, end, parentId, gbCodeList }, { signal });
|
const resp = await client.post<NdmRecordCheck[]>(endpoint, { start, end, parentId, gbCodeList }, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadRecordCheckByGbId`;
|
const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadRecordCheckByGbId`;
|
||||||
const resp = await client.post<boolean>(endpoint, { ...channel, dayOffset }, { signal });
|
const resp = await client.post<boolean>(endpoint, { ...channel, dayOffset }, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
@@ -53,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;
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ndmClient, userClient, type NdmSnmpLogPageQuery, type NdmSnmpLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
import { ndmClient, userClient, type NdmSnmpLogPageQuery, type NdmSnmpLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageSnmpLogApi = async (pageQuery: PageParams<NdmSnmpLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageSnmpLogApi = async (pageQuery: PageParams<NdmSnmpLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -6,8 +7,6 @@ export const pageSnmpLogApi = async (pageQuery: PageParams<NdmSnmpLogPageQuery>,
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSnmpLog/page`;
|
const endpoint = `${prefix}/api/ndm/ndmSnmpLog/page`;
|
||||||
const resp = await client.post<PageResult<NdmSnmpLogResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmSnmpLogResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ndmClient, userClient, type NdmVimpLogPageQuery, type NdmVimpLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
import { ndmClient, userClient, type NdmVimpLogPageQuery, type NdmVimpLogResultVO, type PageParams, type PageResult, type Station } from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageVimpLogApi = async (pageQuery: PageParams<NdmVimpLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageVimpLogApi = async (pageQuery: PageParams<NdmVimpLogPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -6,9 +7,7 @@ export const pageVimpLogApi = async (pageQuery: PageParams<NdmVimpLogPageQuery>,
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVimpLog/page`;
|
const endpoint = `${prefix}/api/ndm/ndmVimpLog/page`;
|
||||||
const resp = await client.post<PageResult<NdmVimpLogResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmVimpLogResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,8 +17,6 @@ export const exportVimpLogApi = async (pageQuery: PageParams<NdmVimpLogPageQuery
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVimpLog/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmVimpLog/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|||||||
83
src/apis/request/biz/other/ndm-permission.ts
Normal file
83
src/apis/request/biz/other/ndm-permission.ts
Normal 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;
|
||||||
|
};
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
type PageResult,
|
type PageResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
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 ?? {};
|
||||||
@@ -17,9 +18,7 @@ export const pageSecurityBoxApi = async (pageQuery: PageParams<NdmSecurityBoxPag
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/page`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/page`;
|
||||||
const resp = await client.post<PageResult<NdmSecurityBoxResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmSecurityBoxResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +28,7 @@ export const detailSecurityBoxApi = async (id: string, options?: { stationCode?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/detail`;
|
||||||
const resp = await client.get<NdmSecurityBoxResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmSecurityBoxResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,9 +38,7 @@ export const saveSecurityBoxApi = async (saveVO: NdmSecurityBoxSaveVO, options?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox`;
|
||||||
const resp = await client.post<NdmSecurityBoxResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmSecurityBoxResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,9 +48,7 @@ export const updateSecurityBoxApi = async (updateVO: NdmSecurityBoxUpdateVO, opt
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox`;
|
||||||
const resp = await client.put<NdmSecurityBoxResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmSecurityBoxResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,9 +58,7 @@ export const deleteSecurityBoxApi = async (ids: string[], options?: { stationCod
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,9 +68,7 @@ export const exportSecurityBoxApi = async (pageQuery: PageParams<NdmSecurityBoxP
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,9 +80,7 @@ export const importSecurityBoxApi = async (file: File, options?: { stationCode?:
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,8 +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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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 }) => {
|
||||||
@@ -113,9 +99,7 @@ export const turnCitcuitStatusApi = async (ipAddress: string, circuitIndex: numb
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/turnStatus`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/turnStatus`;
|
||||||
const resp = await client.post<boolean>(endpoint, { community: 'public', ipAddress, circuit: `${circuitIndex}`, status }, { signal });
|
const resp = await client.post<boolean>(endpoint, { community: 'public', ipAddress, circuit: `${circuitIndex}`, status }, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -125,8 +109,6 @@ export const rebootSecurityBoxApi = async (ipAddress: string, options?: { statio
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/reboot`;
|
const endpoint = `${prefix}/api/ndm/ndmSecurityBox/reboot`;
|
||||||
const resp = await client.post<boolean>(endpoint, { community: 'public', ipAddress }, { signal });
|
const resp = await client.post<boolean>(endpoint, { community: 'public', ipAddress }, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,15 @@
|
|||||||
import { ndmClient, userClient, type MediaServerStatus, type Station } from '@/apis';
|
import { ndmClient, userClient, type MediaServerStatus, type SendRtpInfo, type Station } from '@/apis';
|
||||||
|
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 ?? {};
|
||||||
@@ -6,9 +17,7 @@ export const isMediaServerAliveApi = async (options?: { stationCode?: Station['c
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmServiceAvailable/mediaServer/isAlive`;
|
const endpoint = `${prefix}/api/ndm/ndmServiceAvailable/mediaServer/isAlive`;
|
||||||
const resp = await client.get<MediaServerStatus[]>(endpoint, { signal });
|
const resp = await client.get<MediaServerStatus[]>(endpoint, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,8 +27,6 @@ export const isSipServerAliveApi = async (options?: { stationCode?: Station['cod
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmServiceAvailable/sipServer/isAlive`;
|
const endpoint = `${prefix}/api/ndm/ndmServiceAvailable/sipServer/isAlive`;
|
||||||
const resp = await client.get<boolean>(endpoint, { signal });
|
const resp = await client.get<boolean>(endpoint, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (data === null) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,76 +10,65 @@ import {
|
|||||||
type PageResult,
|
type PageResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,18 +80,15 @@ export const importSwitchApi = async (file: File, options?: { stationCode?: Stat
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +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, 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 ?? {};
|
||||||
@@ -6,9 +7,7 @@ export const pageNvrPageApi = async (pageQuery: PageParams<NdmNvrPageQuery>, opt
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmNvr/page`;
|
const endpoint = `${prefix}/api/ndm/ndmNvr/page`;
|
||||||
const resp = await client.post<PageResult<NdmNvrResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmNvrResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -18,9 +17,7 @@ export const detailNvrApi = async (id: string, options?: { stationCode?: Station
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmNvr/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmNvr/detail`;
|
||||||
const resp = await client.get<NdmNvrResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmNvrResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,9 +27,7 @@ export const saveNvrApi = async (saveVO: NdmNvrSaveVO, options?: { stationCode?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
||||||
const resp = await client.post<NdmNvrResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmNvrResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,9 +37,7 @@ export const updateNvrApi = async (updateVO: NdmNvrUpdateVO, options?: { station
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
||||||
const resp = await client.put<NdmNvrResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmNvrResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,9 +47,7 @@ export const deleteNvrApi = async (ids: string[], options?: { stationCode?: Stat
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
const endpoint = `${prefix}/api/ndm/ndmNvr`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,9 +57,7 @@ export const exportNvrApi = async (pageQuery: PageParams<NdmNvrPageQuery>, optio
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmNvr/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmNvr/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,9 +69,7 @@ export const importNvrApi = async (file: File, options?: { stationCode?: Station
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,8 +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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const syncNvrChannelsApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => {
|
export const syncNvrChannelsApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => {
|
||||||
@@ -102,6 +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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|||||||
1
src/apis/request/biz/upper-ndm/index.ts
Normal file
1
src/apis/request/biz/upper-ndm/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './upper-ndm';
|
||||||
20
src/apis/request/biz/upper-ndm/upper-ndm.ts
Normal file
20
src/apis/request/biz/upper-ndm/upper-ndm.ts
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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';
|
||||||
|
|||||||
@@ -1,61 +1,62 @@
|
|||||||
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';
|
||||||
|
|
||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore/page`;
|
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore/page`;
|
||||||
const resp = await client.post<PageResult<NdmCameraIgnoreResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmCameraIgnoreResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore/detail`;
|
||||||
const resp = await client.get<NdmCameraIgnoreResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmCameraIgnoreResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
||||||
const resp = await client.post<NdmCameraIgnoreResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmCameraIgnoreResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
||||||
const resp = await client.put<NdmCameraIgnoreResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmCameraIgnoreResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
const endpoint = `${prefix}/api/ndm/ndmCameraIgnore`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
type SnapResult,
|
type SnapResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageCameraApi = async (pageQuery: PageParams<NdmCameraPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageCameraApi = async (pageQuery: PageParams<NdmCameraPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -18,9 +19,7 @@ export const pageCameraApi = async (pageQuery: PageParams<NdmCameraPageQuery>, o
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCamera/page`;
|
const endpoint = `${prefix}/api/ndm/ndmCamera/page`;
|
||||||
const resp = await client.post<PageResult<NdmCameraResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmCameraResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,9 +29,7 @@ export const detailCameraApi = async (id: string, options?: { stationCode?: Stat
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCamera/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmCamera/detail`;
|
||||||
const resp = await client.get<NdmCameraResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmCameraResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,9 +39,7 @@ export const saveCameraApi = async (saveVO: NdmCameraSaveVO, options?: { station
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCamera`;
|
const endpoint = `${prefix}/api/ndm/ndmCamera`;
|
||||||
const resp = await client.post<NdmCameraResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmCameraResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,9 +49,7 @@ export const updateCameraApi = async (updateVO: NdmCameraUpdateVO, options?: { s
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCamera`;
|
const endpoint = `${prefix}/api/ndm/ndmCamera`;
|
||||||
const resp = await client.put<NdmCameraResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmCameraResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,9 +59,7 @@ export const deleteCameraApi = async (ids: string[], options?: { stationCode?: S
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCamera`;
|
const endpoint = `${prefix}/api/ndm/ndmCamera`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -78,9 +69,7 @@ export const exportCameraApi = async (pageQuery: PageParams<NdmCameraPageQuery>,
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCamera/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmCamera/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,30 +81,24 @@ export const importCameraApi = async (file: File, options?: { stationCode?: Stat
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getCameraSnapApi = async (deviceId: string, options?: { signal?: AbortSignal }) => {
|
export const getCameraSnapApi = async (deviceId: string, options?: { signal?: AbortSignal }) => {
|
||||||
const { signal } = options ?? {};
|
const { signal } = options ?? {};
|
||||||
const endpoint = `/api/ndm/ndmCamera/getSnapByDeviceId`;
|
const endpoint = `/api/ndm/ndmCamera/getSnapByDeviceId`;
|
||||||
const resp = await ndmClient.get<SnapResult>(endpoint, { params: { deviceId }, signal });
|
const resp = await ndmClient.get<SnapResult>(endpoint, { params: { deviceId }, retRaw: true, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmCamera/syncCamera`;
|
const endpoint = `${prefix}/api/ndm/ndmCamera/syncCamera`;
|
||||||
const resp = await client.get<boolean>(endpoint, { signal });
|
const resp = await client.get<boolean>(endpoint, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
type PageResult,
|
type PageResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
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 ?? {};
|
||||||
@@ -17,9 +18,7 @@ export const pageDecoderApi = async (pageQuery: PageParams<NdmDecoderPageQuery>,
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDecoder/page`;
|
const endpoint = `${prefix}/api/ndm/ndmDecoder/page`;
|
||||||
const resp = await client.post<PageResult<NdmDecoderResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmDecoderResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +28,7 @@ export const detailDecoderApi = async (id: string, options?: { stationCode?: Sta
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDecoder/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmDecoder/detail`;
|
||||||
const resp = await client.get<NdmDecoderResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmDecoderResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,9 +38,7 @@ export const saveDecoderApi = async (saveVO: NdmDecoderSaveVO, options?: { stati
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDecoder`;
|
const endpoint = `${prefix}/api/ndm/ndmDecoder`;
|
||||||
const resp = await client.post<NdmDecoderResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmDecoderResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,9 +48,7 @@ export const updateDecoderApi = async (updateVO: NdmDecoderUpdateVO, options?: {
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDecoder`;
|
const endpoint = `${prefix}/api/ndm/ndmDecoder`;
|
||||||
const resp = await client.put<NdmDecoderResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmDecoderResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,9 +58,7 @@ export const deleteDecoderApi = async (ids: string[], options?: { stationCode?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDecoder`;
|
const endpoint = `${prefix}/api/ndm/ndmDecoder`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,9 +68,7 @@ export const exportDecoderApi = async (pageQuery: PageParams<NdmDecoderPageQuery
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmDecoder/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmDecoder/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,9 +80,7 @@ export const importDecoderApi = async (file: File, options?: { stationCode?: Sta
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,6 +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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
type PageResult,
|
type PageResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageKeyboardApi = async (pageQuery: PageParams<NdmKeyboardPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageKeyboardApi = async (pageQuery: PageParams<NdmKeyboardPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -17,9 +18,7 @@ export const pageKeyboardApi = async (pageQuery: PageParams<NdmKeyboardPageQuery
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmKeyboard/page`;
|
const endpoint = `${prefix}/api/ndm/ndmKeyboard/page`;
|
||||||
const resp = await client.post<PageResult<NdmKeyboardResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmKeyboardResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +28,7 @@ export const detailKeyboardApi = async (id: string, options?: { stationCode?: St
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmKeyboard/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmKeyboard/detail`;
|
||||||
const resp = await client.get<NdmKeyboardResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmKeyboardResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,9 +38,7 @@ export const saveKeyboardApi = async (saveVO: NdmKeyboardSaveVO, options?: { sta
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmKeyboard`;
|
const endpoint = `${prefix}/api/ndm/ndmKeyboard`;
|
||||||
const resp = await client.post<NdmKeyboardResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmKeyboardResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,9 +48,7 @@ export const updateKeyboardApi = async (updateVO: NdmKeyboardUpdateVO, options?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmKeyboard`;
|
const endpoint = `${prefix}/api/ndm/ndmKeyboard`;
|
||||||
const resp = await client.put<NdmKeyboardResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmKeyboardResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,9 +58,7 @@ export const deleteKeyboardApi = async (ids: string[], options?: { stationCode?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmKeyboard`;
|
const endpoint = `${prefix}/api/ndm/ndmKeyboard`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,9 +68,7 @@ export const exportKeyboardApi = async (pageQuery: PageParams<NdmKeyboardPageQue
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmKeyboard/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmKeyboard/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,8 +80,6 @@ export const importKeyboardApi = async (file: File, options?: { stationCode?: St
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
type PageResult,
|
type PageResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
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 ?? {};
|
||||||
@@ -17,9 +18,7 @@ export const postNdmMediaServerPage = async (pageQuery: PageParams<NdmMediaServe
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmMediaServer/page`;
|
const endpoint = `${prefix}/api/ndm/ndmMediaServer/page`;
|
||||||
const resp = await client.post<PageResult<NdmMediaServerResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmMediaServerResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +28,7 @@ export const detailMediaServerApi = async (id: string, options?: { stationCode?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmMediaServer/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmMediaServer/detail`;
|
||||||
const resp = await client.get<NdmMediaServerResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmMediaServerResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,9 +38,7 @@ export const saveMediaServerApi = async (saveVO: NdmMediaServerSaveVO, options?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmMediaServer`;
|
const endpoint = `${prefix}/api/ndm/ndmMediaServer`;
|
||||||
const resp = await client.post<NdmMediaServerResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmMediaServerResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -53,9 +48,7 @@ export const updateMediaServerApi = async (updateVO: NdmMediaServerUpdateVO, opt
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmMediaServer`;
|
const endpoint = `${prefix}/api/ndm/ndmMediaServer`;
|
||||||
const resp = await client.put<NdmMediaServerResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmMediaServerResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,9 +58,7 @@ export const deleteMediaServerApi = async (ids: string[], options?: { stationCod
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmMediaServer`;
|
const endpoint = `${prefix}/api/ndm/ndmMediaServer`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,9 +68,7 @@ export const exportMediaServerApi = async (pageQuery: PageParams<NdmMediaServerP
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmMediaServer/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmMediaServer/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,9 +80,7 @@ export const importMediaServerApi = async (file: File, options?: { stationCode?:
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,6 +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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|||||||
20
src/apis/request/biz/video/ndm-snap.ts
Normal file
20
src/apis/request/biz/video/ndm-snap.ts
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
type PageResult,
|
type PageResult,
|
||||||
type Station,
|
type Station,
|
||||||
} from '@/apis';
|
} from '@/apis';
|
||||||
|
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 ?? {};
|
||||||
@@ -17,9 +18,7 @@ export const pageVideoServerApi = async (pageQuery: PageParams<NdmVideoServerPag
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVideoServer/page`;
|
const endpoint = `${prefix}/api/ndm/ndmVideoServer/page`;
|
||||||
const resp = await client.post<PageResult<NdmVideoServerResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<NdmVideoServerResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -29,9 +28,7 @@ export const detailVideoServerApi = async (id: string, options?: { stationCode?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVideoServer/detail`;
|
const endpoint = `${prefix}/api/ndm/ndmVideoServer/detail`;
|
||||||
const resp = await client.get<NdmVideoServerResultVO>(endpoint, { params: { id }, signal });
|
const resp = await client.get<NdmVideoServerResultVO>(endpoint, { params: { id }, signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,21 +38,17 @@ export const saveVideoServerApi = async (saveVO: NdmVideoServerSaveVO, options?:
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVideoServer`;
|
const endpoint = `${prefix}/api/ndm/ndmVideoServer`;
|
||||||
const resp = await client.post<NdmVideoServerResultVO>(endpoint, saveVO, { signal });
|
const resp = await client.post<NdmVideoServerResultVO>(endpoint, saveVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateVideoServerApi = async (id: string, updateVO: NdmVideoServerUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const updateVideoServerApi = async (updateVO: NdmVideoServerUpdateVO, 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}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVideoServer`;
|
const endpoint = `${prefix}/api/ndm/ndmVideoServer`;
|
||||||
const resp = await client.put<NdmVideoServerResultVO>(endpoint, updateVO, { signal });
|
const resp = await client.put<NdmVideoServerResultVO>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,9 +58,7 @@ export const deleteVideoServerApi = async (ids: string[], options?: { stationCod
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVideoServer`;
|
const endpoint = `${prefix}/api/ndm/ndmVideoServer`;
|
||||||
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
const resp = await client.delete<boolean>(endpoint, ids, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,9 +68,7 @@ export const exportVideoServerApi = async (pageQuery: PageParams<NdmVideoServerP
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/ndm/ndmVideoServer/defaultExportByTemplate`;
|
const endpoint = `${prefix}/api/ndm/ndmVideoServer/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 });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,9 +80,7 @@ export const importVideoServerApi = async (file: File, options?: { stationCode?:
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
const resp = await client.post<ImportMsg>(endpoint, formData, { signal, upload: true });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -103,6 +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 });
|
||||||
const [err] = resp;
|
unwrapVoidResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
export * from './base';
|
||||||
export * from './biz';
|
export * from './biz';
|
||||||
export * from './system';
|
export * from './system';
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ndmClient, userClient, type DefParameterPageQuery, type DefParameterResultVO, type DefParameterUpdateVO, type PageParams, type PageResult, type Station } from '@/apis';
|
import { ndmClient, userClient, type DefParameterPageQuery, type DefParameterResultVO, type DefParameterUpdateVO, type PageParams, type PageResult, type Station } from '@/apis';
|
||||||
import type { Result } from '@/types';
|
import type { Result } from '@/types';
|
||||||
|
import { unwrapResponse } from '@/utils';
|
||||||
|
|
||||||
export const pageDefParameterApi = async (pageQuery: PageParams<DefParameterPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
export const pageDefParameterApi = async (pageQuery: PageParams<DefParameterPageQuery>, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => {
|
||||||
const { stationCode, signal } = options ?? {};
|
const { stationCode, signal } = options ?? {};
|
||||||
@@ -7,9 +8,7 @@ export const pageDefParameterApi = async (pageQuery: PageParams<DefParameterPage
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/system/defParameter/page`;
|
const endpoint = `${prefix}/api/system/defParameter/page`;
|
||||||
const resp = await client.post<PageResult<DefParameterResultVO>>(endpoint, pageQuery, { signal });
|
const resp = await client.post<PageResult<DefParameterResultVO>>(endpoint, pageQuery, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -19,8 +18,6 @@ export const updateDefParameterApi = async (updateVO: DefParameterUpdateVO, opti
|
|||||||
const prefix = stationCode ? `/${stationCode}` : '';
|
const prefix = stationCode ? `/${stationCode}` : '';
|
||||||
const endpoint = `${prefix}/api/system/defParameter`;
|
const endpoint = `${prefix}/api/system/defParameter`;
|
||||||
const resp = await client.put<Result<DefParameterResultVO>>(endpoint, updateVO, { signal });
|
const resp = await client.put<Result<DefParameterResultVO>>(endpoint, updateVO, { signal });
|
||||||
const [err, data] = resp;
|
const data = unwrapResponse(resp);
|
||||||
if (err) throw err;
|
|
||||||
if (!data) throw new Error(`${data}`);
|
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|
||||||
@@ -8,12 +8,16 @@ const props = defineProps<{
|
|||||||
memUsage?: string;
|
memUsage?: string;
|
||||||
diskUsage?: string;
|
diskUsage?: string;
|
||||||
runningTime?: string;
|
runningTime?: string;
|
||||||
|
cpuUsageLabel?: string;
|
||||||
|
memUsageLabel?: string;
|
||||||
|
diskUsageLabel?: string;
|
||||||
|
runningTimeLabel?: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { cpuUsage, memUsage, diskUsage, runningTime } = toRefs(props);
|
const { cpuUsage, memUsage, diskUsage, runningTime, cpuUsageLabel, memUsageLabel, diskUsageLabel, runningTimeLabel } = toRefs(props);
|
||||||
|
|
||||||
const showCard = computed(() => {
|
const showCard = computed(() => {
|
||||||
return Object.values(props).some((value) => !!value);
|
return Object.values({ cpuUsage, memUsage, diskUsage, runningTime }).some((refValue) => !!refValue.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
const cpuPercent = computed(() => {
|
const cpuPercent = computed(() => {
|
||||||
@@ -50,23 +54,23 @@ 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">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">内存</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">磁盘</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>系统运行时间</span>
|
<span>{{ runningTimeLabel || '运行时间' }}</span>
|
||||||
<span>{{ formattedRunningTime }}</span>
|
<span>{{ formattedRunningTime }}</span>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
|
|||||||
@@ -1,19 +1,29 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { detailDeviceApi, probeDeviceApi, type NdmDeviceResultVO, type Station } from '@/apis';
|
import { detailDeviceApi, probeDeviceApi, type LinkDescription, type NdmDeviceResultVO, type Station } from '@/apis';
|
||||||
import { DEVICE_TYPE_NAMES, tryGetDeviceType } from '@/enums';
|
import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants';
|
||||||
|
import { DEVICE_TYPE_LITERALS, DEVICE_TYPE_NAMES, tryGetDeviceType } from '@/enums';
|
||||||
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 { 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 { computed, onBeforeUnmount, ref, toRefs } from 'vue';
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { computed, inject, onBeforeUnmount, ref, toRefs } from 'vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
ndmDevice: NdmDeviceResultVO;
|
ndmDevice: NdmDeviceResultVO;
|
||||||
station: Station;
|
station: Station;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
defineSlots<{
|
||||||
|
'append-info': () => any;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const deviceStore = useDeviceStore();
|
||||||
|
const { lineDevices } = storeToRefs(deviceStore);
|
||||||
|
|
||||||
const { ndmDevice, station } = toRefs(props);
|
const { ndmDevice, station } = toRefs(props);
|
||||||
|
|
||||||
const type = computed(() => {
|
const type = computed(() => {
|
||||||
@@ -26,6 +36,44 @@ const status = computed(() => ndmDevice.value.deviceStatus);
|
|||||||
const ipAddr = computed(() => ndmDevice.value.ipAddress ?? '-');
|
const ipAddr = computed(() => ndmDevice.value.ipAddress ?? '-');
|
||||||
const gbCode = computed(() => Reflect.get(ndmDevice.value, 'gbCode') as string | undefined);
|
const gbCode = computed(() => Reflect.get(ndmDevice.value, 'gbCode') as string | undefined);
|
||||||
|
|
||||||
|
const linkDescription = computed(() => {
|
||||||
|
const result = destr<any>(ndmDevice.value.linkDescription);
|
||||||
|
if (!result) return null;
|
||||||
|
if (typeof result !== 'object') return null;
|
||||||
|
return result as LinkDescription;
|
||||||
|
});
|
||||||
|
|
||||||
|
const upperDevices = computed(() => {
|
||||||
|
const devices: NdmDeviceResultVO[] = [];
|
||||||
|
if (!linkDescription.value) return devices;
|
||||||
|
if (!linkDescription.value.upstream) return devices;
|
||||||
|
linkDescription.value.upstream.forEach((deviceStoreIndex) => {
|
||||||
|
const { stationCode, deviceType, deviceDbId } = deviceStoreIndex;
|
||||||
|
const stationDevices = lineDevices.value[stationCode];
|
||||||
|
if (!stationDevices) return;
|
||||||
|
const classified = stationDevices[deviceType];
|
||||||
|
const device = classified.find((device) => device.id === deviceDbId);
|
||||||
|
if (device) devices.push(device);
|
||||||
|
});
|
||||||
|
return devices.sort((aDevice, bDevice) => {
|
||||||
|
// 按在DEVICE_TYPE_LITERALS中的顺序排序
|
||||||
|
const aDeviceType = tryGetDeviceType(aDevice.deviceType);
|
||||||
|
const bDeviceType = tryGetDeviceType(bDevice.deviceType);
|
||||||
|
if (!aDeviceType || !bDeviceType) return 0;
|
||||||
|
const deviceTypes = Object.values(DEVICE_TYPE_LITERALS);
|
||||||
|
return deviceTypes.indexOf(aDeviceType) - deviceTypes.indexOf(bDeviceType);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取从父组件注入的 `selectDevice` 函数
|
||||||
|
const selectDeviceFn = inject(SELECT_DEVICE_FN_INJECTION_KEY);
|
||||||
|
// 跳转到上游设备
|
||||||
|
const navigateToUpperDevice = (upperDevice: NdmDeviceResultVO) => {
|
||||||
|
if (!!selectDeviceFn && !!selectDeviceFn.value) {
|
||||||
|
selectDeviceFn.value(upperDevice, station.value.code);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const canOpenMgmtPage = computed(() => {
|
const canOpenMgmtPage = computed(() => {
|
||||||
return Object.keys(ndmDevice.value).includes('manageUrl');
|
return Object.keys(ndmDevice.value).includes('manageUrl');
|
||||||
});
|
});
|
||||||
@@ -92,40 +140,49 @@ onBeforeUnmount(() => {
|
|||||||
<template>
|
<template>
|
||||||
<NCard hoverable size="small">
|
<NCard hoverable size="small">
|
||||||
<template #header>
|
<template #header>
|
||||||
<NFlex align="center">
|
<NFlex vertical>
|
||||||
<NTag v-if="status === '10'" size="small" type="success">在线</NTag>
|
<NFlex align="center">
|
||||||
<NTag v-else-if="status === '20'" size="small" type="error">离线</NTag>
|
<NTag v-if="status === '10'" size="small" type="success">在线</NTag>
|
||||||
<NTag v-else size="small" type="warning">-</NTag>
|
<NTag v-else-if="status === '20'" size="small" type="error">离线</NTag>
|
||||||
<div>{{ name }}</div>
|
<NTag v-else size="small" type="warning">-</NTag>
|
||||||
<NButton v-if="canOpenMgmtPage" ghost size="tiny" type="default" :focusable="false" @click="onClickOpenMgmtPage">管理</NButton>
|
<div>{{ name }}</div>
|
||||||
|
<NButton v-if="canOpenMgmtPage" ghost size="tiny" type="default" :focusable="false" @click="onClickOpenMgmtPage">管理</NButton>
|
||||||
|
<div style="margin-left: auto">
|
||||||
|
<NTooltip v-if="canProbe" trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<NButton size="small" quaternary circle :loading="probing" @click="() => probeDevice()">
|
||||||
|
<template #icon>
|
||||||
|
<NIcon :component="LinkIcon" />
|
||||||
|
</template>
|
||||||
|
</NButton>
|
||||||
|
</template>
|
||||||
|
<template #default>
|
||||||
|
<span>请求最新诊断</span>
|
||||||
|
</template>
|
||||||
|
</NTooltip>
|
||||||
|
<NTooltip trigger="hover">
|
||||||
|
<template #trigger>
|
||||||
|
<NButton size="small" quaternary circle :loading="loading" @click="() => detailDevice()">
|
||||||
|
<template #icon>
|
||||||
|
<NIcon :component="RotateCwIcon" />
|
||||||
|
</template>
|
||||||
|
</NButton>
|
||||||
|
</template>
|
||||||
|
<template #default>
|
||||||
|
<span>刷新设备</span>
|
||||||
|
</template>
|
||||||
|
</NTooltip>
|
||||||
|
</div>
|
||||||
|
</NFlex>
|
||||||
|
<div v-if="upperDevices.length > 0" style="font-size: 0.85rem">
|
||||||
|
<span>上游设备:</span>
|
||||||
|
<template v-for="(device, index) in upperDevices" :key="index">
|
||||||
|
<span style="text-decoration: underline; cursor: pointer" @click="() => navigateToUpperDevice(device)">{{ device.name }}</span>
|
||||||
|
<span v-if="index < upperDevices.length - 1">、</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</template>
|
</template>
|
||||||
<template #header-extra>
|
|
||||||
<NTooltip v-if="canProbe" trigger="hover">
|
|
||||||
<template #trigger>
|
|
||||||
<NButton size="small" quaternary circle :loading="probing" @click="() => probeDevice()">
|
|
||||||
<template #icon>
|
|
||||||
<NIcon :component="ApiOutlined" />
|
|
||||||
</template>
|
|
||||||
</NButton>
|
|
||||||
</template>
|
|
||||||
<template #default>
|
|
||||||
<span>请求最新诊断</span>
|
|
||||||
</template>
|
|
||||||
</NTooltip>
|
|
||||||
<NTooltip trigger="hover">
|
|
||||||
<template #trigger>
|
|
||||||
<NButton size="small" quaternary circle :loading="loading" @click="() => detailDevice()">
|
|
||||||
<template #icon>
|
|
||||||
<NIcon :component="ReloadOutlined" />
|
|
||||||
</template>
|
|
||||||
</NButton>
|
|
||||||
</template>
|
|
||||||
<template #default>
|
|
||||||
<span>刷新设备</span>
|
|
||||||
</template>
|
|
||||||
</NTooltip>
|
|
||||||
</template>
|
|
||||||
<template #default>
|
<template #default>
|
||||||
<div style="font-size: small; color: #666">
|
<div style="font-size: small; color: #666">
|
||||||
<div>
|
<div>
|
||||||
@@ -150,6 +207,9 @@ onBeforeUnmount(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template #footer>
|
||||||
|
<slot name="append-info"></slot>
|
||||||
|
</template>
|
||||||
</NCard>
|
</NCard>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,20 @@ import DeviceHeaderCard from './device-header-card.vue';
|
|||||||
import NvrDiskCard from './nvr-disk-card.vue';
|
import NvrDiskCard from './nvr-disk-card.vue';
|
||||||
import NvrRecordCard from './nvr-record-card.vue';
|
import NvrRecordCard from './nvr-record-card.vue';
|
||||||
import SecurityBoxCircuitCard from './security-box-circuit-card.vue';
|
import SecurityBoxCircuitCard from './security-box-circuit-card.vue';
|
||||||
|
import SecurityBoxCircuitLinkModal from './security-box-circuit-link-modal.vue';
|
||||||
import SecurityBoxEnvCard from './security-box-env-card.vue';
|
import SecurityBoxEnvCard from './security-box-env-card.vue';
|
||||||
import SwitchPortCard from './switch-port-card.vue';
|
import SwitchPortCard from './switch-port-card.vue';
|
||||||
|
import SwitchPortLinkModal from './switch-port-link-modal.vue';
|
||||||
|
|
||||||
export { DeviceCommonCard, DeviceHardwareCard, DeviceHeaderCard, NvrDiskCard, NvrRecordCard, SecurityBoxCircuitCard, SecurityBoxEnvCard, SwitchPortCard };
|
export {
|
||||||
|
DeviceCommonCard,
|
||||||
|
DeviceHardwareCard,
|
||||||
|
DeviceHeaderCard,
|
||||||
|
NvrDiskCard,
|
||||||
|
NvrRecordCard,
|
||||||
|
SecurityBoxCircuitCard,
|
||||||
|
SecurityBoxCircuitLinkModal,
|
||||||
|
SecurityBoxEnvCard,
|
||||||
|
SwitchPortCard,
|
||||||
|
SwitchPortLinkModal,
|
||||||
|
};
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -1,28 +1,57 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { probeDeviceApi, rebootSecurityBoxApi, turnCitcuitStatusApi, type NdmSecurityBoxCircuit, type NdmSecurityBoxResultVO, type Station } from '@/apis';
|
import {
|
||||||
|
detailDeviceApi,
|
||||||
|
probeDeviceApi,
|
||||||
|
rebootSecurityBoxApi,
|
||||||
|
turnCitcuitStatusApi,
|
||||||
|
updateDeviceApi,
|
||||||
|
type LinkDescription,
|
||||||
|
type NdmDeviceResultVO,
|
||||||
|
type NdmSecurityBoxCircuit,
|
||||||
|
type NdmSecurityBoxLinkDescription,
|
||||||
|
type NdmSecurityBoxResultVO,
|
||||||
|
type Station,
|
||||||
|
} from '@/apis';
|
||||||
|
import { SecurityBoxCircuitLinkModal } from '@/components';
|
||||||
|
import { usePermission } from '@/composables';
|
||||||
|
import { SELECT_DEVICE_FN_INJECTION_KEY } from '@/constants';
|
||||||
|
import { PERMISSION_TYPE_LITERALS } from '@/enums';
|
||||||
|
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 { NButton, NCard, NDescriptions, NDescriptionsItem, NFlex, NIcon, NPopconfirm, NPopover, NSwitch, NTag, useThemeVars, type TagProps } from 'naive-ui';
|
import { isCancel } from 'axios';
|
||||||
import { computed, ref, toRefs } from 'vue';
|
import destr from 'destr';
|
||||||
|
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 { storeToRefs } from 'pinia';
|
||||||
|
import { computed, inject, ref, toRefs } from 'vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
circuits?: NdmSecurityBoxCircuit[];
|
|
||||||
ndmDevice: NdmSecurityBoxResultVO;
|
ndmDevice: NdmSecurityBoxResultVO;
|
||||||
station: Station;
|
station: Station;
|
||||||
|
circuits?: NdmSecurityBoxCircuit[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const themeVars = useThemeVars();
|
const themeVars = useThemeVars();
|
||||||
|
|
||||||
const { circuits, ndmDevice, station } = toRefs(props);
|
const deviceStore = useDeviceStore();
|
||||||
|
const { lineDevices } = storeToRefs(deviceStore);
|
||||||
|
|
||||||
|
const settingStore = useSettingStore();
|
||||||
|
const { useLocalDB } = storeToRefs(settingStore);
|
||||||
|
|
||||||
|
const { hasPermission } = usePermission();
|
||||||
|
|
||||||
|
const { ndmDevice, station, circuits } = toRefs(props);
|
||||||
|
|
||||||
const showCard = computed(() => !!circuits.value && circuits.value.length > 0);
|
const showCard = computed(() => !!circuits.value && circuits.value.length > 0);
|
||||||
|
|
||||||
const boxCircuits = ref<NdmSecurityBoxCircuit[]>([]);
|
const localCircuits = ref<NdmSecurityBoxCircuit[]>([]);
|
||||||
|
|
||||||
watchImmediate(circuits, (newCircuits) => {
|
watchImmediate(circuits, (newCircuits) => {
|
||||||
boxCircuits.value = newCircuits?.map((circuit) => ({ ...circuit })) ?? [];
|
localCircuits.value = newCircuits?.map((circuit) => ({ ...circuit })) ?? [];
|
||||||
});
|
});
|
||||||
|
|
||||||
const getCircuitStatusTagType = (circuit: NdmSecurityBoxCircuit): TagProps['type'] => {
|
const getCircuitStatusTagType = (circuit: NdmSecurityBoxCircuit): TagProps['type'] => {
|
||||||
@@ -40,22 +69,34 @@ const getCircuitStatusClassName = (circuit: NdmSecurityBoxCircuit) => {
|
|||||||
return status === 0 ? 'circuit-off' : status === 1 ? 'circuit-on' : 'circuit-unknown';
|
return status === 0 ? 'circuit-off' : status === 1 ? 'circuit-on' : 'circuit-unknown';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const abortController = ref<AbortController>(new AbortController());
|
||||||
|
|
||||||
const { mutate: turnStatus, isPending: turning } = useMutation({
|
const { mutate: turnStatus, isPending: turning } = useMutation({
|
||||||
mutationFn: async (params: { circuitIndex: number; newStatus: boolean }) => {
|
mutationFn: async (params: { circuitIndex: number; newStatus: boolean }) => {
|
||||||
|
abortController.value.abort();
|
||||||
|
abortController.value = new AbortController();
|
||||||
|
|
||||||
|
window.$loadingBar.start();
|
||||||
|
|
||||||
const { circuitIndex, newStatus } = params;
|
const { circuitIndex, newStatus } = params;
|
||||||
if (!ndmDevice.value.ipAddress) {
|
if (!ndmDevice.value.ipAddress) {
|
||||||
throw new Error('设备IP地址不存在');
|
throw new Error('设备IP地址不存在');
|
||||||
}
|
}
|
||||||
const status = newStatus ? 1 : 0;
|
const status = newStatus ? 1 : 0;
|
||||||
await turnCitcuitStatusApi(ndmDevice.value.ipAddress, circuitIndex, status, { stationCode: station.value.code });
|
const stationCode = station.value.code;
|
||||||
await probeDeviceApi(ndmDevice.value, { stationCode: station.value.code });
|
const signal = abortController.value.signal;
|
||||||
|
await turnCitcuitStatusApi(ndmDevice.value.ipAddress, circuitIndex, status, { stationCode, signal });
|
||||||
|
await probeDeviceApi(ndmDevice.value, { stationCode, signal });
|
||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
onSuccess: (status, { circuitIndex }) => {
|
onSuccess: (status, { circuitIndex }) => {
|
||||||
const circuit = boxCircuits.value.at(circuitIndex);
|
window.$loadingBar.finish();
|
||||||
|
const circuit = localCircuits.value.at(circuitIndex);
|
||||||
if (circuit) circuit.status = status;
|
if (circuit) circuit.status = status;
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
window.$loadingBar.error();
|
||||||
|
if (isCancel(error)) return;
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const errorFeedback = parseErrorFeedback(error);
|
const errorFeedback = parseErrorFeedback(error);
|
||||||
window.$message.error(errorFeedback);
|
window.$message.error(errorFeedback);
|
||||||
@@ -64,15 +105,189 @@ const { mutate: turnStatus, isPending: turning } = useMutation({
|
|||||||
|
|
||||||
const { mutate: reboot, isPending: rebooting } = useMutation({
|
const { mutate: reboot, isPending: rebooting } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
|
abortController.value.abort();
|
||||||
|
abortController.value = new AbortController();
|
||||||
|
|
||||||
|
window.$loadingBar.start();
|
||||||
|
|
||||||
if (!ndmDevice.value.ipAddress) {
|
if (!ndmDevice.value.ipAddress) {
|
||||||
throw new Error('设备IP地址不存在');
|
throw new Error('设备IP地址不存在');
|
||||||
}
|
}
|
||||||
await rebootSecurityBoxApi(ndmDevice.value.ipAddress, { stationCode: station.value.code });
|
|
||||||
|
const stationCode = station.value.code;
|
||||||
|
const signal = abortController.value.signal;
|
||||||
|
await rebootSecurityBoxApi(ndmDevice.value.ipAddress, { stationCode, signal });
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
window.$loadingBar.finish();
|
||||||
window.$message.success('设备重启成功');
|
window.$message.success('设备重启成功');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
window.$loadingBar.error();
|
||||||
|
if (isCancel(error)) return;
|
||||||
|
console.error(error);
|
||||||
|
const errorFeedback = parseErrorFeedback(error);
|
||||||
|
window.$message.error(errorFeedback);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const upperDeviceLinkDescription = computed(() => {
|
||||||
|
const result = destr<any>(ndmDevice.value.linkDescription);
|
||||||
|
if (!result) return null;
|
||||||
|
if (typeof result !== 'object') return null;
|
||||||
|
return result as NdmSecurityBoxLinkDescription;
|
||||||
|
});
|
||||||
|
|
||||||
|
const getLowerDeviceByCircuitIndex = (circuitIndex: number) => {
|
||||||
|
if (!upperDeviceLinkDescription.value) return null;
|
||||||
|
const downstream = upperDeviceLinkDescription.value.downstream;
|
||||||
|
if (!downstream) return null;
|
||||||
|
const deviceStoreIndex = downstream[circuitIndex];
|
||||||
|
if (!deviceStoreIndex) return null;
|
||||||
|
const { stationCode, deviceType, deviceDbId } = deviceStoreIndex;
|
||||||
|
const stationDevices = lineDevices.value[stationCode];
|
||||||
|
if (!stationDevices) return null;
|
||||||
|
const devices = stationDevices[deviceType];
|
||||||
|
const lowerDevice = devices.find((device) => device.id === deviceDbId);
|
||||||
|
if (!lowerDevice) {
|
||||||
|
// 下游设备不存在时解除关联
|
||||||
|
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||||
|
const modifiedUpperLinkDescription = cloneDeep(upperDeviceLinkDescription.value);
|
||||||
|
delete modifiedUpperLinkDescription.downstream?.[circuitIndex];
|
||||||
|
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
|
||||||
|
// 不需要等待异步
|
||||||
|
const stationCode = station.value.code;
|
||||||
|
updateDeviceApi(modifiedUpperDevice, { stationCode }).then(() => {
|
||||||
|
detailDeviceApi(modifiedUpperDevice, { stationCode }).then((upperDevice) => {
|
||||||
|
if (!upperDevice) return;
|
||||||
|
deviceStore.patchDevice(stationCode, { ...upperDevice });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return lowerDevice;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取从父组件注入的selectDevice函数
|
||||||
|
const selectDeviceFn = inject(SELECT_DEVICE_FN_INJECTION_KEY);
|
||||||
|
// 跳转到下游设备
|
||||||
|
const navigateToLowerDevice = (circuitIndex: number) => {
|
||||||
|
const lowerDevice = getLowerDeviceByCircuitIndex(circuitIndex);
|
||||||
|
if (!lowerDevice) return;
|
||||||
|
if (!!selectDeviceFn && !!selectDeviceFn.value) {
|
||||||
|
selectDeviceFn.value(lowerDevice, station.value.code);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const showModal = ref(false);
|
||||||
|
const contextmenu = ref<{ x: number; y: number; circuitIndex?: number }>({ x: 0, y: 0 });
|
||||||
|
const showContextmenu = ref(false);
|
||||||
|
const contextmenuOptions = computed<DropdownOption[]>(() => [
|
||||||
|
{
|
||||||
|
label: '关联设备',
|
||||||
|
key: 'link-device',
|
||||||
|
onSelect: () => {
|
||||||
|
showContextmenu.value = false;
|
||||||
|
showModal.value = true;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '解除关联',
|
||||||
|
key: 'unlink-device',
|
||||||
|
onSelect: () => {
|
||||||
|
showContextmenu.value = false;
|
||||||
|
const circuitIndex = contextmenu.value.circuitIndex;
|
||||||
|
if (circuitIndex === undefined) return;
|
||||||
|
const lowerDevice = getLowerDeviceByCircuitIndex(circuitIndex);
|
||||||
|
if (!lowerDevice) return;
|
||||||
|
window.$dialog.warning({
|
||||||
|
title: '确认解除关联吗?',
|
||||||
|
content: `将解除【电路${circuitIndex + 1}】与【${lowerDevice.name}】的关联关系。`,
|
||||||
|
style: { width: '600px' },
|
||||||
|
contentStyle: { height: '60px' },
|
||||||
|
negativeText: '取消',
|
||||||
|
positiveText: '确认',
|
||||||
|
onNegativeClick: () => {
|
||||||
|
window.$dialog.destroyAll();
|
||||||
|
},
|
||||||
|
onPositiveClick: () => {
|
||||||
|
window.$dialog.destroyAll();
|
||||||
|
unlinkDevice({ circuitIndex, lowerDevice });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const onSelectDropdownOption = (key: string, option: DropdownOption) => {
|
||||||
|
const onSelect = option['onSelect'];
|
||||||
|
if (isFunction(onSelect)) {
|
||||||
|
onSelect();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const onContextmenu = (payload: PointerEvent, circuitIndex: number) => {
|
||||||
|
payload.stopPropagation();
|
||||||
|
payload.preventDefault();
|
||||||
|
if (!hasPermission(station.value.code, PERMISSION_TYPE_LITERALS.OPERATION)) return;
|
||||||
|
const { clientX, clientY } = payload;
|
||||||
|
contextmenu.value = { x: clientX, y: clientY, circuitIndex };
|
||||||
|
showContextmenu.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const { mutate: unlinkDevice } = useMutation({
|
||||||
|
mutationFn: async (params: { circuitIndex: number; lowerDevice: NdmDeviceResultVO }) => {
|
||||||
|
abortController.value.abort();
|
||||||
|
abortController.value = new AbortController();
|
||||||
|
|
||||||
|
window.$loadingBar.start();
|
||||||
|
|
||||||
|
const { circuitIndex, lowerDevice } = params;
|
||||||
|
|
||||||
|
if (!upperDeviceLinkDescription.value) return;
|
||||||
|
|
||||||
|
// 1.从下游设备的linkDescription的upstream字段中删除当前上游设备
|
||||||
|
const modifiedLowerDevice = cloneDeep(lowerDevice);
|
||||||
|
// 解除关联时下游设备的linkDescription一定存在
|
||||||
|
const modifiedLowerDeviceLinkDescription = destr<LinkDescription>(modifiedLowerDevice.linkDescription);
|
||||||
|
// upstream字段存在时才进行删除操作
|
||||||
|
if (modifiedLowerDeviceLinkDescription.upstream) {
|
||||||
|
const index = modifiedLowerDeviceLinkDescription.upstream.findIndex((deviceStoreIndex) => deviceStoreIndex.deviceDbId === ndmDevice.value.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
modifiedLowerDeviceLinkDescription.upstream.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription);
|
||||||
|
|
||||||
|
// 2. 修改上游设备的linkDescription的downstream字段
|
||||||
|
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||||
|
const modifiedUpperLinkDescription = cloneDeep(upperDeviceLinkDescription.value);
|
||||||
|
delete modifiedUpperLinkDescription.downstream?.[circuitIndex];
|
||||||
|
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
|
||||||
|
|
||||||
|
// 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据)
|
||||||
|
if (useLocalDB.value) {
|
||||||
|
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
|
||||||
|
}
|
||||||
|
const stationCode = station.value.code;
|
||||||
|
const signal = abortController.value.signal;
|
||||||
|
await updateDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
await updateDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
const latestUpperDevice = await detailDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
const latestLowerDevice = await detailDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
return { upperDevice: latestUpperDevice, lowerDevice: latestLowerDevice };
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
window.$loadingBar.finish();
|
||||||
|
window.$message.success('解除成功');
|
||||||
|
if (!data) return;
|
||||||
|
const { upperDevice, lowerDevice } = data;
|
||||||
|
if (!!upperDevice && !!lowerDevice) {
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...upperDevice });
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...lowerDevice });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
window.$loadingBar.error();
|
||||||
|
if (isCancel(error)) return;
|
||||||
console.error(error);
|
console.error(error);
|
||||||
const errorFeedback = parseErrorFeedback(error);
|
const errorFeedback = parseErrorFeedback(error);
|
||||||
window.$message.error(errorFeedback);
|
window.$message.error(errorFeedback);
|
||||||
@@ -94,40 +309,46 @@ const { mutate: reboot, isPending: rebooting } = useMutation({
|
|||||||
</NFlex>
|
</NFlex>
|
||||||
</template>
|
</template>
|
||||||
<template #default>
|
<template #default>
|
||||||
<div style="display: grid" :style="{ 'grid-template-columns': `repeat(${Math.min(boxCircuits.length, 4)}, 1fr)` }">
|
<div style="display: grid" :style="{ 'grid-template-columns': `repeat(${Math.min(localCircuits.length, 4)}, 1fr)` }">
|
||||||
<template v-for="(circuit, index) in boxCircuits" :key="index">
|
<template v-for="(circuit, circuitIndex) in localCircuits" :key="circuitIndex">
|
||||||
<NPopover :delay="300">
|
<NPopover :delay="300">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<NFlex justify="center" align="center" :size="0">
|
<div style="display: flex; justify-content: center; align-items: center" @contextmenu="(payload) => onContextmenu(payload, circuitIndex)">
|
||||||
<NFlex vertical class="pointer-cursor circuit" style="padding: 12px" :class="getCircuitStatusClassName(circuit)">
|
<NFlex vertical class="pointer-cursor circuit" style="padding: 12px" :class="getCircuitStatusClassName(circuit)">
|
||||||
<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>
|
||||||
</template>
|
</template>
|
||||||
</NTag>
|
</NTag>
|
||||||
<span>电路{{ index + 1 }}</span>
|
<span>电路{{ circuitIndex + 1 }}</span>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
<NFlex justify="end" align="center">
|
<NFlex justify="end" align="center">
|
||||||
<NPopconfirm :positive-text="'确认'" :negative-text="'取消'" @positive-click="() => turnStatus({ circuitIndex: index, newStatus: circuit.status !== 1 })">
|
<NPopconfirm :positive-text="'确认'" :negative-text="'取消'" @positive-click="() => turnStatus({ circuitIndex: circuitIndex, newStatus: circuit.status !== 1 })">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<NSwitch size="small" :value="circuit.status === 1" :loading="turning" />
|
<NSwitch size="small" :value="circuit.status === 1" :loading="turning" />
|
||||||
</template>
|
</template>
|
||||||
<template #default>
|
<template #default>
|
||||||
<span>确定要{{ circuit.status === 1 ? '关闭' : '开启' }}电路{{ index + 1 }}吗?</span>
|
<span>确定要{{ circuit.status === 1 ? '关闭' : '开启' }}电路{{ circuitIndex + 1 }}吗?</span>
|
||||||
</template>
|
</template>
|
||||||
</NPopconfirm>
|
</NPopconfirm>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</NFlex>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #default>
|
<template #default>
|
||||||
<NDescriptions bordered size="small" label-placement="left" :column="1">
|
<NDescriptions bordered size="small" label-placement="left" :column="1">
|
||||||
<NDescriptionsItem label="电压">{{ circuit.voltage }}V</NDescriptionsItem>
|
<NDescriptionsItem label="电压">{{ circuit.voltage }}V</NDescriptionsItem>
|
||||||
<NDescriptionsItem label="电流">{{ circuit.current }}A</NDescriptionsItem>
|
<NDescriptionsItem label="电流">{{ circuit.current }}A</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem label="关联设备">
|
||||||
|
<span v-if="getLowerDeviceByCircuitIndex(circuitIndex)" style="text-decoration: underline; cursor: pointer" @click="() => navigateToLowerDevice(circuitIndex)">
|
||||||
|
{{ getLowerDeviceByCircuitIndex(circuitIndex)?.name || '-' }}
|
||||||
|
</span>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</NDescriptionsItem>
|
||||||
</NDescriptions>
|
</NDescriptions>
|
||||||
</template>
|
</template>
|
||||||
</NPopover>
|
</NPopover>
|
||||||
@@ -135,6 +356,19 @@ const { mutate: reboot, isPending: rebooting } = useMutation({
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</NCard>
|
</NCard>
|
||||||
|
|
||||||
|
<SecurityBoxCircuitLinkModal v-model:show="showModal" :ndm-device="ndmDevice" :station="station" :circuit-index="contextmenu.circuitIndex" />
|
||||||
|
|
||||||
|
<NDropdown
|
||||||
|
placement="bottom-start"
|
||||||
|
trigger="manual"
|
||||||
|
:show="showContextmenu"
|
||||||
|
:x="contextmenu.x"
|
||||||
|
:y="contextmenu.y"
|
||||||
|
:options="contextmenuOptions"
|
||||||
|
@select="onSelectDropdownOption"
|
||||||
|
@clickoutside="() => (showContextmenu = false)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -0,0 +1,214 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { detailDeviceApi, updateDeviceApi, type NdmCameraLinkDescription, type NdmDeviceResultVO, type NdmSecurityBoxLinkDescription, type NdmSecurityBoxResultVO, type Station } from '@/apis';
|
||||||
|
import { DeviceTree } from '@/components';
|
||||||
|
import { tryGetDeviceType } from '@/enums';
|
||||||
|
import { useDeviceStore, useSettingStore } from '@/stores';
|
||||||
|
import { parseErrorFeedback } from '@/utils';
|
||||||
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
|
import { isCancel } from 'axios';
|
||||||
|
import destr from 'destr';
|
||||||
|
import { cloneDeep } from 'es-toolkit';
|
||||||
|
import { NButton, NFlex, NModal } from 'naive-ui';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { computed, ref, toRefs } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
ndmDevice: NdmSecurityBoxResultVO;
|
||||||
|
station: Station;
|
||||||
|
circuitIndex?: number;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const show = defineModel<boolean>('show', { default: false });
|
||||||
|
|
||||||
|
const deviceStore = useDeviceStore();
|
||||||
|
|
||||||
|
const settingStore = useSettingStore();
|
||||||
|
const { useLocalDB } = storeToRefs(settingStore);
|
||||||
|
|
||||||
|
const { ndmDevice, station, circuitIndex } = toRefs(props);
|
||||||
|
|
||||||
|
const upperDeviceLinkDescription = computed(() => {
|
||||||
|
const result = destr<any>(ndmDevice.value.linkDescription);
|
||||||
|
if (!result) return null;
|
||||||
|
if (typeof result !== 'object') return null;
|
||||||
|
return result as NdmSecurityBoxLinkDescription;
|
||||||
|
});
|
||||||
|
|
||||||
|
const lowerDevice = ref<NdmDeviceResultVO>();
|
||||||
|
const lowerDeviceLinkDescription = computed<NdmCameraLinkDescription | null>(() => {
|
||||||
|
if (!lowerDevice.value) return null;
|
||||||
|
const result = destr<any>(lowerDevice.value.linkDescription);
|
||||||
|
if (!result) return null;
|
||||||
|
if (typeof result !== 'object') return null;
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
const onAfterSelectDevice = (device: NdmDeviceResultVO) => {
|
||||||
|
lowerDevice.value = device;
|
||||||
|
};
|
||||||
|
|
||||||
|
const abortController = ref<AbortController>(new AbortController());
|
||||||
|
|
||||||
|
const { mutate: linkPortToDevice, isPending: linking } = useMutation({
|
||||||
|
mutationFn: async () => {
|
||||||
|
abortController.value.abort();
|
||||||
|
abortController.value = new AbortController();
|
||||||
|
|
||||||
|
window.$loadingBar.start();
|
||||||
|
|
||||||
|
const upperDeviceType = tryGetDeviceType(ndmDevice.value.deviceType);
|
||||||
|
if (!upperDeviceType) throw new Error('本设备类型未知');
|
||||||
|
const upperDeviceDbId = ndmDevice.value.id;
|
||||||
|
if (!upperDeviceDbId) throw new Error('本设备没有ID');
|
||||||
|
|
||||||
|
if (circuitIndex.value === undefined) throw new Error('该电路不存在');
|
||||||
|
|
||||||
|
if (!lowerDevice.value) throw new Error('请选择要关联的设备');
|
||||||
|
const lowerDeviceType = tryGetDeviceType(lowerDevice.value?.deviceType);
|
||||||
|
if (!lowerDeviceType) throw new Error('该设备类型未知');
|
||||||
|
const lowerDeviceDbId = lowerDevice.value?.id;
|
||||||
|
if (!lowerDeviceDbId) throw new Error('该设备没有ID');
|
||||||
|
|
||||||
|
// 0. 检查是否会导致循环关联,
|
||||||
|
if (upperDeviceDbId === lowerDeviceDbId) throw new Error('不能关联到自身');
|
||||||
|
// 以及检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备
|
||||||
|
const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => {
|
||||||
|
return deviceStoreIndex.deviceDbId === lowerDeviceDbId;
|
||||||
|
});
|
||||||
|
if (duplicated) {
|
||||||
|
const [portName] = duplicated;
|
||||||
|
throw new Error(`该设备已关联到端口${portName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 修改上游设备的linkDescription的downstream字段
|
||||||
|
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||||
|
let modifiedUpperDeviceLinkDescription: NdmSecurityBoxLinkDescription;
|
||||||
|
if (!upperDeviceLinkDescription.value) {
|
||||||
|
modifiedUpperDeviceLinkDescription = {
|
||||||
|
downstream: {
|
||||||
|
[circuitIndex.value]: {
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: lowerDeviceType,
|
||||||
|
deviceDbId: lowerDeviceDbId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
modifiedUpperDeviceLinkDescription = {
|
||||||
|
...upperDeviceLinkDescription.value,
|
||||||
|
downstream: {
|
||||||
|
...upperDeviceLinkDescription.value.downstream,
|
||||||
|
[circuitIndex.value]: {
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: lowerDeviceType,
|
||||||
|
deviceDbId: lowerDeviceDbId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperDeviceLinkDescription);
|
||||||
|
|
||||||
|
// 2. 修改下游设备的linkDescription的upstream字段
|
||||||
|
const modifiedLowerDevice = cloneDeep(lowerDevice.value);
|
||||||
|
let modifiedLowerDeviceLinkDescription: NdmCameraLinkDescription;
|
||||||
|
if (!lowerDeviceLinkDescription.value) {
|
||||||
|
modifiedLowerDeviceLinkDescription = {
|
||||||
|
upstream: [
|
||||||
|
{
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: upperDeviceType,
|
||||||
|
deviceDbId: upperDeviceDbId,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const upstream = cloneDeep(lowerDeviceLinkDescription.value.upstream);
|
||||||
|
if (!upstream) {
|
||||||
|
modifiedLowerDeviceLinkDescription = {
|
||||||
|
...lowerDeviceLinkDescription.value,
|
||||||
|
upstream: [
|
||||||
|
{
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: upperDeviceType,
|
||||||
|
deviceDbId: upperDeviceDbId,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const deviceStoreIndex = upstream.find((deviceStoreIndex) => deviceStoreIndex.deviceDbId === upperDeviceDbId);
|
||||||
|
if (!deviceStoreIndex) {
|
||||||
|
upstream.push({
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: upperDeviceType,
|
||||||
|
deviceDbId: upperDeviceDbId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
modifiedLowerDeviceLinkDescription = {
|
||||||
|
...lowerDeviceLinkDescription.value,
|
||||||
|
upstream,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription);
|
||||||
|
|
||||||
|
// 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据)
|
||||||
|
if (useLocalDB.value) {
|
||||||
|
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
|
||||||
|
}
|
||||||
|
const stationCode = station.value.code;
|
||||||
|
const signal = abortController.value.signal;
|
||||||
|
await updateDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
await updateDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
const latestUpperDevice = await detailDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
const latestLowerDevice = await detailDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
return { upperDevice: latestUpperDevice, lowerDevice: latestLowerDevice };
|
||||||
|
},
|
||||||
|
onSuccess: ({ upperDevice, lowerDevice }) => {
|
||||||
|
show.value = false;
|
||||||
|
window.$loadingBar.finish();
|
||||||
|
window.$message.success('关联成功');
|
||||||
|
if (!!upperDevice && !!lowerDevice) {
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...upperDevice });
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...lowerDevice });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
window.$loadingBar.error();
|
||||||
|
if (isCancel(error)) return;
|
||||||
|
console.error(error);
|
||||||
|
const errorFeedback = parseErrorFeedback(error);
|
||||||
|
window.$message.error(errorFeedback);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const onLink = () => {
|
||||||
|
linkPortToDevice();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCancel = () => {
|
||||||
|
abortController.value.abort();
|
||||||
|
show.value = false;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NModal v-model:show="show" preset="card" style="width: 600px; height: 600px" :content-style="{ height: '100%', overflow: 'hidden' }" @close="onCancel" @esc="onCancel">
|
||||||
|
<template #header>
|
||||||
|
<span>{{ ndmDevice.name }}</span>
|
||||||
|
<span> - </span>
|
||||||
|
<span>电路{{ circuitIndex ? circuitIndex + 1 : '-' }}</span>
|
||||||
|
<span> - </span>
|
||||||
|
<span>关联设备</span>
|
||||||
|
</template>
|
||||||
|
<template #default>
|
||||||
|
<DeviceTree :station="station" :events="['select']" :device-prefix-label="'选择'" @after-select-device="onAfterSelectDevice" />
|
||||||
|
</template>
|
||||||
|
<template #action>
|
||||||
|
<NFlex justify="end">
|
||||||
|
<NButton size="small" quaternary @click="onCancel">取消</NButton>
|
||||||
|
<NButton size="small" type="primary" :disabled="!lowerDevice" :loading="linking" @click="onLink">关联</NButton>
|
||||||
|
</NFlex>
|
||||||
|
</template>
|
||||||
|
</NModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss"></style>
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -1,16 +1,37 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NdmSwitchPortInfo } from '@/apis';
|
import { detailDeviceApi, updateDeviceApi, type LinkDescription, type NdmDeviceResultVO, type NdmSwitchLinkDescription, type NdmSwitchPortInfo, type NdmSwitchResultVO, type Station } from '@/apis';
|
||||||
|
import { SwitchPortLinkModal } from '@/components';
|
||||||
|
import { usePermission } from '@/composables';
|
||||||
|
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 { NCard, NDescriptions, NDescriptionsItem, NPopover, useThemeVars } from 'naive-ui';
|
import { useDeviceStore, useSettingStore } from '@/stores';
|
||||||
import { computed, toRefs } from 'vue';
|
import { parseErrorFeedback } from '@/utils';
|
||||||
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
|
import { isCancel } from 'axios';
|
||||||
|
import destr from 'destr';
|
||||||
|
import { cloneDeep, isFunction } from 'es-toolkit';
|
||||||
|
import { NCard, NDescriptions, NDescriptionsItem, NDropdown, NPopover, useThemeVars, type DropdownOption } from 'naive-ui';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { computed, inject, onBeforeUnmount, ref, toRefs } from 'vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
|
ndmDevice: NdmSwitchResultVO;
|
||||||
|
station: Station;
|
||||||
ports?: NdmSwitchPortInfo[];
|
ports?: NdmSwitchPortInfo[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const themeVars = useThemeVars();
|
const themeVars = useThemeVars();
|
||||||
|
|
||||||
const { ports } = toRefs(props);
|
const deviceStore = useDeviceStore();
|
||||||
|
const { lineDevices } = storeToRefs(deviceStore);
|
||||||
|
|
||||||
|
const settingStore = useSettingStore();
|
||||||
|
const { useLocalDB } = storeToRefs(settingStore);
|
||||||
|
|
||||||
|
const { hasPermission } = usePermission();
|
||||||
|
|
||||||
|
const { ndmDevice, station, ports } = toRefs(props);
|
||||||
|
|
||||||
const showCard = computed(() => !!ports.value);
|
const showCard = computed(() => !!ports.value);
|
||||||
|
|
||||||
@@ -58,6 +79,173 @@ const getPortClassName = (port: NdmSwitchPortInfo) => {
|
|||||||
}
|
}
|
||||||
return 'port-unknown';
|
return 'port-unknown';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const upperDeviceLinkDescription = computed(() => {
|
||||||
|
const result = destr<any>(ndmDevice.value.linkDescription);
|
||||||
|
if (!result) return null;
|
||||||
|
if (typeof result !== 'object') return null;
|
||||||
|
return result as NdmSwitchLinkDescription;
|
||||||
|
});
|
||||||
|
|
||||||
|
const getLowerDeviceByPort = (port: NdmSwitchPortInfo) => {
|
||||||
|
if (!upperDeviceLinkDescription.value) return null;
|
||||||
|
const downstream = upperDeviceLinkDescription.value.downstream;
|
||||||
|
if (!downstream) return null;
|
||||||
|
const deviceStoreIndex = downstream[port.portName];
|
||||||
|
if (!deviceStoreIndex) return null;
|
||||||
|
const { stationCode, deviceType, deviceDbId } = deviceStoreIndex;
|
||||||
|
const stationDevices = lineDevices.value[stationCode];
|
||||||
|
if (!stationDevices) return null;
|
||||||
|
const devices = stationDevices[deviceType];
|
||||||
|
const lowerDevice = devices.find((device) => device.id === deviceDbId);
|
||||||
|
if (!lowerDevice) {
|
||||||
|
// 下游设备不存在时解除关联
|
||||||
|
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||||
|
const modifiedUpperLinkDescription = cloneDeep(upperDeviceLinkDescription.value);
|
||||||
|
delete modifiedUpperLinkDescription.downstream?.[port.portName];
|
||||||
|
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
|
||||||
|
// 不需要等待异步
|
||||||
|
const stationCode = station.value.code;
|
||||||
|
updateDeviceApi(modifiedUpperDevice, { stationCode }).then(() => {
|
||||||
|
detailDeviceApi(modifiedUpperDevice, { stationCode }).then((upperDevice) => {
|
||||||
|
if (!upperDevice) return;
|
||||||
|
deviceStore.patchDevice(stationCode, { ...upperDevice });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return lowerDevice;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取从父组件注入的selectDevice函数
|
||||||
|
const selectDeviceFn = inject(SELECT_DEVICE_FN_INJECTION_KEY);
|
||||||
|
// 跳转到下游设备
|
||||||
|
const navigateToLowerDevice = (port: NdmSwitchPortInfo) => {
|
||||||
|
const lowerDevice = getLowerDeviceByPort(port);
|
||||||
|
if (!lowerDevice) return;
|
||||||
|
if (!!selectDeviceFn && !!selectDeviceFn.value) {
|
||||||
|
selectDeviceFn.value(lowerDevice, station.value.code);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const showModal = ref(false);
|
||||||
|
const contextmenu = ref<{ x: number; y: number; port?: NdmSwitchPortInfo }>({ x: 0, y: 0 });
|
||||||
|
const showContextmenu = ref(false);
|
||||||
|
const contextmenuOptions = computed<DropdownOption[]>(() => [
|
||||||
|
{
|
||||||
|
label: '关联设备',
|
||||||
|
key: 'link-device',
|
||||||
|
onSelect: () => {
|
||||||
|
showContextmenu.value = false;
|
||||||
|
showModal.value = true;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '解除关联',
|
||||||
|
key: 'unlink-device',
|
||||||
|
onSelect: () => {
|
||||||
|
showContextmenu.value = false;
|
||||||
|
const port = contextmenu.value.port;
|
||||||
|
if (!port) return;
|
||||||
|
const lowerDevice = getLowerDeviceByPort(port);
|
||||||
|
if (!lowerDevice) return;
|
||||||
|
window.$dialog.warning({
|
||||||
|
title: '确认解除关联吗?',
|
||||||
|
content: `将解除【${port.portName}】与【${lowerDevice.name}】的关联关系。`,
|
||||||
|
style: { width: '600px' },
|
||||||
|
contentStyle: { height: '60px' },
|
||||||
|
negativeText: '取消',
|
||||||
|
positiveText: '确认',
|
||||||
|
onNegativeClick: () => {
|
||||||
|
window.$dialog.destroyAll();
|
||||||
|
},
|
||||||
|
onPositiveClick: () => {
|
||||||
|
window.$dialog.destroyAll();
|
||||||
|
unlinkDevice({ port, lowerDevice });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const onSelectDropdownOption = (key: string, option: DropdownOption) => {
|
||||||
|
const onSelect = option['onSelect'];
|
||||||
|
if (isFunction(onSelect)) {
|
||||||
|
onSelect();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const onContextmenu = (payload: PointerEvent, port: NdmSwitchPortInfo) => {
|
||||||
|
payload.stopPropagation();
|
||||||
|
payload.preventDefault();
|
||||||
|
if (!hasPermission(station.value.code, PERMISSION_TYPE_LITERALS.OPERATION)) return;
|
||||||
|
const { clientX, clientY } = payload;
|
||||||
|
contextmenu.value = { x: clientX, y: clientY, port };
|
||||||
|
showContextmenu.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const abortController = ref<AbortController>(new AbortController());
|
||||||
|
const { mutate: unlinkDevice } = useMutation({
|
||||||
|
mutationFn: async (params: { port: NdmSwitchPortInfo; lowerDevice: NdmDeviceResultVO }) => {
|
||||||
|
abortController.value.abort();
|
||||||
|
abortController.value = new AbortController();
|
||||||
|
|
||||||
|
window.$loadingBar.start();
|
||||||
|
|
||||||
|
const { port, lowerDevice } = params;
|
||||||
|
|
||||||
|
if (!upperDeviceLinkDescription.value) return;
|
||||||
|
|
||||||
|
// 1. 从下游设备的linkDescription的upstream字段中删除当前上游设备
|
||||||
|
const modifiedLowerDevice = cloneDeep(lowerDevice);
|
||||||
|
// 解除关联时下游设备的linkDescription一定存在
|
||||||
|
const modifiedLowerDeviceLinkDescription = destr<LinkDescription>(modifiedLowerDevice.linkDescription);
|
||||||
|
// upstream字段存在时才进行删除操作
|
||||||
|
if (modifiedLowerDeviceLinkDescription.upstream) {
|
||||||
|
const index = modifiedLowerDeviceLinkDescription.upstream.findIndex((deviceStoreIndex) => deviceStoreIndex.deviceDbId === ndmDevice.value.id);
|
||||||
|
if (index !== -1) {
|
||||||
|
modifiedLowerDeviceLinkDescription.upstream.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription);
|
||||||
|
|
||||||
|
// 2. 修改上游设备的linkDescription的downstream字段
|
||||||
|
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||||
|
const modifiedUpperLinkDescription = cloneDeep(upperDeviceLinkDescription.value);
|
||||||
|
delete modifiedUpperLinkDescription.downstream?.[port.portName];
|
||||||
|
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription);
|
||||||
|
|
||||||
|
// 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据)
|
||||||
|
if (useLocalDB.value) {
|
||||||
|
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
|
||||||
|
}
|
||||||
|
const stationCode = station.value.code;
|
||||||
|
const signal = abortController.value.signal;
|
||||||
|
await updateDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
await updateDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
const latestUpperDevice = await detailDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
const latestLowerDevice = await detailDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
return { upperDevice: latestUpperDevice, lowerDevice: latestLowerDevice };
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
window.$loadingBar.finish();
|
||||||
|
window.$message.success('解除成功');
|
||||||
|
if (!data) return;
|
||||||
|
const { upperDevice, lowerDevice } = data;
|
||||||
|
if (!!upperDevice && !!lowerDevice) {
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...upperDevice });
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...lowerDevice });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
window.$loadingBar.error();
|
||||||
|
if (isCancel(error)) return;
|
||||||
|
console.error(error);
|
||||||
|
const errorFeedback = parseErrorFeedback(error);
|
||||||
|
window.$message.error(errorFeedback);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
abortController.value.abort();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -77,7 +265,12 @@ const getPortClassName = (port: NdmSwitchPortInfo) => {
|
|||||||
<NPopover :delay="300">
|
<NPopover :delay="300">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<!-- 最外层div宽度100% -->
|
<!-- 最外层div宽度100% -->
|
||||||
<div class="port" style="height: 40px; box-sizing: border-box; display: flex; cursor: pointer" :class="getPortClassName(port)">
|
<div
|
||||||
|
class="port"
|
||||||
|
style="height: 40px; box-sizing: border-box; display: flex; cursor: pointer"
|
||||||
|
:class="getPortClassName(port)"
|
||||||
|
@contextmenu="(payload) => onContextmenu(payload, port)"
|
||||||
|
>
|
||||||
<!-- 将端口号和状态指示器包裹起来 用于居中布局 -->
|
<!-- 将端口号和状态指示器包裹起来 用于居中布局 -->
|
||||||
<div style="margin: auto; display: flex; flex-direction: column; align-items: center">
|
<div style="margin: auto; display: flex; flex-direction: column; align-items: center">
|
||||||
<div style="font-size: xx-small">{{ index }}</div>
|
<div style="font-size: xx-small">{{ index }}</div>
|
||||||
@@ -89,9 +282,21 @@ const getPortClassName = (port: NdmSwitchPortInfo) => {
|
|||||||
<NDescriptions bordered size="small" label-placement="left" :column="1">
|
<NDescriptions bordered size="small" label-placement="left" :column="1">
|
||||||
<NDescriptionsItem label="端口名称">{{ port.portName }}</NDescriptionsItem>
|
<NDescriptionsItem label="端口名称">{{ port.portName }}</NDescriptionsItem>
|
||||||
<NDescriptionsItem label="状态">{{ getPortStatusValue(port) }}</NDescriptionsItem>
|
<NDescriptionsItem label="状态">{{ getPortStatusValue(port) }}</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem label="状态变更时间">{{ port.lastChangeTime.replace('days', '天') }} 前</NDescriptionsItem>
|
||||||
<NDescriptionsItem label="上行速率">{{ transformPortSpeed(port, 'in') }}</NDescriptionsItem>
|
<NDescriptionsItem label="上行速率">{{ transformPortSpeed(port, 'in') }}</NDescriptionsItem>
|
||||||
<NDescriptionsItem label="下行速率">{{ transformPortSpeed(port, 'out') }}</NDescriptionsItem>
|
<NDescriptionsItem label="下行速率">{{ transformPortSpeed(port, 'out') }}</NDescriptionsItem>
|
||||||
<NDescriptionsItem label="总速率">{{ transformPortSpeed(port, 'total') }}</NDescriptionsItem>
|
<NDescriptionsItem label="总速率">{{ transformPortSpeed(port, 'total') }}</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem v-if="!!port.opticalTemperature && port.opticalTemperature >= 0" label="光模块温度">{{ port.opticalTemperature }} ℃</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem v-if="!!port.opticalVoltage && port.opticalVoltage >= 0" label="光模块电压">{{ port.opticalVoltage }} mV</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem v-if="!!port.opticalBiasCurrent && port.opticalBiasCurrent >= 0" label="光模块偏置电流">{{ port.opticalBiasCurrent }} μA</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem v-if="!!port.opticalReceivePower && port.opticalReceivePower >= 0" label="光模块接收功率">{{ port.opticalReceivePower / 100 }} dBm</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem v-if="!!port.opticalTransmitPower && port.opticalTransmitPower >= 0" label="光模块发送功率">{{ port.opticalTransmitPower / 100 }} dBm</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem label="关联设备">
|
||||||
|
<span v-if="getLowerDeviceByPort(port)" style="text-decoration: underline; cursor: pointer" @click="() => navigateToLowerDevice(port)">
|
||||||
|
{{ getLowerDeviceByPort(port)?.name || '-' }}
|
||||||
|
</span>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</NDescriptionsItem>
|
||||||
</NDescriptions>
|
</NDescriptions>
|
||||||
</template>
|
</template>
|
||||||
</NPopover>
|
</NPopover>
|
||||||
@@ -101,6 +306,19 @@ const getPortClassName = (port: NdmSwitchPortInfo) => {
|
|||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</NCard>
|
</NCard>
|
||||||
|
|
||||||
|
<SwitchPortLinkModal v-model:show="showModal" :ndm-device="ndmDevice" :station="station" :port="contextmenu.port" />
|
||||||
|
|
||||||
|
<NDropdown
|
||||||
|
placement="bottom-start"
|
||||||
|
trigger="manual"
|
||||||
|
:show="showContextmenu"
|
||||||
|
:x="contextmenu.x"
|
||||||
|
:y="contextmenu.y"
|
||||||
|
:options="contextmenuOptions"
|
||||||
|
@select="onSelectDropdownOption"
|
||||||
|
@clickoutside="() => (showContextmenu = false)"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@@ -0,0 +1,224 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
detailDeviceApi,
|
||||||
|
updateDeviceApi,
|
||||||
|
type NdmCameraLinkDescription,
|
||||||
|
type NdmDeviceResultVO,
|
||||||
|
type NdmSwitchLinkDescription,
|
||||||
|
type NdmSwitchPortInfo,
|
||||||
|
type NdmSwitchResultVO,
|
||||||
|
type Station,
|
||||||
|
} from '@/apis';
|
||||||
|
import { DeviceTree } from '@/components';
|
||||||
|
import { tryGetDeviceType } from '@/enums';
|
||||||
|
import { useDeviceStore, useSettingStore } from '@/stores';
|
||||||
|
import { parseErrorFeedback } from '@/utils';
|
||||||
|
import { useMutation } from '@tanstack/vue-query';
|
||||||
|
import { isCancel } from 'axios';
|
||||||
|
import destr from 'destr';
|
||||||
|
import { cloneDeep } from 'es-toolkit';
|
||||||
|
import { NButton, NFlex, NModal } from 'naive-ui';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { computed, ref, toRefs } from 'vue';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
ndmDevice: NdmSwitchResultVO;
|
||||||
|
station: Station;
|
||||||
|
port?: NdmSwitchPortInfo;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const show = defineModel<boolean>('show', { default: false });
|
||||||
|
|
||||||
|
const deviceStore = useDeviceStore();
|
||||||
|
|
||||||
|
const settingStore = useSettingStore();
|
||||||
|
const { useLocalDB } = storeToRefs(settingStore);
|
||||||
|
|
||||||
|
const { ndmDevice, station, port } = toRefs(props);
|
||||||
|
|
||||||
|
const upperDeviceLinkDescription = computed(() => {
|
||||||
|
const result = destr<any>(ndmDevice.value.linkDescription);
|
||||||
|
if (!result) return null;
|
||||||
|
if (typeof result !== 'object') return null;
|
||||||
|
return result as NdmSwitchLinkDescription;
|
||||||
|
});
|
||||||
|
|
||||||
|
const lowerDevice = ref<NdmDeviceResultVO>();
|
||||||
|
const lowerDeviceLinkDescription = computed<NdmCameraLinkDescription | NdmSwitchLinkDescription | null>(() => {
|
||||||
|
if (!lowerDevice.value) return null;
|
||||||
|
const result = destr<any>(lowerDevice.value.linkDescription);
|
||||||
|
if (!result) return null;
|
||||||
|
if (typeof result !== 'object') return null;
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
const onAfterSelectDevice = (device: NdmDeviceResultVO) => {
|
||||||
|
lowerDevice.value = device;
|
||||||
|
};
|
||||||
|
|
||||||
|
const abortController = ref<AbortController>(new AbortController());
|
||||||
|
|
||||||
|
const { mutate: linkPortToDevice, isPending: linking } = useMutation({
|
||||||
|
mutationFn: async () => {
|
||||||
|
abortController.value.abort();
|
||||||
|
abortController.value = new AbortController();
|
||||||
|
|
||||||
|
window.$loadingBar.start();
|
||||||
|
|
||||||
|
const upperDeviceType = tryGetDeviceType(ndmDevice.value.deviceType);
|
||||||
|
if (!upperDeviceType) throw new Error('本设备类型未知');
|
||||||
|
const upperDeviceDbId = ndmDevice.value.id;
|
||||||
|
if (!upperDeviceDbId) throw new Error('本设备没有ID');
|
||||||
|
|
||||||
|
const { portName } = port.value ?? {};
|
||||||
|
if (!portName) throw new Error('该端口没有名称');
|
||||||
|
|
||||||
|
if (!lowerDevice.value) throw new Error('请选择要关联的设备');
|
||||||
|
const lowerDeviceType = tryGetDeviceType(lowerDevice.value?.deviceType);
|
||||||
|
if (!lowerDeviceType) throw new Error('该设备类型未知');
|
||||||
|
const lowerDeviceDbId = lowerDevice.value?.id;
|
||||||
|
if (!lowerDeviceDbId) throw new Error('该设备没有ID');
|
||||||
|
|
||||||
|
// 0. 检查是否会导致循环关联,
|
||||||
|
if (upperDeviceDbId === lowerDeviceDbId) throw new Error('不能关联到自身');
|
||||||
|
// 以及检查上游设备的linkDescription的downstream字段是否存在某个端口已经关联下游设备
|
||||||
|
const duplicated = Object.entries(upperDeviceLinkDescription.value?.downstream ?? {}).find(([, deviceStoreIndex]) => {
|
||||||
|
return deviceStoreIndex.deviceDbId === lowerDeviceDbId;
|
||||||
|
});
|
||||||
|
if (duplicated) {
|
||||||
|
const [portName] = duplicated;
|
||||||
|
throw new Error(`该设备已关联到端口${portName}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1. 修改上游设备的linkDescription的downstream字段
|
||||||
|
const modifiedUpperDevice = cloneDeep(ndmDevice.value);
|
||||||
|
let modifiedUpperDeviceLinkDescription: NdmSwitchLinkDescription;
|
||||||
|
if (!upperDeviceLinkDescription.value) {
|
||||||
|
modifiedUpperDeviceLinkDescription = {
|
||||||
|
downstream: {
|
||||||
|
[portName]: {
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: lowerDeviceType,
|
||||||
|
deviceDbId: lowerDeviceDbId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
modifiedUpperDeviceLinkDescription = {
|
||||||
|
...upperDeviceLinkDescription.value,
|
||||||
|
downstream: {
|
||||||
|
...upperDeviceLinkDescription.value.downstream,
|
||||||
|
[portName]: {
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: lowerDeviceType,
|
||||||
|
deviceDbId: lowerDeviceDbId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperDeviceLinkDescription);
|
||||||
|
|
||||||
|
// 2. 修改下游设备的linkDescription的upstream字段
|
||||||
|
const modifiedLowerDevice = cloneDeep(lowerDevice.value);
|
||||||
|
let modifiedLowerDeviceLinkDescription: NdmSwitchLinkDescription | NdmCameraLinkDescription;
|
||||||
|
if (!lowerDeviceLinkDescription.value) {
|
||||||
|
modifiedLowerDeviceLinkDescription = {
|
||||||
|
upstream: [
|
||||||
|
{
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: upperDeviceType,
|
||||||
|
deviceDbId: upperDeviceDbId,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const upstream = cloneDeep(lowerDeviceLinkDescription.value.upstream);
|
||||||
|
if (!upstream) {
|
||||||
|
modifiedLowerDeviceLinkDescription = {
|
||||||
|
...lowerDeviceLinkDescription.value,
|
||||||
|
upstream: [
|
||||||
|
{
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: upperDeviceType,
|
||||||
|
deviceDbId: upperDeviceDbId,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const deviceStoreIndex = upstream.find((deviceStoreIndex) => deviceStoreIndex.deviceDbId === upperDeviceDbId);
|
||||||
|
if (!deviceStoreIndex) {
|
||||||
|
upstream.push({
|
||||||
|
stationCode: station.value.code,
|
||||||
|
deviceType: upperDeviceType,
|
||||||
|
deviceDbId: upperDeviceDbId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
modifiedLowerDeviceLinkDescription = {
|
||||||
|
...lowerDeviceLinkDescription.value,
|
||||||
|
upstream,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription);
|
||||||
|
|
||||||
|
// 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据)
|
||||||
|
if (useLocalDB.value) {
|
||||||
|
return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice };
|
||||||
|
}
|
||||||
|
const stationCode = station.value.code;
|
||||||
|
const signal = abortController.value.signal;
|
||||||
|
await updateDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
await updateDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
const latestUpperDevice = await detailDeviceApi(modifiedUpperDevice, { stationCode, signal });
|
||||||
|
const latestLowerDevice = await detailDeviceApi(modifiedLowerDevice, { stationCode, signal });
|
||||||
|
return { upperDevice: latestUpperDevice, lowerDevice: latestLowerDevice };
|
||||||
|
},
|
||||||
|
onSuccess: ({ upperDevice, lowerDevice }) => {
|
||||||
|
show.value = false;
|
||||||
|
window.$loadingBar.finish();
|
||||||
|
window.$message.success('关联成功');
|
||||||
|
if (!!upperDevice && !!lowerDevice) {
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...upperDevice });
|
||||||
|
deviceStore.patchDevice(station.value.code, { ...lowerDevice });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
window.$loadingBar.error();
|
||||||
|
if (isCancel(error)) return;
|
||||||
|
console.error(error);
|
||||||
|
const errorFeedback = parseErrorFeedback(error);
|
||||||
|
window.$message.error(errorFeedback);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const onLink = () => {
|
||||||
|
linkPortToDevice();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCancel = () => {
|
||||||
|
abortController.value.abort();
|
||||||
|
show.value = false;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NModal v-model:show="show" preset="card" style="width: 600px; height: 600px" :content-style="{ height: '100%', overflow: 'hidden' }" @close="onCancel" @esc="onCancel">
|
||||||
|
<template #header>
|
||||||
|
<span>{{ ndmDevice.name }}</span>
|
||||||
|
<span> - </span>
|
||||||
|
<span>{{ port?.portName }}</span>
|
||||||
|
<span> - </span>
|
||||||
|
<span>关联设备</span>
|
||||||
|
</template>
|
||||||
|
<template #default>
|
||||||
|
<DeviceTree :station="station" :events="['select']" :device-prefix-label="'选择'" @after-select-device="onAfterSelectDevice" />
|
||||||
|
</template>
|
||||||
|
<template #action>
|
||||||
|
<NFlex justify="end">
|
||||||
|
<NButton size="small" quaternary @click="onCancel">取消</NButton>
|
||||||
|
<NButton size="small" type="primary" :disabled="!lowerDevice" :loading="linking" @click="onLink">关联</NButton>
|
||||||
|
</NFlex>
|
||||||
|
</template>
|
||||||
|
</NModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="ts"></style>
|
||||||
@@ -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,23 +18,25 @@ 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);
|
||||||
|
|
||||||
const showPageHeader = computed(() => {
|
const showPageHeader = computed(() => {
|
||||||
return !!route.query['from'];
|
return !!route.query['fromPage'];
|
||||||
});
|
});
|
||||||
const onBack = () => {
|
const onBack = () => {
|
||||||
router.push({ path: `${route.query['from']}` });
|
router.push({ path: `${route.query['fromPage']}` });
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeTabName = ref('当前诊断');
|
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>
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const deviceIdPattern = /^\d{4}01\d{4}$/;
|
const deviceIdPattern = /^\d{4}01\d{4}$/;
|
||||||
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
||||||
|
|
||||||
|
// 如果没有修改设备ID,则不做ID唯一性校验
|
||||||
|
if (deviceId === ndmDevice.value.deviceId) return;
|
||||||
|
|
||||||
validatorAbortController.value.abort();
|
validatorAbortController.value.abort();
|
||||||
validatorAbortController.value = new AbortController();
|
validatorAbortController.value = new AbortController();
|
||||||
|
|
||||||
@@ -69,8 +72,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const { mutate: updateDevice, isPending: loading } = useMutation({
|
const { mutate: updateDevice, isPending: loading } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
await formInst.value?.validate().catch(() => {
|
await formInst.value?.validate().catch(() => {
|
||||||
window.$message.error('表单验证失败');
|
throw new Error('表单校验失败');
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
abortController.value.abort();
|
abortController.value.abort();
|
||||||
@@ -85,6 +87,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({
|
|||||||
onSuccess: (newDevice) => {
|
onSuccess: (newDevice) => {
|
||||||
localDevice.value = { ...newDevice };
|
localDevice.value = { ...newDevice };
|
||||||
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
||||||
|
window.$message.success('更新成功');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
if (isCancel(error)) return;
|
if (isCancel(error)) return;
|
||||||
@@ -136,9 +139,6 @@ onBeforeUnmount(() => {
|
|||||||
<NFormItem label-placement="left" label="设备描述">
|
<NFormItem label-placement="left" label="设备描述">
|
||||||
<NInput v-model:value="localDevice.description" />
|
<NInput v-model:value="localDevice.description" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label-placement="left" label="上游设备">
|
|
||||||
<NInput v-model:value="localDevice.linkDescription" />
|
|
||||||
</NFormItem>
|
|
||||||
</NForm>
|
</NForm>
|
||||||
</template>
|
</template>
|
||||||
<template #action>
|
<template #action>
|
||||||
|
|||||||
@@ -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,23 +18,25 @@ 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);
|
||||||
|
|
||||||
const showPageHeader = computed(() => {
|
const showPageHeader = computed(() => {
|
||||||
return !!route.query['from'];
|
return !!route.query['fromPage'];
|
||||||
});
|
});
|
||||||
const onBack = () => {
|
const onBack = () => {
|
||||||
router.push({ path: `${route.query['from']}` });
|
router.push({ path: `${route.query['fromPage']}` });
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeTabName = ref('当前诊断');
|
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>
|
||||||
|
|||||||
@@ -1,16 +1,118 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
const CAMERA_TYPES = {
|
||||||
|
'001': '模拟彩色云台摄像机',
|
||||||
|
'002': '模拟彩色半球摄像机',
|
||||||
|
'003': '模拟彩色固定摄像机',
|
||||||
|
'004': '数字高清云台摄像机',
|
||||||
|
'005': '数字高清半球摄像机',
|
||||||
|
'006': '数字高清固定摄像机',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
type CameraType = keyof typeof CAMERA_TYPES;
|
||||||
|
|
||||||
|
const isCameraTypeCode = (code: string): code is CameraType => {
|
||||||
|
return code in CAMERA_TYPES;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { NdmCameraResultVO, Station } from '@/apis';
|
import type { NdmCameraResultVO, Station } from '@/apis';
|
||||||
import { DeviceCommonCard, DeviceHeaderCard } from '@/components';
|
import { DeviceCommonCard, DeviceHeaderCard } from '@/components';
|
||||||
import { NFlex } from 'naive-ui';
|
import { useSettingStore } from '@/stores';
|
||||||
import { computed, toRefs } from 'vue';
|
import { useQuery, useQueryClient } from '@tanstack/vue-query';
|
||||||
|
import axios from 'axios';
|
||||||
|
import { NDescriptions, NDescriptionsItem, NFlex } from 'naive-ui';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { computed, toRefs, watch } from 'vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
ndmDevice: NdmCameraResultVO;
|
ndmDevice: NdmCameraResultVO;
|
||||||
station: Station;
|
station: Station;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const settingStore = useSettingStore();
|
||||||
|
const { activeRequests } = storeToRefs(settingStore);
|
||||||
|
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const { ndmDevice, station } = toRefs(props);
|
const { ndmDevice, station } = toRefs(props);
|
||||||
|
|
||||||
|
const cameraType = computed(() => {
|
||||||
|
const gbCode = ndmDevice.value.gbCode;
|
||||||
|
if (!gbCode) return '-';
|
||||||
|
const cameraTypeCode = gbCode.slice(11, 14);
|
||||||
|
if (!isCameraTypeCode(cameraTypeCode)) return '-';
|
||||||
|
return CAMERA_TYPES[cameraTypeCode];
|
||||||
|
});
|
||||||
|
|
||||||
|
const QUERY_KEY = 'camera-installation-area-query';
|
||||||
|
|
||||||
|
const { data: installationArea } = useQuery({
|
||||||
|
queryKey: computed(() => [QUERY_KEY, ndmDevice.value.gbCode, station.value.code]),
|
||||||
|
enabled: computed(() => activeRequests.value),
|
||||||
|
gcTime: 0,
|
||||||
|
queryFn: async ({ signal }) => {
|
||||||
|
const UNKNOWN_NAME = '-';
|
||||||
|
|
||||||
|
const gbCode = ndmDevice.value.gbCode;
|
||||||
|
if (!gbCode) return UNKNOWN_NAME;
|
||||||
|
|
||||||
|
const MINIO_PREFIX = `/minio`;
|
||||||
|
const CDN_VIMP_CODES_PREFIX = `${MINIO_PREFIX}/cdn/vimp/codes`;
|
||||||
|
const CODE_STATIONS_JSON_PATH = `${CDN_VIMP_CODES_PREFIX}/codeStations.json`;
|
||||||
|
const CODE_STATION_AREAS_JSON_PATH = `${CDN_VIMP_CODES_PREFIX}/codeStationAreas.json`;
|
||||||
|
const CODE_PARKING_AREAS_JSON_PATH = `${CDN_VIMP_CODES_PREFIX}/codeParkingAreas.json`;
|
||||||
|
const CODE_OCC_AREAS_JSON_PATH = `${CDN_VIMP_CODES_PREFIX}/codeOccAreas.json`;
|
||||||
|
|
||||||
|
// minio中的编码表结构
|
||||||
|
type Unit = { name: string; type: 'train' | 'station' | 'parking' | 'occ' };
|
||||||
|
type Area = { code: string; name: string; subs: Array<{ code: string; name: string }> };
|
||||||
|
|
||||||
|
const { data: unitCodes } = await axios.get<Record<string, Unit>>(CODE_STATIONS_JSON_PATH, { signal });
|
||||||
|
|
||||||
|
// 根据国标编码的前6位匹配minio中的编码表
|
||||||
|
const unitCode = gbCode.slice(0, 6);
|
||||||
|
const unit = unitCodes[unitCode];
|
||||||
|
if (!unit) return UNKNOWN_NAME;
|
||||||
|
// 获取编码表中的线路/单位类型
|
||||||
|
const unitType = unit.type;
|
||||||
|
// 国标编码的第7位到第8位为1级区域编码
|
||||||
|
const tier1AreaCode = gbCode.slice(6, 8);
|
||||||
|
// 国标编码的第9位到第11位为2级区域编码
|
||||||
|
const tier2AreaCode = gbCode.slice(8, 11);
|
||||||
|
|
||||||
|
if (unitType === 'train') {
|
||||||
|
return unit.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const areaJsonPaths: Record<string, string> = {
|
||||||
|
station: CODE_STATION_AREAS_JSON_PATH,
|
||||||
|
parking: CODE_PARKING_AREAS_JSON_PATH,
|
||||||
|
occ: CODE_OCC_AREAS_JSON_PATH,
|
||||||
|
};
|
||||||
|
|
||||||
|
const jsonPath = areaJsonPaths[unitType];
|
||||||
|
if (!jsonPath) return UNKNOWN_NAME;
|
||||||
|
|
||||||
|
// 获取1级区域
|
||||||
|
const { data: areaCodes } = await axios.get<Area[]>(jsonPath, { signal });
|
||||||
|
const tier1Area = areaCodes.find((area) => area.code === tier1AreaCode);
|
||||||
|
if (!tier1Area) return UNKNOWN_NAME;
|
||||||
|
|
||||||
|
// 获取2级区域
|
||||||
|
const tier2Area = tier1Area.subs.find((area) => area.code === `${tier1AreaCode}${tier2AreaCode}`);
|
||||||
|
if (!tier2Area) return UNKNOWN_NAME;
|
||||||
|
|
||||||
|
// 拼接1级和2级区域名称
|
||||||
|
return `${tier1Area.name}-${tier2Area.name}`;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
watch(activeRequests, (active) => {
|
||||||
|
if (!active) {
|
||||||
|
queryClient.cancelQueries({ queryKey: [QUERY_KEY] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const commonInfo = computed(() => {
|
const commonInfo = computed(() => {
|
||||||
const {
|
const {
|
||||||
createdTime,
|
createdTime,
|
||||||
@@ -44,7 +146,14 @@ const commonInfo = computed(() => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NFlex vertical>
|
<NFlex vertical>
|
||||||
<DeviceHeaderCard :ndm-device="ndmDevice" :station="station" />
|
<DeviceHeaderCard :ndm-device="ndmDevice" :station="station">
|
||||||
|
<template #append-info>
|
||||||
|
<NDescriptions bordered size="small" label-placement="left" :columns="1" style="width: 60%; min-width: 400px">
|
||||||
|
<NDescriptionsItem label="摄像机类型" :span="1">{{ cameraType }}</NDescriptionsItem>
|
||||||
|
<NDescriptionsItem label="建议安装区域" :span="1">{{ installationArea ?? '-' }}</NDescriptionsItem>
|
||||||
|
</NDescriptions>
|
||||||
|
</template>
|
||||||
|
</DeviceHeaderCard>
|
||||||
<DeviceCommonCard :common-info="commonInfo" />
|
<DeviceCommonCard :common-info="commonInfo" />
|
||||||
</NFlex>
|
</NFlex>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const deviceIdPattern = /^\d{4}06\d{4}$/;
|
const deviceIdPattern = /^\d{4}06\d{4}$/;
|
||||||
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
||||||
|
|
||||||
|
// 如果没有修改设备ID,则不做ID唯一性校验
|
||||||
|
if (deviceId === ndmDevice.value.deviceId) return;
|
||||||
|
|
||||||
validatorAbortController.value.abort();
|
validatorAbortController.value.abort();
|
||||||
validatorAbortController.value = new AbortController();
|
validatorAbortController.value = new AbortController();
|
||||||
|
|
||||||
@@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const { mutate: updateDevice, isPending: loading } = useMutation({
|
const { mutate: updateDevice, isPending: loading } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
await formInst.value?.validate().catch(() => {
|
await formInst.value?.validate().catch(() => {
|
||||||
window.$message.error('表单验证失败');
|
throw new Error('表单校验失败');
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
abortController.value.abort();
|
abortController.value.abort();
|
||||||
@@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({
|
|||||||
onSuccess: (newDevice) => {
|
onSuccess: (newDevice) => {
|
||||||
localDevice.value = { ...newDevice };
|
localDevice.value = { ...newDevice };
|
||||||
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
||||||
|
window.$message.success('更新成功');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
if (isCancel(error)) return;
|
if (isCancel(error)) return;
|
||||||
@@ -117,9 +120,6 @@ onBeforeUnmount(() => {
|
|||||||
<NFormItem label-placement="left" label="设备描述">
|
<NFormItem label-placement="left" label="设备描述">
|
||||||
<NInput v-model:value="localDevice.description" />
|
<NInput v-model:value="localDevice.description" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label-placement="left" label="上游设备">
|
|
||||||
<NInput v-model:value="localDevice.linkDescription" />
|
|
||||||
</NFormItem>
|
|
||||||
</NForm>
|
</NForm>
|
||||||
</template>
|
</template>
|
||||||
<template #action>
|
<template #action>
|
||||||
|
|||||||
@@ -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,23 +18,25 @@ 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);
|
||||||
|
|
||||||
const showPageHeader = computed(() => {
|
const showPageHeader = computed(() => {
|
||||||
return !!route.query['from'];
|
return !!route.query['fromPage'];
|
||||||
});
|
});
|
||||||
const onBack = () => {
|
const onBack = () => {
|
||||||
router.push({ path: `${route.query['from']}` });
|
router.push({ path: `${route.query['fromPage']}` });
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeTabName = ref('当前诊断');
|
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>
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const deviceIdPattern = /^\d{4}07\d{4}$/;
|
const deviceIdPattern = /^\d{4}07\d{4}$/;
|
||||||
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
||||||
|
|
||||||
|
// 如果没有修改设备ID,则不做ID唯一性校验
|
||||||
|
if (deviceId === ndmDevice.value.deviceId) return;
|
||||||
|
|
||||||
validatorAbortController.value.abort();
|
validatorAbortController.value.abort();
|
||||||
validatorAbortController.value = new AbortController();
|
validatorAbortController.value = new AbortController();
|
||||||
|
|
||||||
@@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const { mutate: updateDevice, isPending: loading } = useMutation({
|
const { mutate: updateDevice, isPending: loading } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
await formInst.value?.validate().catch(() => {
|
await formInst.value?.validate().catch(() => {
|
||||||
window.$message.error('表单验证失败');
|
throw new Error('表单校验失败');
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
abortController.value.abort();
|
abortController.value.abort();
|
||||||
@@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({
|
|||||||
onSuccess: (newDevice) => {
|
onSuccess: (newDevice) => {
|
||||||
localDevice.value = { ...newDevice };
|
localDevice.value = { ...newDevice };
|
||||||
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
||||||
|
window.$message.success('更新成功');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
if (isCancel(error)) return;
|
if (isCancel(error)) return;
|
||||||
@@ -138,9 +141,6 @@ onBeforeUnmount(() => {
|
|||||||
<NFormItem label-placement="left" label="设备描述">
|
<NFormItem label-placement="left" label="设备描述">
|
||||||
<NInput v-model:value="localDevice.description" />
|
<NInput v-model:value="localDevice.description" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label-placement="left" label="上游设备">
|
|
||||||
<NInput v-model:value="localDevice.linkDescription" />
|
|
||||||
</NFormItem>
|
|
||||||
</NForm>
|
</NForm>
|
||||||
</template>
|
</template>
|
||||||
<template #action>
|
<template #action>
|
||||||
|
|||||||
@@ -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,23 +18,25 @@ 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);
|
||||||
|
|
||||||
const showPageHeader = computed(() => {
|
const showPageHeader = computed(() => {
|
||||||
return !!route.query['from'];
|
return !!route.query['fromPage'];
|
||||||
});
|
});
|
||||||
const onBack = () => {
|
const onBack = () => {
|
||||||
router.push({ path: `${route.query['from']}` });
|
router.push({ path: `${route.query['fromPage']}` });
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeTabName = ref('当前诊断');
|
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>
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const deviceIdPattern = /^\d{4}08\d{4}$/;
|
const deviceIdPattern = /^\d{4}08\d{4}$/;
|
||||||
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
if (!deviceIdPattern.test(deviceId)) throw new Error('设备ID不符合规范');
|
||||||
|
|
||||||
|
// 如果没有修改设备ID,则不做ID唯一性校验
|
||||||
|
if (deviceId === ndmDevice.value.deviceId) return;
|
||||||
|
|
||||||
validatorAbortController.value.abort();
|
validatorAbortController.value.abort();
|
||||||
validatorAbortController.value = new AbortController();
|
validatorAbortController.value = new AbortController();
|
||||||
|
|
||||||
@@ -68,8 +71,7 @@ const { mutateAsync: validateDeviceIdDuplicated } = useMutation({
|
|||||||
const { mutate: updateDevice, isPending: loading } = useMutation({
|
const { mutate: updateDevice, isPending: loading } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
await formInst.value?.validate().catch(() => {
|
await formInst.value?.validate().catch(() => {
|
||||||
window.$message.error('表单验证失败');
|
throw new Error('表单校验失败');
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
abortController.value.abort();
|
abortController.value.abort();
|
||||||
@@ -84,6 +86,7 @@ const { mutate: updateDevice, isPending: loading } = useMutation({
|
|||||||
onSuccess: (newDevice) => {
|
onSuccess: (newDevice) => {
|
||||||
localDevice.value = { ...newDevice };
|
localDevice.value = { ...newDevice };
|
||||||
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
deviceStore.patchDevice(station.value.code, { ...newDevice });
|
||||||
|
window.$message.success('更新成功');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
if (isCancel(error)) return;
|
if (isCancel(error)) return;
|
||||||
@@ -126,9 +129,6 @@ onBeforeUnmount(() => {
|
|||||||
<NFormItem label-placement="left" label="设备描述">
|
<NFormItem label-placement="left" label="设备描述">
|
||||||
<NInput v-model:value="localDevice.description" />
|
<NInput v-model:value="localDevice.description" />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem label-placement="left" label="上游设备">
|
|
||||||
<NInput v-model:value="localDevice.linkDescription" />
|
|
||||||
</NFormItem>
|
|
||||||
</NForm>
|
</NForm>
|
||||||
</template>
|
</template>
|
||||||
<template #action>
|
<template #action>
|
||||||
|
|||||||
@@ -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,23 +18,25 @@ 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);
|
||||||
|
|
||||||
const showPageHeader = computed(() => {
|
const showPageHeader = computed(() => {
|
||||||
return !!route.query['from'];
|
return !!route.query['fromPage'];
|
||||||
});
|
});
|
||||||
const onBack = () => {
|
const onBack = () => {
|
||||||
router.push({ path: `${route.query['from']}` });
|
router.push({ path: `${route.query['fromPage']}` });
|
||||||
};
|
};
|
||||||
|
|
||||||
const activeTabName = ref('当前诊断');
|
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>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user