diff --git a/.env.development b/.env.development index 3f2a973..368025f 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,5 @@ # 页面标题 -VITE_APP_TITLE = 招商车研AI测评机器人模拟测试平台 +VITE_APP_TITLE = 招商车研机器人智能测试管理系统 # 开发环境配置 VITE_APP_ENV = 'development' @@ -7,13 +7,8 @@ VITE_APP_ENV = 'development' # 招商车研物联网平台/开发环境 VITE_APP_BASE_API = '/dev-api' -VITE_API_URL = http://192.168.0.222:13080 -VITE_WS_URL = ws://192.168.0.222:13080/ws - -# explanation +VITE_API_URL = http://192.168.0.222:14080 +VITE_WS_URL = ws://192.168.0.222:14080/ws +VITE_PORT = 5174 VITE_INSPECTION_TYPE = "inspection" -VITE_INSPECTION_ARM_DEVICE_ID = "huayan_arm" -VITE_INSPECTION_AGV_DEVICE_ID = "src1100" -VITE_AUDIO_SERVER_URL = "ws://192.168.0.222:13080/ws/audio" -VITE_SPEAKER_DEVICE_ID = "spk1" -VITE_MIC_DEVICE_ID = "mic1" \ No newline at end of file +VITE_MINIO_URL = "http://192.168.28.10:9000/cmvr-iot/" diff --git a/.env.production b/.env.production index 4c5aa50..6b82b87 100644 --- a/.env.production +++ b/.env.production @@ -1,5 +1,5 @@ # 页面标题 -VITE_APP_TITLE = 智能座舱测评AI机器人 +VITE_APP_TITLE = 招商车研机器人智能测试管理系统 # 生产环境配置 VITE_APP_ENV = 'production' @@ -10,11 +10,8 @@ VITE_APP_BASE_API = '/prod-api' # 是否在打包时开启压缩,支持 gzip 和 brotli VITE_BUILD_COMPRESS = gzip -#node-red 服务地址 VITE_NODE_RED_URL = 'http://10.148.108.59:13080' - VITE_API_URL = http://192.168.28.10:13080 VITE_WS_URL = ws://192.168.0.201:13080/ws - -# explanation -VITE_INSPECTION_TYPE = "inspection" \ No newline at end of file +VITE_INSPECTION_TYPE = "inspection" +VITE_MINIO_URL = "http://192.168.28.10:9000/cmvr-iot/" diff --git a/.env.staging b/.env.staging index 66d8d56..bef0d90 100644 --- a/.env.staging +++ b/.env.staging @@ -1,13 +1,16 @@ # 页面标题 -VITE_APP_TITLE = 招商车研物联网平台管理系统 +VITE_APP_TITLE = 招商车研机器人智能测试管理系统 # 生产环境配置 VITE_APP_ENV = 'staging' -# 招商车研物联网平台管理系统/生产环境 +# 招商车研物联网平台/测试环境 VITE_APP_BASE_API = '/stage-api' # 是否在打包时开启压缩,支持 gzip 和 brotli VITE_BUILD_COMPRESS = gzip + VITE_API_URL = http://10.148.121.100:13080 -VITE_WS_URL = ws://192.168.0.201:13080/ws \ No newline at end of file +VITE_WS_URL = ws://192.168.0.201:13080/ws +VITE_INSPECTION_TYPE = "inspection" +VITE_MINIO_URL = "http://192.168.28.10:9000/cmvr-iot/" diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..fbcab77 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: http://doc.ruoyi.vip/ruoyi-vue/other/donate.html diff --git a/.gitignore b/.gitignore index 57a04df..dc89b16 100644 --- a/.gitignore +++ b/.gitignore @@ -18,9 +18,8 @@ selenium-debug.log *.njsproj *.sln *.local -.history package-lock.json yarn.lock -bin/ -pnpm-lock.yaml + +.history diff --git a/README.md b/README.md index 5e715c1..107a327 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,102 @@ +# CMVR IoT 管理控制台 -## 前端运行 +招商车研物联网平台 Vue 3 管理端。项目以 RuoYi-Vue3 3.9.2 为新版基础框架,完整迁移原 `cmvr-iot-ui` 的业务页面、API、机器人模型和运行配置,并连接 `RuoYi-Vue-master` 中的 Spring Boot 4 后端。 + +旧前端仅作为迁移来源,不参与本项目构建。 + +## 功能范围 + +- 系统管理:用户、角色、部门、岗位、菜单、字典、参数、通知和文件。 +- 系统监控:在线用户、操作日志、登录日志、缓存、服务、Quartz 和 Druid。 +- 设备管理:设备注册、终端、机器人、相机、机械臂、灵巧手、机器人头部、麦克风、扬声器和电机。 +- 测试平台:测试项目、任务配置、任务编排、检测项、任务实例和执行流程。 +- 智能巡检:机器人、地图、点位、任务、执行实例、巡检结果、告警和驾驶舱。 +- 交互评价:语音交互、触控交互、评价指标、方案、项目和语料。 +- 智能座舱:车机界面、车辆配置、功能配置、流程编辑和执行评价。 +- 语料与媒体:语料管理、音频上传、图片预览、视频播放和 WebSocket 实时消息。 +- 开发工具:代码生成、表单构建和 Knife4j 接口文档。 + +## 技术栈 + +| 组件 | 版本 | +| --- | --- | +| Vue | 3.5.26 | +| Vite | 6.4.1 | +| Element Plus | 2.13.1 | +| Pinia | 3.0.4 | +| Vue Router | 4.6.4 | +| 可视化 | ECharts、Vue Flow、Three.js、Monaco Editor、XGPlayer | + +## 环境要求 + +- Node.js 20 LTS +- pnpm 10 +- 后端 `RuoYi-Vue-master/cmvr-iot-admin` + +## 开发运行 + +先启动后端,确认 `http://localhost:13080` 可以访问,然后执行: ```bash -# 安装依赖 -yarn --registry=https://registry.npmmirror.com - -# 启动服务 -yarn dev - -# 构建测试环境 yarn build:stage -# 构建生产环境 yarn build:prod -# 前端访问地址 http://localhost:80 +pnpm install +pnpm dev ``` -## 内置功能 +默认地址: -1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。 -2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。 -3. 岗位管理:配置系统用户所属担任职务。 -4. 菜单管理:配置系统菜单,操作权限,按钮权限标识等。 -5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。 -6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。 -7. 参数管理:对系统动态配置常用参数。 -8. 通知公告:系统通知公告信息发布维护。 -9. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。 -10. 登录日志:系统登录日志记录查询包含登录异常。 -11. 在线用户:当前系统中活跃用户状态监控。 -12. 定时任务:在线(添加、修改、删除)任务调度包含执行结果日志。 -13. 代码生成:前后端代码的生成(java、html、xml、sql)支持CRUD下载 。 -14. 系统接口:根据业务代码自动生成相关的api接口文档。 -15. 服务监控:监视当前系统CPU、内存、磁盘、堆栈等相关信息。 -16. 缓存监控:对系统的缓存信息查询,命令统计等。 -17. 在线构建器:拖动表单元素生成相应的HTML代码。 -18. 连接池监视:监视当前系统数据库连接池状态,可进行分析SQL找出系统性能瓶颈。 +- 前端:`http://localhost:80` +- 后端:`http://localhost:13080` +- Knife4j:`http://localhost:13080/doc.html` + +开发配置位于 `.env.development`: + +```dotenv +VITE_APP_TITLE=招商车研物联网平台管理系统 +VITE_APP_BASE_API=/dev-api +VITE_API_URL=http://localhost:13080 +VITE_WS_URL=ws://localhost:13080/ws +VITE_PORT=80 +``` + +## 构建 + +```bash +pnpm build:dev +pnpm build:stage +pnpm build:prod +pnpm preview +``` + +生产构建输出到 `dist`。部署时需要由 Nginx 或网关转发 `/prod-api`,并支持 `/ws` WebSocket、文件上传和媒体请求。 + +## 目录说明 + +```text +public/models 机器人 URDF 和网格模型 +public/inspection 巡检机械臂模型 +src/adapters URDF/Xacro 模型适配 +src/api REST API 封装 +src/components 公共及业务组件 +src/router 公共路由和隐藏业务路由 +src/store Pinia 状态管理 +src/views/device 设备管理与设备控制 +src/views/test 测试业务 +src/views/flow 流程编排 +src/views/inspection 智能巡检 +src/views/evaluate 评价管理 +src/views/vi 语音交互 +src/views/is 智能座舱 +src/views/corpusManger 语料管理 +``` + +业务菜单由后端 `/getRouters` 动态返回。数据库菜单中的 `component` 必须与 `src/views` 下的实际页面路径一致,权限字符必须与后端控制器保持一致。 + +## 配置说明 + +- `.env.development`:本地开发地址。 +- `.env.staging`:测试环境地址。 +- `.env.production`:生产环境地址、Node-RED 和 MinIO。 +- `vite.config.js`:代理、端口、Monaco 和构建分包。 +- `src/settings.js`:布局、页签和版权配置。 + +生产密码、访问密钥和内部网络配置应通过部署环境注入,不要提交新的敏感信息。 diff --git a/bin/build.bat b/bin/build.bat new file mode 100644 index 0000000..ecbb454 --- /dev/null +++ b/bin/build.bat @@ -0,0 +1,12 @@ +@echo off +echo. +echo [ÐÅϢ] ´ò°üWeb¹¤³̣¬Éú³ÉdistÎļþ¡£ +echo. + +%~d0 +cd %~dp0 + +cd .. +yarn build:prod + +pause \ No newline at end of file diff --git a/bin/package.bat b/bin/package.bat new file mode 100644 index 0000000..f5b24e0 --- /dev/null +++ b/bin/package.bat @@ -0,0 +1,12 @@ +@echo off +echo. +echo [ÐÅϢ] °²װWeb¹¤³̣¬Éú³Énode_modulesÎļþ¡£ +echo. + +%~d0 +cd %~dp0 + +cd .. +yarn --registry=https://registry.npmmirror.com + +pause \ No newline at end of file diff --git a/bin/run-web.bat b/bin/run-web.bat new file mode 100644 index 0000000..d2fe397 --- /dev/null +++ b/bin/run-web.bat @@ -0,0 +1,12 @@ +@echo off +echo. +echo [ÐÅϢ] ʹÓà Vite ÃüÁîÔËÐÐ Web ¹¤³̡£ +echo. + +%~d0 +cd %~dp0 + +cd .. +yarn dev + +pause \ No newline at end of file diff --git a/index.html b/index.html index ceebf89..17457d3 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - 招商车研物联网平台管理系统 + %VITE_APP_TITLE% + \ No newline at end of file diff --git a/src/components/Crontab/day.vue b/src/components/Crontab/day.vue index 8f67324..39263f5 100644 --- a/src/components/Crontab/day.vue +++ b/src/components/Crontab/day.vue @@ -171,4 +171,4 @@ function onRadioChange() { .el-select, .el-select--small { width: 18.8rem; } - + \ No newline at end of file diff --git a/src/components/Crontab/hour.vue b/src/components/Crontab/hour.vue index c6f9a13..db77835 100644 --- a/src/components/Crontab/hour.vue +++ b/src/components/Crontab/hour.vue @@ -78,10 +78,10 @@ watch(() => props.cron.hour, value => changeRadioValue(value)) watch([radioValue, cycleTotal, averageTotal, checkboxString], () => onRadioChange()) function changeRadioValue(value) { if (props.cron.min === '*') { - emit('update', 'min', '0', 'hour'); + emit('update', 'min', '0', 'hour') } if (props.cron.second === '*') { - emit('update', 'second', '0', 'hour'); + emit('update', 'second', '0', 'hour') } if (value === '*') { radioValue.value = 1 @@ -130,4 +130,4 @@ function onRadioChange() { .el-select, .el-select--small { width: 18.8rem; } - + \ No newline at end of file diff --git a/src/components/Crontab/index.vue b/src/components/Crontab/index.vue index ef0fe97..cbb41ab 100644 --- a/src/components/Crontab/index.vue +++ b/src/components/Crontab/index.vue @@ -70,42 +70,46 @@

