diff --git a/.env.development b/.env.development index 05e0632..07fc129 100644 --- a/.env.development +++ b/.env.development @@ -11,6 +11,7 @@ VUE_APP_BASE_API = '/dev-api' VUE_CLI_BABEL_TRANSPILE_MODULES = true # 后端接口地址 +# VUE_APP_SERVER_API_URL = 'http://1.94.62.14:8080/' VUE_APP_SERVER_API_URL = 'http://localhost:8080/' # Mqtt消息服务器连接地址 diff --git a/.vscode/settings.json b/.vscode/settings.json index aa408f0..af8eeb9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -9,5 +9,8 @@ "i18n-ally.displayLanguage": "zh-CN", "[javascript]": { "editor.defaultFormatter": "vscode.typescript-language-features" + }, + "[vue]": { + "editor.defaultFormatter": "Vue.volar" } // 显示文件 } diff --git a/dist.zip b/dist.zip index e9b444c..0d8c83c 100644 Binary files a/dist.zip and b/dist.zip differ diff --git a/package.json b/package.json index 949e4c2..920ea35 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "babel-eslint": "10.1.0", "babel-plugin-dynamic-import-node": "^2.3.3", "chalk": "4.1.0", - "code-inspector-plugin": "^0.20.10", + "code-inspector-plugin": "^0.20.12", "compression-webpack-plugin": "5.0.2", "connect": "3.6.6", "eslint": "^7.28.0", diff --git a/src/lang/zh-CN/device.json b/src/lang/zh-CN/device.json index 961f980..3c448b4 100644 --- a/src/lang/zh-CN/device.json +++ b/src/lang/zh-CN/device.json @@ -603,6 +603,7 @@ "device.running-status.866086-44": "查看版本", "device.running-status.866086-45": "只读属性", "device.running-status.866086-46": "非历史存储", + "device.running-status.866086-47": "您当前最新固件的版本号小于设备当前版本号,请检查固件版本是否正确", "device.sub.083943-0": "添加子设备", "device.sub.083943-1": "移除子设备", "device.sub.083943-2": "设置子设备地址", diff --git a/src/views/iot/device/device-instruction-config.vue b/src/views/iot/device/device-instruction-config.vue new file mode 100644 index 0000000..3f8a328 --- /dev/null +++ b/src/views/iot/device/device-instruction-config.vue @@ -0,0 +1,716 @@ + + + + + diff --git a/src/views/iot/device/relay.vue b/src/views/iot/device/relay.vue index b9f2beb..3fe394f 100644 --- a/src/views/iot/device/relay.vue +++ b/src/views/iot/device/relay.vue @@ -489,13 +489,13 @@ - - + + style="width: 350px" disabled> @@ -507,6 +507,7 @@ +
{{ @@ -519,34 +520,39 @@ -
+
{{ $t('device.running-status.866086-11') }}
- + + {{ $t('device.running-status.866086-47') }} +
+ {{ firmware.firmwareName - }} + }} {{ firmware.productName - }} + }} Version {{ firmware.version - }} + }} {{ getDownloadUrl(firmware.filePath) }} {{ firmware.remark - }} + }}
@@ -1066,6 +1072,24 @@ export default { cancel1() { this.openVersion = false; }, + // 添加版本比较方法 + compareVersions(version1, version2) { + // 移除可能的'Version'前缀 + version1 = String(version1).replace('Version', '').trim(); + version2 = String(version2).replace('Version', '').trim(); + + const v1Parts = version1.split('.').map(Number); + const v2Parts = version2.split('.').map(Number); + + for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) { + const v1 = v1Parts[i] || 0; + const v2 = v2Parts[i] || 0; + + if (v1 < v2) return true; + if (v1 > v2) return false; + } + return false; + }, /** 更新设备状态 */ updateDeviceStatus(device) { if (device.status == 3) { diff --git a/src/views/iot/device/running-status.vue b/src/views/iot/device/running-status.vue index 00f3664..c93bd02 100644 --- a/src/views/iot/device/running-status.vue +++ b/src/views/iot/device/running-status.vue @@ -17,133 +17,180 @@ {{ $t('device.running-status.866086-1') }} - {{ - $t('device.running-status.866086-44') - }} + {{ $t('device.running-status.866086-44') }} - +
- +
- + :class="{ 'is-active-btn': subItem.value === item.shadow }" + > {{ subItem.text }}
- - + +
- - + + v-if="!shadowUnEnable && item.isReadonly == 0" + >
- +
- + v-if="!shadowUnEnable && item.isReadonly == 0" + >
- + :disabled="shadowUnEnable || item.isReadonly == 1" + >
- + v-if="!shadowUnEnable && item.isReadonly == 0" + >
- +
- + :disabled="shadowUnEnable || param.isReadonly == 1" + />
- + :class="{ 'is-active-btn': subItem.value === param.shadow }" + > {{ subItem.text }}
- - + :disabled="shadowUnEnable || param.isReadonly == 1" + > +
- - + + v-if="!shadowUnEnable && param.isReadonly == 0" + >
- - + + v-if="!shadowUnEnable && param.isReadonly == 0" + >
- - + + v-if="!shadowUnEnable && param.isReadonly == 0" + >
@@ -151,38 +198,61 @@
- +
- - + + v-if="!shadowUnEnable || item.isReadonly == 0" + >
- - + + v-if="!shadowUnEnable || item.isReadonly == 0" + >
- - + + v-if="!shadowUnEnable || item.isReadonly == 0" + >
@@ -196,63 +266,78 @@ - +
- + :disabled="shadowUnEnable || param.isReadonly == 1" + />
-
- + + :class="{ 'is-active-btn': subItem.value === param.shadow }" + > {{ subItem.text }}
- - + :disabled="shadowUnEnable || param.isReadonly == 1" + > +
- - + + v-if="!shadowUnEnable && param.isReadonly == 0" + >
- - + + v-if="!shadowUnEnable && param.isReadonly == 0" + >
- - + + v-if="!shadowUnEnable && param.isReadonly == 0" + >
@@ -264,100 +349,80 @@
- + - +
- +
- {{ subItem.text - }} + {{ subItem.text }}
- - + +
- +
- +
- +
- +
- +
- - + +
- +
- +
- +
- +
- +
- +
- +
@@ -370,37 +435,32 @@ - +
- +
- - + +
- +
- +
- +
@@ -414,77 +474,57 @@ - + -
-
+
- - - + - - + + - +
- {{ - $t('device.running-status.866086-42') }} + {{ $t('device.running-status.866086-42') }} {{ $t('cancel') }}
- +
{{ $t('device.running-status.866086-11') }}
- + - {{ firmware.firmwareName - }} - {{ firmware.productName - }} - Version {{ firmware.version - }} + {{ firmware.firmwareName }} + {{ firmware.productName }} + Version {{ firmware.version }} - {{ - getDownloadUrl(firmware.filePath) }} + {{ getDownloadUrl(firmware.filePath) }} - {{ firmware.remark - }} + {{ firmware.remark }}
@@ -515,7 +555,6 @@ export default { this.$nextTick(function () { this.MonitorChart(); }); - // console.log("物模型", JSON.stringify(this.deviceInfo.thingsModels)); //物模型排序 if (this.deviceInfo.thingsModels && this.deviceInfo.thingsModels.length > 0) { this.deviceInfo.thingsModels = this.device.thingsModels.sort((a, b) => b.order - a.order); @@ -632,7 +671,6 @@ export default { // 监听值的实时更新 this.$busEvent.$on('updateData', (params) => { this.updateParam(params); - // console.log("物模型", JSON.stringify(this.deviceInfo.thingsModels)); }); }, initDataStatus() { diff --git a/src/views/iot/device/voicecard.vue b/src/views/iot/device/voicecard.vue index 811ba12..618188b 100644 --- a/src/views/iot/device/voicecard.vue +++ b/src/views/iot/device/voicecard.vue @@ -83,7 +83,7 @@ - +
播放列表 @@ -205,7 +205,7 @@ + style="width: 350px" disabled> @@ -217,6 +217,7 @@ +
{{ @@ -229,34 +230,39 @@ -
+
{{ $t('device.running-status.866086-11') }}
- + + {{ $t('device.running-status.866086-47') }} +
+ {{ firmware.firmwareName - }} + }} {{ firmware.productName - }} + }} Version {{ firmware.version - }} + }} {{ getDownloadUrl(firmware.filePath) }} {{ firmware.remark - }} + }}
@@ -309,25 +315,33 @@
- - - - - +
+ 全天 +
+
+ + + + + +
- - 周一 - 周二 - 周三 - 周四 - 周五 - 周六 - 周日 - +
+ 全选 + + 周一 + 周二 + 周三 + 周四 + 周五 + 周六 + 周日 + +
@@ -514,7 +528,9 @@ export default { weekdays: [], radarEnabled: false, radarSpeedMin: 0, - radarSpeedMax: 120 + radarSpeedMax: 120, + isAllDay: false, + isAllWeek: false }, playlistRules: { audioId: [ @@ -710,7 +726,7 @@ export default { // 转换时间格式 const beginTime = this.formatSecondsToTime(item.time.begin); const endTime = this.formatSecondsToTime(item.time.end); - + // 转换星期格式 const weekdays = this.convertWeekToArray(item.time.week); @@ -955,6 +971,7 @@ export default { this.handleVersionInputChange(); }, + //选择改变 handleVersionInputChange() { if (this.firmwareParams.firmwareType == 1) { this.firmwareParams.versionInput = 'Version' + this.device.firmwareVersion; @@ -962,25 +979,79 @@ export default { this.firmwareParams.versionInput = 'Version' + this.device.wirelessVersion; } }, - cancel1() { this.openVersion = false; }, + // 添加版本比较方法 + compareVersions(version1, version2) { + // 移除可能的'Version'前缀 + version1 = String(version1).replace('Version', '').trim(); + version2 = String(version2).replace('Version', '').trim(); + + const v1Parts = version1.split('.').map(Number); + const v2Parts = version2.split('.').map(Number); + + for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) { + const v1 = v1Parts[i] || 0; + const v2 = v2Parts[i] || 0; + + if (v1 < v2) return true; + if (v1 > v2) return false; + } + return false; + }, + + /** 获取最新固件 */ getLatestFirmware() { const { deviceId, firmwareType } = this.deviceInfo; + if (!deviceId || !firmwareType) { + this.$message.error('设备信息不完整'); + return; + } getLatestFirmware(deviceId, firmwareType).then((response) => { if (response.code === 200) { - this.firmware = response.data; - this.openFirmware = true; + if (response.data) { + this.firmware = response.data; + // 添加版本比较的调试信息 + console.log('当前版本:', this.deviceInfo.firmwareVersion); + console.log('新版本:', this.firmware.version); + console.log('版本比较结果:', this.compareVersions(this.deviceInfo.firmwareVersion, this.firmware.version)); + this.openFirmware = true; + } else { + this.$message.info('当前已是最新版本'); + this.openFirmware = true; + } + } else { + this.$message.error(response.msg || '获取固件信息失败'); } + }).catch(error => { + console.error('获取固件信息失败:', error); + this.$message.error('获取固件信息失败'); }); }, + /** 设备升级 */ + otaUpgrade() { + // OTA升级 + let topic = '/' + this.deviceInfo.productId + '/' + this.deviceInfo.serialNumber + '/ota/get'; + let message = '{"version":' + this.firmware.version + ',"downloadUrl":"' + this.getDownloadUrl(this.firmware.filePath) + '"}'; + // 发布 + this.$mqttTool + .publish(topic, message, this.$t('device.running-status.866086-31')) + .then((res) => { + this.$modal.notifySuccess(res); + }) + .catch((res) => { + this.$modal.notifyError(res); + }); + this.openFirmware = false; + }, cancel() { this.openFirmware = false; }, + /** 获取下载路径 */ getDownloadUrl(path) { return window.location.origin + process.env.VUE_APP_BASE_API + path; }, @@ -1304,7 +1375,9 @@ export default { weekdays: [], radarEnabled: false, radarSpeedMin: 0, - radarSpeedMax: 120 + radarSpeedMax: 120, + isAllDay: false, + isAllWeek: false }; }, @@ -1338,8 +1411,8 @@ export default { }, time: { en: 1, - begin: this.convertTimeToSeconds(this.newPlaylist.playTimeStart), - end: this.convertTimeToSeconds(this.newPlaylist.playTimeEnd), + begin: this.newPlaylist.isAllDay ? 0 : this.convertTimeToSeconds(this.newPlaylist.playTimeStart), + end: this.newPlaylist.isAllDay ? 86399 : this.convertTimeToSeconds(this.newPlaylist.playTimeEnd), week: this.convertWeekArrayToValue(this.newPlaylist.weekdays) }, speed: { @@ -1502,7 +1575,27 @@ export default { this.$message.error('删除失败'); } } - }).catch(() => {}); + }).catch(() => { }); + }, + + /** 处理全天选择变化 */ + handleAllDayChange(val) { + if (val) { + // 设置为全天时,将时间设置为 00:00 到 23:59 + this.newPlaylist.playTimeStart = new Date(2000, 0, 1, 0, 0); + this.newPlaylist.playTimeEnd = new Date(2000, 0, 1, 23, 59); + } + }, + + /** 处理全选星期变化 */ + handleAllWeekChange(val) { + if (val) { + // 全选时,设置所有星期 + this.newPlaylist.weekdays = ['0', '1', '2', '3', '4', '5', '6']; + } else { + // 取消全选时,清空选择 + this.newPlaylist.weekdays = []; + } }, }, }; @@ -1799,12 +1892,27 @@ export default { .time-range { display: flex; - align-items: center; + flex-direction: column; gap: 10px; - .time-separator { - color: #606266; - font-size: 14px; + .time-header { + margin-bottom: 5px; + } + + .time-pickers { + display: flex; + align-items: center; + width: 100%; + + .time-separator { + margin: 0 10px; + } } } + +.weekday-select { + display: flex; + flex-direction: column; + gap: 10px; +} \ No newline at end of file diff --git a/src/views/iot/group/index.vue b/src/views/iot/group/index.vue index d58c330..afa41ab 100644 --- a/src/views/iot/group/index.vue +++ b/src/views/iot/group/index.vue @@ -1,9 +1,11 @@