时间表达式

- - + + + + - - - - - - - - + + + + + + + + + +
{{item}}Cron 表达式
{{item}}Cron 表达式
- {{crontabValueObj.second}} - {{crontabValueObj.second}} - - {{crontabValueObj.min}} - {{crontabValueObj.min}} - - {{crontabValueObj.hour}} - {{crontabValueObj.hour}} - - {{crontabValueObj.day}} - {{crontabValueObj.day}} - - {{crontabValueObj.month}} - {{crontabValueObj.month}} - - {{crontabValueObj.week}} - {{crontabValueObj.week}} - - {{crontabValueObj.year}} - {{crontabValueObj.year}} - - {{crontabValueString}} - {{crontabValueString}} -
+ {{crontabValueObj.second}} + {{crontabValueObj.second}} + + {{crontabValueObj.min}} + {{crontabValueObj.min}} + + {{crontabValueObj.hour}} + {{crontabValueObj.hour}} + + {{crontabValueObj.day}} + {{crontabValueObj.day}} + + {{crontabValueObj.month}} + {{crontabValueObj.month}} + + {{crontabValueObj.week}} + {{crontabValueObj.week}} + + {{crontabValueObj.year}} + {{crontabValueObj.year}} + + {{crontabValueString}} + {{crontabValueString}} +
@@ -306,4 +310,4 @@ onMounted(() => { height: 10em; overflow-y: auto; } - + \ No newline at end of file diff --git a/src/components/Crontab/min.vue b/src/components/Crontab/min.vue index 21de620..65f0946 100644 --- a/src/components/Crontab/min.vue +++ b/src/components/Crontab/min.vue @@ -123,4 +123,4 @@ function onRadioChange() { .el-select, .el-select--small { width: 19.8rem; } - + \ No newline at end of file diff --git a/src/components/Crontab/month.vue b/src/components/Crontab/month.vue index 45e9d0f..e561ba4 100644 --- a/src/components/Crontab/month.vue +++ b/src/components/Crontab/month.vue @@ -138,4 +138,4 @@ function onRadioChange() { .el-select, .el-select--small { width: 18.8rem; } - + \ No newline at end of file diff --git a/src/components/Crontab/result.vue b/src/components/Crontab/result.vue index 0c18922..cbb49ba 100644 --- a/src/components/Crontab/result.vue +++ b/src/components/Crontab/result.vue @@ -26,289 +26,289 @@ watch(() => props.ex, () => expressionChange()) // 表达式值变化时,开始去计算结果 function expressionChange() { // 计算开始-隐藏结果 - isShow.value = false; + isShow.value = false // 获取规则数组[0秒、1分、2时、3日、4月、5星期、6年] - let ruleArr = props.ex.split(' '); + let ruleArr = props.ex.split(' ') // 用于记录进入循环的次数 - let nums = 0; + let nums = 0 // 用于暂时存符号时间规则结果的数组 - let resultArr = []; + let resultArr = [] // 获取当前时间精确至[年、月、日、时、分、秒] - let nTime = new Date(); - let nYear = nTime.getFullYear(); - let nMonth = nTime.getMonth() + 1; - let nDay = nTime.getDate(); - let nHour = nTime.getHours(); - let nMin = nTime.getMinutes(); - let nSecond = nTime.getSeconds(); + let nTime = new Date() + let nYear = nTime.getFullYear() + let nMonth = nTime.getMonth() + 1 + let nDay = nTime.getDate() + let nHour = nTime.getHours() + let nMin = nTime.getMinutes() + let nSecond = nTime.getSeconds() // 根据规则获取到近100年可能年数组、月数组等等 - getSecondArr(ruleArr[0]); - getMinArr(ruleArr[1]); - getHourArr(ruleArr[2]); - getDayArr(ruleArr[3]); - getMonthArr(ruleArr[4]); - getWeekArr(ruleArr[5]); - getYearArr(ruleArr[6], nYear); + getSecondArr(ruleArr[0]) + getMinArr(ruleArr[1]) + getHourArr(ruleArr[2]) + getDayArr(ruleArr[3]) + getMonthArr(ruleArr[4]) + getWeekArr(ruleArr[5]) + getYearArr(ruleArr[6], nYear) // 将获取到的数组赋值-方便使用 - let sDate = dateArr.value[0]; - let mDate = dateArr.value[1]; - let hDate = dateArr.value[2]; - let DDate = dateArr.value[3]; - let MDate = dateArr.value[4]; - let YDate = dateArr.value[5]; + let sDate = dateArr.value[0] + let mDate = dateArr.value[1] + let hDate = dateArr.value[2] + let DDate = dateArr.value[3] + let MDate = dateArr.value[4] + let YDate = dateArr.value[5] // 获取当前时间在数组中的索引 - let sIdx = getIndex(sDate, nSecond); - let mIdx = getIndex(mDate, nMin); - let hIdx = getIndex(hDate, nHour); - let DIdx = getIndex(DDate, nDay); - let MIdx = getIndex(MDate, nMonth); - let YIdx = getIndex(YDate, nYear); + let sIdx = getIndex(sDate, nSecond) + let mIdx = getIndex(mDate, nMin) + let hIdx = getIndex(hDate, nHour) + let DIdx = getIndex(DDate, nDay) + let MIdx = getIndex(MDate, nMonth) + let YIdx = getIndex(YDate, nYear) // 重置月日时分秒的函数(后面用的比较多) const resetSecond = function () { - sIdx = 0; + sIdx = 0 nSecond = sDate[sIdx] } const resetMin = function () { - mIdx = 0; + mIdx = 0 nMin = mDate[mIdx] - resetSecond(); + resetSecond() } const resetHour = function () { - hIdx = 0; + hIdx = 0 nHour = hDate[hIdx] - resetMin(); + resetMin() } const resetDay = function () { - DIdx = 0; + DIdx = 0 nDay = DDate[DIdx] - resetHour(); + resetHour() } const resetMonth = function () { - MIdx = 0; + MIdx = 0 nMonth = MDate[MIdx] - resetDay(); + resetDay() } // 如果当前年份不为数组中当前值 if (nYear !== YDate[YIdx]) { - resetMonth(); + resetMonth() } // 如果当前月份不为数组中当前值 if (nMonth !== MDate[MIdx]) { - resetDay(); + resetDay() } // 如果当前“日”不为数组中当前值 if (nDay !== DDate[DIdx]) { - resetHour(); + resetHour() } // 如果当前“时”不为数组中当前值 if (nHour !== hDate[hIdx]) { - resetMin(); + resetMin() } // 如果当前“分”不为数组中当前值 if (nMin !== mDate[mIdx]) { - resetSecond(); + resetSecond() } // 循环年份数组 goYear: for (let Yi = YIdx; Yi < YDate.length; Yi++) { - let YY = YDate[Yi]; + let YY = YDate[Yi] // 如果到达最大值时 if (nMonth > MDate[MDate.length - 1]) { - resetMonth(); - continue; + resetMonth() + continue } // 循环月份数组 goMonth: for (let Mi = MIdx; Mi < MDate.length; Mi++) { // 赋值、方便后面运算 let MM = MDate[Mi]; - MM = MM < 10 ? '0' + MM : MM; + MM = MM < 10 ? '0' + MM : MM // 如果到达最大值时 if (nDay > DDate[DDate.length - 1]) { - resetDay(); + resetDay() if (Mi === MDate.length - 1) { - resetMonth(); - continue goYear; + resetMonth() + continue goYear } - continue; + continue } // 循环日期数组 goDay: for (let Di = DIdx; Di < DDate.length; Di++) { // 赋值、方便后面运算 - let DD = DDate[Di]; - let thisDD = DD < 10 ? '0' + DD : DD; + let DD = DDate[Di] + let thisDD = DD < 10 ? '0' + DD : DD // 如果到达最大值时 if (nHour > hDate[hDate.length - 1]) { - resetHour(); + resetHour() if (Di === DDate.length - 1) { - resetDay(); + resetDay() if (Mi === MDate.length - 1) { - resetMonth(); - continue goYear; + resetMonth() + continue goYear } - continue goMonth; + continue goMonth } - continue; + continue } // 判断日期的合法性,不合法的话也是跳出当前循环 if (checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true && dayRule.value !== 'workDay' && dayRule.value !== 'lastWeek' && dayRule.value !== 'lastDay') { - resetDay(); - continue goMonth; + resetDay() + continue goMonth } // 如果日期规则中有值时 if (dayRule.value === 'lastDay') { // 如果不是合法日期则需要将前将日期调到合法日期即月末最后一天 if (checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { while (DD > 0 && checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { - DD--; - thisDD = DD < 10 ? '0' + DD : DD; + DD-- + thisDD = DD < 10 ? '0' + DD : DD } } } else if (dayRule.value === 'workDay') { // 校验并调整如果是2月30号这种日期传进来时需调整至正常月底 if (checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { while (DD > 0 && checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { - DD--; - thisDD = DD < 10 ? '0' + DD : DD; + DD-- + thisDD = DD < 10 ? '0' + DD : DD } } // 获取达到条件的日期是星期X - let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week'); + let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week') // 当星期日时 if (thisWeek === 1) { // 先找下一个日,并判断是否为月底 - DD++; - thisDD = DD < 10 ? '0' + DD : DD; + DD++ + thisDD = DD < 10 ? '0' + DD : DD // 判断下一日已经不是合法日期 if (checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { - DD -= 3; + DD -= 3 } } else if (thisWeek === 7) { // 当星期6时只需判断不是1号就可进行操作 if (dayRuleSup.value !== 1) { - DD--; + DD-- } else { - DD += 2; + DD += 2 } } } else if (dayRule.value === 'weekDay') { // 如果指定了是星期几 // 获取当前日期是属于星期几 - let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week'); + let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week') // 校验当前星期是否在星期池(dayRuleSup)中 if (dayRuleSup.value.indexOf(thisWeek) < 0) { // 如果到达最大值时 if (Di === DDate.length - 1) { - resetDay(); + resetDay() if (Mi === MDate.length - 1) { - resetMonth(); - continue goYear; + resetMonth() + continue goYear } - continue goMonth; + continue goMonth } - continue; + continue } } else if (dayRule.value === 'assWeek') { // 如果指定了是第几周的星期几 // 获取每月1号是属于星期几 - let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week'); + let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + DD + ' 00:00:00'), 'week') if (dayRuleSup.value[1] >= thisWeek) { - DD = (dayRuleSup.value[0] - 1) * 7 + dayRuleSup.value[1] - thisWeek + 1; + DD = (dayRuleSup.value[0] - 1) * 7 + dayRuleSup.value[1] - thisWeek + 1 } else { - DD = dayRuleSup.value[0] * 7 + dayRuleSup.value[1] - thisWeek + 1; + DD = dayRuleSup.value[0] * 7 + dayRuleSup.value[1] - thisWeek + 1 } } else if (dayRule.value === 'lastWeek') { // 如果指定了每月最后一个星期几 // 校验并调整如果是2月30号这种日期传进来时需调整至正常月底 if (checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { while (DD > 0 && checkDate(YY + '-' + MM + '-' + thisDD + ' 00:00:00') !== true) { - DD--; - thisDD = DD < 10 ? '0' + DD : DD; + DD-- + thisDD = DD < 10 ? '0' + DD : DD } } // 获取月末最后一天是星期几 - let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week'); + let thisWeek = formatDate(new Date(YY + '-' + MM + '-' + thisDD + ' 00:00:00'), 'week') // 找到要求中最近的那个星期几 if (dayRuleSup.value < thisWeek) { - DD -= thisWeek - dayRuleSup.value; + DD -= thisWeek - dayRuleSup.value } else if (dayRuleSup.value > thisWeek) { DD -= 7 - (dayRuleSup.value - thisWeek) } } // 判断时间值是否小于10置换成“05”这种格式 - DD = DD < 10 ? '0' + DD : DD; + DD = DD < 10 ? '0' + DD : DD // 循环“时”数组 goHour: for (let hi = hIdx; hi < hDate.length; hi++) { let hh = hDate[hi] < 10 ? '0' + hDate[hi] : hDate[hi] // 如果到达最大值时 if (nMin > mDate[mDate.length - 1]) { - resetMin(); + resetMin() if (hi === hDate.length - 1) { - resetHour(); + resetHour() if (Di === DDate.length - 1) { - resetDay(); + resetDay() if (Mi === MDate.length - 1) { - resetMonth(); - continue goYear; + resetMonth() + continue goYear } - continue goMonth; + continue goMonth } - continue goDay; + continue goDay } - continue; + continue } // 循环"分"数组 goMin: for (let mi = mIdx; mi < mDate.length; mi++) { - let mm = mDate[mi] < 10 ? '0' + mDate[mi] : mDate[mi]; + let mm = mDate[mi] < 10 ? '0' + mDate[mi] : mDate[mi] // 如果到达最大值时 if (nSecond > sDate[sDate.length - 1]) { - resetSecond(); + resetSecond() if (mi === mDate.length - 1) { - resetMin(); + resetMin() if (hi === hDate.length - 1) { - resetHour(); + resetHour() if (Di === DDate.length - 1) { - resetDay(); + resetDay() if (Mi === MDate.length - 1) { - resetMonth(); - continue goYear; + resetMonth() + continue goYear } - continue goMonth; + continue goMonth } - continue goDay; + continue goDay } - continue goHour; + continue goHour } - continue; + continue } // 循环"秒"数组 goSecond: for (let si = sIdx; si <= sDate.length - 1; si++) { - let ss = sDate[si] < 10 ? '0' + sDate[si] : sDate[si]; + let ss = sDate[si] < 10 ? '0' + sDate[si] : sDate[si] // 添加当前时间(时间合法性在日期循环时已经判断) if (MM !== '00' && DD !== '00') { resultArr.push(YY + '-' + MM + '-' + DD + ' ' + hh + ':' + mm + ':' + ss) - nums++; + nums++ } // 如果条数满了就退出循环 - if (nums === 5) break goYear; + if (nums === 5) break goYear // 如果到达最大值时 if (si === sDate.length - 1) { - resetSecond(); + resetSecond() if (mi === mDate.length - 1) { - resetMin(); + resetMin() if (hi === hDate.length - 1) { - resetHour(); + resetHour() if (Di === DDate.length - 1) { - resetDay(); + resetDay() if (Mi === MDate.length - 1) { - resetMonth(); - continue goYear; + resetMonth() + continue goYear } - continue goMonth; + continue goMonth } - continue goDay; + continue goDay } - continue goHour; + continue goHour } - continue goMin; + continue goMin } } //goSecond } //goMin @@ -318,31 +318,31 @@ function expressionChange() { } // 判断100年内的结果条数 if (resultArr.length === 0) { - resultList.value = ['没有达到条件的结果!']; + resultList.value = ['没有达到条件的结果!'] } else { - resultList.value = resultArr; + resultList.value = resultArr if (resultArr.length !== 5) { resultList.value.push('最近100年内只有上面' + resultArr.length + '条结果!') } } // 计算完成-显示结果 - isShow.value = true; + isShow.value = true } // 用于计算某位数字在数组中的索引 function getIndex(arr, value) { if (value <= arr[0] || value > arr[arr.length - 1]) { - return 0; + return 0 } else { for (let i = 0; i < arr.length - 1; i++) { if (value > arr[i] && value <= arr[i + 1]) { - return i + 1; + return i + 1 } } } } // 获取"年"数组 function getYearArr(rule, year) { - dateArr.value[5] = getOrderArr(year, year + 100); + dateArr.value[5] = getOrderArr(year, year + 100) if (rule !== undefined) { if (rule.indexOf('-') >= 0) { dateArr.value[5] = getCycleArr(rule, year + 100, false) @@ -355,7 +355,7 @@ function getYearArr(rule, year) { } // 获取"月"数组 function getMonthArr(rule) { - dateArr.value[4] = getOrderArr(1, 12); + dateArr.value[4] = getOrderArr(1, 12) if (rule.indexOf('-') >= 0) { dateArr.value[4] = getCycleArr(rule, 12, false) } else if (rule.indexOf('/') >= 0) { @@ -369,58 +369,58 @@ function getWeekArr(rule) { // 只有当日期规则的两个值均为“”时则表达日期是有选项的 if (dayRule.value === '' && dayRuleSup.value === '') { if (rule.indexOf('-') >= 0) { - dayRule.value = 'weekDay'; + dayRule.value = 'weekDay' dayRuleSup.value = getCycleArr(rule, 7, false) } else if (rule.indexOf('#') >= 0) { - dayRule.value = 'assWeek'; - let matchRule = rule.match(/[0-9]{1}/g); - dayRuleSup.value = [Number(matchRule[1]), Number(matchRule[0])]; - dateArr.value[3] = [1]; + dayRule.value = 'assWeek' + let matchRule = rule.match(/[0-9]{1}/g) + dayRuleSup.value = [Number(matchRule[1]), Number(matchRule[0])] + dateArr.value[3] = [1] if (dayRuleSup.value[1] === 7) { - dayRuleSup.value[1] = 0; + dayRuleSup.value[1] = 0 } } else if (rule.indexOf('L') >= 0) { - dayRule.value = 'lastWeek'; - dayRuleSup.value = Number(rule.match(/[0-9]{1,2}/g)[0]); - dateArr.value[3] = [31]; + dayRule.value = 'lastWeek' + dayRuleSup.value = Number(rule.match(/[0-9]{1,2}/g)[0]) + dateArr.value[3] = [31] if (dayRuleSup.value === 7) { - dayRuleSup.value = 0; + dayRuleSup.value = 0 } } else if (rule !== '*' && rule !== '?') { - dayRule.value = 'weekDay'; + dayRule.value = 'weekDay' dayRuleSup.value = getAssignArr(rule) } } } // 获取"日"数组-少量为日期规则 function getDayArr(rule) { - dateArr.value[3] = getOrderArr(1, 31); - dayRule.value = ''; - dayRuleSup.value = ''; + dateArr.value[3] = getOrderArr(1, 31) + dayRule.value = '' + dayRuleSup.value = '' if (rule.indexOf('-') >= 0) { dateArr.value[3] = getCycleArr(rule, 31, false) - dayRuleSup.value = 'null'; + dayRuleSup.value = 'null' } else if (rule.indexOf('/') >= 0) { dateArr.value[3] = getAverageArr(rule, 31) - dayRuleSup.value = 'null'; + dayRuleSup.value = 'null' } else if (rule.indexOf('W') >= 0) { - dayRule.value = 'workDay'; - dayRuleSup.value = Number(rule.match(/[0-9]{1,2}/g)[0]); - dateArr.value[3] = [dayRuleSup.value]; + dayRule.value = 'workDay' + dayRuleSup.value = Number(rule.match(/[0-9]{1,2}/g)[0]) + dateArr.value[3] = [dayRuleSup.value] } else if (rule.indexOf('L') >= 0) { - dayRule.value = 'lastDay'; - dayRuleSup.value = 'null'; - dateArr.value[3] = [31]; + dayRule.value = 'lastDay' + dayRuleSup.value = 'null' + dateArr.value[3] = [31] } else if (rule !== '*' && rule !== '?') { dateArr.value[3] = getAssignArr(rule) - dayRuleSup.value = 'null'; + dayRuleSup.value = 'null' } else if (rule === '*') { - dayRuleSup.value = 'null'; + dayRuleSup.value = 'null' } } // 获取"时"数组 function getHourArr(rule) { - dateArr.value[2] = getOrderArr(0, 23); + dateArr.value[2] = getOrderArr(0, 23) if (rule.indexOf('-') >= 0) { dateArr.value[2] = getCycleArr(rule, 24, true) } else if (rule.indexOf('/') >= 0) { @@ -431,7 +431,7 @@ function getHourArr(rule) { } // 获取"分"数组 function getMinArr(rule) { - dateArr.value[1] = getOrderArr(0, 59); + dateArr.value[1] = getOrderArr(0, 59) if (rule.indexOf('-') >= 0) { dateArr.value[1] = getCycleArr(rule, 60, true) } else if (rule.indexOf('/') >= 0) { @@ -442,7 +442,7 @@ function getMinArr(rule) { } // 获取"秒"数组 function getSecondArr(rule) { - dateArr.value[0] = getOrderArr(0, 59); + dateArr.value[0] = getOrderArr(0, 59) if (rule.indexOf('-') >= 0) { dateArr.value[0] = getCycleArr(rule, 60, true) } else if (rule.indexOf('/') >= 0) { @@ -453,88 +453,88 @@ function getSecondArr(rule) { } // 根据传进来的min-max返回一个顺序的数组 function getOrderArr(min, max) { - let arr = []; + let arr = [] for (let i = min; i <= max; i++) { - arr.push(i); + arr.push(i) } - return arr; + return arr } // 根据规则中指定的零散值返回一个数组 function getAssignArr(rule) { - let arr = []; - let assiginArr = rule.split(','); + let arr = [] + let assiginArr = rule.split(',') for (let i = 0; i < assiginArr.length; i++) { arr[i] = Number(assiginArr[i]) } arr.sort(compare) - return arr; + return arr } // 根据一定算术规则计算返回一个数组 function getAverageArr(rule, limit) { - let arr = []; - let agArr = rule.split('/'); - let min = Number(agArr[0]); - let step = Number(agArr[1]); + let arr = [] + let agArr = rule.split('/') + let min = Number(agArr[0]) + let step = Number(agArr[1]) while (min <= limit) { - arr.push(min); - min += step; + arr.push(min) + min += step } - return arr; + return arr } // 根据规则返回一个具有周期性的数组 function getCycleArr(rule, limit, status) { // status--表示是否从0开始(则从1开始) - let arr = []; - let cycleArr = rule.split('-'); - let min = Number(cycleArr[0]); - let max = Number(cycleArr[1]); + let arr = [] + let cycleArr = rule.split('-') + let min = Number(cycleArr[0]) + let max = Number(cycleArr[1]) if (min > max) { - max += limit; + max += limit } for (let i = min; i <= max; i++) { - let add = 0; + let add = 0 if (status === false && i % limit === 0) { - add = limit; + add = limit } arr.push(Math.round(i % limit + add)) } arr.sort(compare) - return arr; + return arr } // 比较数字大小(用于Array.sort) function compare(value1, value2) { if (value2 - value1 > 0) { - return -1; + return -1 } else { - return 1; + return 1 } } // 格式化日期格式如:2017-9-19 18:04:33 function formatDate(value, type) { // 计算日期相关值 - let time = typeof value == 'number' ? new Date(value) : value; - let Y = time.getFullYear(); - let M = time.getMonth() + 1; - let D = time.getDate(); - let h = time.getHours(); - let m = time.getMinutes(); - let s = time.getSeconds(); - let week = time.getDay(); + let time = typeof value == 'number' ? new Date(value) : value + let Y = time.getFullYear() + let M = time.getMonth() + 1 + let D = time.getDate() + let h = time.getHours() + let m = time.getMinutes() + let s = time.getSeconds() + let week = time.getDay() // 如果传递了type的话 if (type === undefined) { - return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D) + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s); + return Y + '-' + (M < 10 ? '0' + M : M) + '-' + (D < 10 ? '0' + D : D) + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m) + ':' + (s < 10 ? '0' + s : s) } else if (type === 'week') { // 在quartz中 1为星期日 - return week + 1; + return week + 1 } } // 检查日期是否存在 function checkDate(value) { - let time = new Date(value); + let time = new Date(value) let format = formatDate(time) - return value === format; + return value === format } onMounted(() => { expressionChange() }) - + \ No newline at end of file diff --git a/src/components/Crontab/second.vue b/src/components/Crontab/second.vue index 1a47424..15e47a0 100644 --- a/src/components/Crontab/second.vue +++ b/src/components/Crontab/second.vue @@ -125,4 +125,4 @@ function onRadioChange() { .el-select, .el-select--small { width: 18.8rem; } - + \ No newline at end of file diff --git a/src/components/Crontab/week.vue b/src/components/Crontab/week.vue index 669d781..e59da22 100644 --- a/src/components/Crontab/week.vue +++ b/src/components/Crontab/week.vue @@ -194,4 +194,4 @@ function onRadioChange() { .el-select.multiselect, .el-select--small.multiselect { width: 17.8rem; } - + \ No newline at end of file diff --git a/src/components/Crontab/year.vue b/src/components/Crontab/year.vue index 3a47aec..14758ba 100644 --- a/src/components/Crontab/year.vue +++ b/src/components/Crontab/year.vue @@ -61,22 +61,24 @@ const props = defineProps({ } } }) -const fullYear = ref(0) -const maxFullYear = ref(0) + +const fullYear = Number(new Date().getFullYear()) +const maxFullYear = fullYear + 10 const radioValue = ref(1) -const cycle01 = ref(0) -const cycle02 = ref(0) -const average01 = ref(0) +const cycle01 = ref(fullYear) +const cycle02 = ref(fullYear + 1) +const average01 = ref(fullYear) const average02 = ref(1) const checkboxList = ref([]) -const checkCopy = ref([]) +const checkCopy = ref([fullYear]) + const cycleTotal = computed(() => { - cycle01.value = props.check(cycle01.value, fullYear.value, maxFullYear.value - 1) - cycle02.value = props.check(cycle02.value, cycle01.value + 1, maxFullYear.value) + cycle01.value = props.check(cycle01.value, fullYear, maxFullYear - 1) + cycle02.value = props.check(cycle02.value, cycle01.value + 1, maxFullYear) return cycle01.value + '-' + cycle02.value }) const averageTotal = computed(() => { - average01.value = props.check(average01.value, fullYear.value, maxFullYear.value - 1) + average01.value = props.check(average01.value, fullYear, maxFullYear - 1) average02.value = props.check(average02.value, 1, 10) return average01.value + '/' + average02.value }) @@ -97,8 +99,8 @@ function changeRadioValue(value) { radioValue.value = 3 } else if (value.indexOf("/") > -1) { const indexArr = value.split('/') - average01.value = Number(indexArr[1]) - average02.value = Number(indexArr[0]) + average01.value = Number(indexArr[0]) + average02.value = Number(indexArr[1]) radioValue.value = 4 } else { checkboxList.value = [...new Set(value.split(',').map(item => Number(item)))] @@ -129,14 +131,6 @@ function onRadioChange() { break } } -onMounted(() => { - fullYear.value = Number(new Date().getFullYear()) - maxFullYear.value = fullYear.value + 10 - cycle01.value = fullYear.value - cycle02.value = cycle01.value + 1 - average01.value = fullYear.value - checkCopy.value = [fullYear.value] -}) + \ No newline at end of file diff --git a/src/components/DictTag/index.vue b/src/components/DictTag/index.vue index 19e24e4..ce86940 100644 --- a/src/components/DictTag/index.vue +++ b/src/components/DictTag/index.vue @@ -1,7 +1,7 @@ - \ No newline at end of file + + + diff --git a/src/views/inspection/map/index.vue b/src/views/inspection/map/index.vue deleted file mode 100644 index 2576ca7..0000000 --- a/src/views/inspection/map/index.vue +++ /dev/null @@ -1,580 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/views/inspection/point/index.vue b/src/views/inspection/point/index.vue index d4982c1..eed1f12 100644 --- a/src/views/inspection/point/index.vue +++ b/src/views/inspection/point/index.vue @@ -149,7 +149,7 @@ align="center" class-name="small-padding fixed-width" label="操作" - width="200" + width="280" > - + + + @@ -117,17 +130,10 @@ - + - - - - - @@ -140,8 +146,27 @@ - - + + + + + +
+
机器人和设备
+ +
运行参数
+ +
+
@@ -151,16 +176,67 @@ import taskSteps from "./task-steps.vue"; import taskLog from "./task-log.vue"; import { useContainerHeight } from "@/hooks/tableHeight"; import { getTaskList, getWaypointByTaskId } from "@/api/inspection/task"; -import { getRobotList } from "@/api/inspection/robot"; -import { onMounted, onUnmounted } from "vue"; -import { addRunTask, getRunTaskList, startRunTask, pauseRunTask, stopRunTask, resumeRunTask, deleteRunTask, getTaskLogListApi } from "@/api/inspection/runTask"; +import { computed, onMounted, onUnmounted } from "vue"; +import { useElementBounding, useElementSize } from '@vueuse/core' +import { addRunTask, getRunTaskList, startRunTask, rerunRunTask, pauseRunTask, stopRunTask, resumeRunTask, deleteRunTask, getTaskLogListApi } from "@/api/inspection/runTask"; import { ElMessage, ElMessageBox } from "element-plus"; import { formatDate } from "@/utils/index"; import { debounce } from 'lodash'; // 引入 lodash 的防抖函数 +import { fetchAllPagedRows } from '@/utils/pagedRequest' +import { RuntimeAssignmentsEditor, RuntimeParamsEditor } from '@cmvr/iot-common' +import { getTaskConfig } from '@/api/test/config.js' +import { + createRuntimeAssignments, + firstAssignedRobotId, + loadFlowItemScopedRuntimeRoles, +} from '@/utils/flowExecution' const topContainerRef = ref(); const containerHeight = useContainerHeight(topContainerRef); +const contextContainerRef = ref(null) +const taskLogContainerRef = ref(null) +const taskLogTitleRef = ref(null) + +// 通过元素边界实时获取当前任务内容区底部和日志容器顶部,避免依赖固定的 460px。 +const { bottom: contextContainerBottom } = useElementBounding(contextContainerRef) +const { top: taskLogContainerTop } = useElementBounding(taskLogContainerRef) +const { height: taskLogTitleHeight } = useElementSize(taskLogTitleRef) + +const TASK_LOG_MARGIN_TOP = 12 +const CURRENT_TASK_BOTTOM_PADDING = 16 +const MIN_TASK_LOG_HEIGHT = 150 + +/** + * 计算当前任务页面中日志组件可以使用的剩余高度。 + * + * 计算基准是右侧内容区的底部,而不是窗口高度,因此页面外层布局、浏览器窗口 + * 尺寸或右侧面板高度发生变化时都能得到正确结果。日志容器顶部到内容区底部之间, + * 还需要扣除“执行日志”标题高度、taskLog 组件自身的上间距,以及当前任务卡片的 + * 底部内边距,确保日志不会覆盖任务卡片边界。元素尚未挂载时使用最低高度作为初始值, + * 待 VueUse 完成首次测量后会自动更新为实际剩余高度。 + */ +const taskLogHeight = computed(() => { + const remainingHeight = contextContainerBottom.value + - taskLogContainerTop.value + - taskLogTitleHeight.value + - TASK_LOG_MARGIN_TOP + - CURRENT_TASK_BOTTOM_PADDING + + return Math.max(MIN_TASK_LOG_HEIGHT, Math.floor(remainingHeight)) +}) + const socket = inject('ws'); +const startDialogVisible = ref(false) +const startSubmitting = ref(false) +const pendingStartTask = ref(null) +const runtimeRoles = ref([]) +const runtimeAssignments = ref([]) +const runtimeEditorRef = ref() +const runtimeMapId = ref('') +const runtimeParamItems = ref([]) +const runtimeParamsEditorRef = ref() +const selectedTaskId = ref('') +const rerunningId = ref('') const taskStatusMap = { '0': '已完成', @@ -173,19 +249,37 @@ const taskStatusMap = { const form = reactive({ taskId: null, - robotId: null, }); const rules = reactive({ taskId: [{ required: true, message: '请选择任务', trigger: 'change' }], - robotId: [{ required: true, message: '请选择机器人', trigger: 'change' }], }); const taskList = ref([]); -const robotList = ref([]); - const runTaskList = ref([]); +// 接口和 WebSocket 可能分别以数字、字符串返回任务实例 ID,统一转换后再判断是否为选中任务。 +const isSelectedTask = (task) => String(task?.id ?? '') === String(selectedTaskId.value) + +// 当前任务详情直接从完整任务队列中取得,因此未执行、执行中和已暂停任务都可以被选中查看。 +const selectedRunTask = computed(() => runTaskList.value.find(isSelectedTask) || null) + +/** + * 点击左侧任务卡片时切换右侧当前任务详情,并从历史记录面板返回当前任务面板。 + * 卡片内的启动、暂停、停止和删除图标均使用 .stop 阻止冒泡,执行操作时不会意外改变当前选择。 + * + * @param {Object} task 左侧任务队列中被点击的任务实例 + */ +const selectTask = (task) => { + selectedTaskId.value = task.id + activePanel.value = 'current' +} + +const normalizeTaskStatus = (tasks = []) => tasks.map(item => ({ + ...item, + status: String(item.status), +})) + const getTaskData = () => { getTaskList({ pageNum: 1, @@ -195,30 +289,12 @@ const getTaskData = () => { }) } -const getRobotData = (mapId = null) => { - getRobotList({ - pageNum: 1, - pageSize: 10000, - currentMapId: mapId - }).then((res) => { - robotList.value = res.rows; - }) -} - const open = ref(false); const addTask = () => { open.value = true; } -const taskChange = (value) => { - const task = taskList.value.find(item => item.id === value) - const mapId = task.mapId - form.robotId = null; - robotList.value = [] - getRobotData(mapId) -} - const runTaskRef = ref(); /** * 确定添加执行任务 @@ -243,17 +319,23 @@ const cancelTaskDialog = () => { } -const runingTaskList = ref([]) /** - * 获取任务队列 + * 获取任务队列并维护当前选中的任务: + * 1. 页面首次加载时默认选中队列第一条任务; + * 2. 队列刷新后,如果原任务仍存在,则保留用户当前选择; + * 3. 如果原任务已经结束或被删除,则选择刷新后队列中的第一条任务; + * 4. 如果任务队列为空,则清空选择并由模板展示空状态。 */ const getList = () => { - getRunTaskList({ + return getRunTaskList({ statusList: ['1', '3', '5'], }).then((res) => { if (res.code === 200) { - runTaskList.value = res.rows; - runingTaskList.value = res.rows.filter(item => item.status !== '5') + const tasks = normalizeTaskStatus(res.rows) + runTaskList.value = tasks; + if (!tasks.some(isSelectedTask)) { + selectedTaskId.value = tasks[0]?.id ?? '' + } for (let i = 0; i < runTaskList.value.length; i++) { getPointByTaskId(runTaskList.value[i].taskId) getTaskLogList(runTaskList.value[i].id) @@ -262,6 +344,23 @@ const getList = () => { }) } +const handleRerun = async (task) => { + rerunningId.value = task.id + try { + const res = await rerunRunTask(task.id) + if (res.code === 200) { + selectedTaskId.value = String(res.data || '') + activePanel.value = 'current' + await getList() + await nextTick() + document.querySelector(`[data-task-id="${selectedTaskId.value}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + ElMessage.success('已按上次参数创建并启动新任务') + } + } finally { + rerunningId.value = '' + } +} + const pointList_runningTask = ref({}) /** * 获取正在执行任务的点位列表 @@ -281,7 +380,7 @@ const taskLogList = ref({}) * @param taskInstanceId */ const getTaskLogList = async (taskInstanceId) => { - const res = await getTaskLogListApi({ taskInstanceId }) + const res = await fetchAllPagedRows(getTaskLogListApi, { taskInstanceId }) if (res.code === 200) { taskLogList.value[taskInstanceId] = res.rows } @@ -317,18 +416,60 @@ const queryParams = reactive({ * @param task */ const startTask = async (task) => { - if (task.status === '3') { + if (String(task.status) === '3') { let res = await resumeRunTask(task.id); if (res.code === 200) { ElMessage.success("任务已恢复"); getList(); } } else { - let res = await startRunTask(task.id); - if (res.code === 200) { - ElMessage.success("任务已开始"); - getList(); + const taskDefinition = taskList.value.find(item => item.id === task.taskId) + if (!taskDefinition?.taskConfigId) { + ElMessage.warning('当前任务没有关联流程编排') + return } + try { + const paramsResponse = await getTaskConfig({ taskId: taskDefinition.taskConfigId }) + const paramItems = paramsResponse.rows || [] + const roles = await loadFlowItemScopedRuntimeRoles(paramItems) + runtimeAssignments.value = createRuntimeAssignments(roles, task.robotIdentity) + runtimeMapId.value = taskDefinition.mapId || '' + runtimeRoles.value = roles + runtimeParamItems.value = paramItems + pendingStartTask.value = task + startDialogVisible.value = true + } catch (error) { + ElMessage.error(error.message || '工作流执行资源加载失败') + } + } +} + +const confirmStartTask = async () => { + const assignmentError = runtimeEditorRef.value?.validate() + if (assignmentError) { + ElMessage.warning(assignmentError) + return + } + const paramsValid = await runtimeParamsEditorRef.value?.validate() + if (paramsValid === false) { + ElMessage.warning('请完整填写运行参数') + return + } + startSubmitting.value = true + try { + const robotId = firstAssignedRobotId(runtimeAssignments.value) + const res = await startRunTask(pendingStartTask.value.id, { + robotId, + runtimeAssignments: runtimeAssignments.value, + runParams: runtimeParamsEditorRef.value?.getRunParams() || {} + }) + if (res.code === 200) { + ElMessage.success('任务已开始') + startDialogVisible.value = false + getList() + } + } finally { + startSubmitting.value = false } } @@ -387,7 +528,7 @@ const getHistoryList = () => { pageSize: queryParams.pageSize, }).then((res) => { if (res.code === 200) { - tableDataList.value = res.rows; + tableDataList.value = normalizeTaskStatus(res.rows); total.value = res.total; } loading.value = false; @@ -421,13 +562,19 @@ const subscribeDebounced = debounce(async (sub) => { // 清理旧回调 if (socketChannelCallbacks.value[channel]) { socket.off(channel, socketChannelCallbacks.value[channel]); - console.log('清理旧回调:', channel); } const callback = (data) => { if (data !== '500') { - if (data.status !== 0) { - let activeStep = pointList_runningTask.value[data.taskId].findIndex(item => item.detectItemId === data.itemId) || 0 + // WebSocket 可能把状态作为字符串发送,先转成数字再判断,避免 '0' !== 0 导致终态被误当成运行日志。 + // 0=完成、2=失败、4=终止,这三种状态都会结束当前实例,不再追加实时日志和进度。 + const status = Number(data.status) + const terminal = [0, 2, 4].includes(status) + if (!terminal) { + const steps = pointList_runningTask.value[data.taskId] || [] + let activeStep = Number.isInteger(data.itemOrder) && data.itemOrder > 0 + ? data.itemOrder - 1 + : Math.max(steps.findIndex(item => item.detectItemId === data.itemId), 0) if (data.progress == 100) { activeStep += 1 } @@ -442,6 +589,7 @@ const subscribeDebounced = debounce(async (sub) => { ...data }) } else { + // 终态到达后清理内存中的实时快照,再从接口刷新当前队列与历史列表,保证页面以持久化结果为准。 delete taskRunningInfo.value[data.taskInstanceId] delete taskLogList.value[data.taskInstanceId] getList() @@ -465,23 +613,44 @@ const subscribeDebounced = debounce(async (sub) => { const logDialogVisible = ref(false) const logDialogData = ref([]) +// 历史日志组件需要任务定义 ID 查询该任务绑定的点位,并用任务终态推导未单独记录状态的点位结果。 +const logDialogTaskId = ref('') +const logDialogTaskStatus = ref(null) +const logDialogLoading = ref(false) +let logDialogRequestId = 0 const handleOpenLog = async (row) => { + const requestId = ++logDialogRequestId logDialogVisible.value = true - const res = await getTaskLogListApi({ taskInstanceId: row.id }) - if (res.code === 200) { - logDialogData.value = res.rows + + // 先切换任务上下文,再请求日志;点位请求和日志请求可以并行,避免弹窗一直沿用上一次任务的数据。 + logDialogTaskId.value = row.taskId + logDialogTaskStatus.value = row.status + logDialogData.value = [] + logDialogLoading.value = true + try { + const res = await fetchAllPagedRows(getTaskLogListApi, { taskInstanceId: row.id }) + if (requestId === logDialogRequestId && res.code === 200) { + logDialogData.value = res.rows + } + } finally { + if (requestId === logDialogRequestId) logDialogLoading.value = false } } +const refreshAfterSocketReconnect = () => { + getList() + getHistoryList() +} onMounted(() => { getTaskData(); - getRobotData(); getList(); getHistoryList(); subscribeDebounced(true) + socket?.on('open', refreshAfterSocketReconnect) }) onUnmounted(() => { subscribeDebounced(false) + socket?.off('open', refreshAfterSocketReconnect) }) \ No newline at end of file + +.start-dialog-content { + max-height: 65vh; + padding-right: 6px; + overflow-y: auto; +} + +.start-section-title { + margin: 16px 0 10px; + color: var(--el-text-color-primary); + font-size: 15px; + font-weight: 600; +} + +.start-section-title--params { + margin-top: 22px; +} + diff --git a/src/views/inspection/runTask/task-log.vue b/src/views/inspection/runTask/task-log.vue index 97553d1..f17fee8 100644 --- a/src/views/inspection/runTask/task-log.vue +++ b/src/views/inspection/runTask/task-log.vue @@ -1,73 +1,469 @@ + - \ No newline at end of file + +.task-log__heading, +.task-log__group-header { + display: grid; + grid-template-columns: 22px 34px minmax(0, 1fr) auto; + gap: 8px; + align-items: center; +} + +.task-log__heading { + padding: 10px 14px; + color: #98a2b3; + font-size: 12px; + border-bottom: 1px solid #f0f2f5; +} + +.task-log__heading span:first-child { + grid-column: 3; +} + +.task-log__heading span:last-child { + grid-column: 4; +} + +.task-log__groups { + padding: 0 8px 8px; +} + +.task-log__group { + border-bottom: 1px solid #f0f2f5; +} + +.task-log__group:last-child { + border-bottom: 0; +} + +.task-log__group-header { + width: 100%; + min-height: 48px; + padding: 8px 6px; + color: #344054; + text-align: left; + cursor: pointer; + background: transparent; + border: 0; +} + +.task-log__group-header:hover { + background: #f8fafc; +} + +.task-log__expand-icon { + color: #98a2b3; + transition: transform 0.2s ease; +} + +.task-log__expand-icon.is-expanded { + transform: rotate(90deg); +} + +.task-log__order { + color: #98a2b3; + font-size: 12px; + font-variant-numeric: tabular-nums; +} + +.task-log__name { + min-width: 0; + overflow: hidden; + font-size: 14px; + font-weight: 500; + text-overflow: ellipsis; + white-space: nowrap; +} + +.task-log__statuses { + display: flex; + flex-wrap: wrap; + gap: 6px; + justify-self: end; +} + +.task-log__details { + margin: 0 6px 10px 64px; + padding: 10px 12px 12px; + background: #f8fafc; + border-left: 2px solid #d0d5dd; +} + +.task-log__details-heading { + display: flex; + align-items: center; + justify-content: space-between; + color: #475467; + font-size: 13px; + font-weight: 500; +} + +.task-log__details-count, +.task-log__nodes { + color: #98a2b3; + font-size: 12px; + font-weight: 400; +} + +.task-log__nodes { + margin-top: 6px; + line-height: 18px; + word-break: break-word; +} + +.task-log__details :deep(.task-log) { + margin-top: 8px; + border-color: #eaecf0; +} + +.task-log__empty, +.task-log__details-empty { + padding: 28px 12px; + color: #98a2b3; + font-size: 13px; + text-align: center; +} + +.task-log__details-empty { + padding: 18px 0 6px; +} + +@media (max-width: 640px) { + .task-log__details { + margin-left: 12px; + } + + .task-log__heading, + .task-log__group-header { + grid-template-columns: 22px 26px minmax(0, 1fr) auto; + gap: 6px; + } +} + diff --git a/src/views/inspection/runTask/task-steps.vue b/src/views/inspection/runTask/task-steps.vue index f1d7ea3..6d7e595 100644 --- a/src/views/inspection/runTask/task-steps.vue +++ b/src/views/inspection/runTask/task-steps.vue @@ -1,8 +1,13 @@