From a574bcc5aa2a90d01a282ca69f433f061ff35b26 Mon Sep 17 00:00:00 2001 From: kerwincui <164770707@qq.com> Date: Thu, 16 Jun 2022 23:41:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BA=E4=BB=B6=E5=8D=87=E7=BA=A7=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/src/api/iot/firmware.js | 8 +++ vue/src/views/iot/device/running-status.vue | 51 +++++++++++++++++-- vue/src/views/iot/firmware/index.vue | 31 ++++++----- vue/src/views/iot/product/index.vue | 6 +-- .../views/iot/product/product-authorize.vue | 2 +- .../views/iot/product/product-firmware.vue | 38 +++++++++----- 6 files changed, 100 insertions(+), 36 deletions(-) diff --git a/vue/src/api/iot/firmware.js b/vue/src/api/iot/firmware.js index 3f4719d9..6b93c6fd 100644 --- a/vue/src/api/iot/firmware.js +++ b/vue/src/api/iot/firmware.js @@ -9,6 +9,14 @@ export function listFirmware(query) { }) } +// 查询设备最新固件 +export function getLatestFirmware(deviceId) { + return request({ + url: '/iot/firmware/getLatest/' + deviceId, + method: 'get' + }) +} + // 查询产品固件详细 export function getFirmware(firmwareId) { return request({ diff --git a/vue/src/views/iot/device/running-status.vue b/vue/src/views/iot/device/running-status.vue index 52566480..ed26c047 100644 --- a/vue/src/views/iot/device/running-status.vue +++ b/vue/src/views/iot/device/running-status.vue @@ -10,8 +10,7 @@ OTA升级 Version {{deviceInfo.firmwareVersion}} - 已经是最新版本 - 升级 + 检查更新 @@ -165,6 +164,27 @@ + + + +
已经是最新版本,不需要升级
+ + + {{firmware.firmwareName}} + {{firmware.productName}} + Version {{firmware.version}} + + {{getDownloadUrl(firmware.filePath)}} + + {{firmware.remark}} + + +
@@ -172,6 +192,9 @@ import { getDeviceRunningStatus } from "@/api/iot/device" +import { + getLatestFirmware, +} from "@/api/iot/firmware"; import { cacheJsonThingsModel } from "@/api/iot/model"; @@ -195,7 +218,6 @@ export default { if (newVal && newVal.deviceId != 0) { getDeviceRunningStatus(newVal.deviceId).then(response => { this.deviceInfo = response.data; - console.log(this.deviceInfo); this.updateDeviceStatus(this.deviceInfo); this.$nextTick(function () { this.MonitorChart(); @@ -221,6 +243,10 @@ export default { background: '#67C23A', color: '#fff', }, + // 最新固件信息 + firmware: {}, + // 打开固件对话框 + openFirmware: false, // 遮罩层 loading: true, // 设备信息 @@ -295,7 +321,7 @@ export default { } else if (type == 3) { // OTA升级 topic = "/" + device.productId + "/" + device.serialNumber + "/ota/get"; - message = '{"version":' + device.firmwareVersion + '}'; + message = '{"version":' + this.firmware.version + ',"downloadUrl":"' + this.getDownloadUrl(this.firmware.filePath) + '"}'; } else { return; } @@ -348,10 +374,25 @@ export default { let model = {}; model.name = "设备升级" this.mqttPublish(3, this.deviceInfo, model); + this.openFirmware = false; + }, + /** 修改按钮操作 */ + getLatestFirmware(deviceId) { + getLatestFirmware(deviceId).then(response => { + this.firmware = response.data; + this.openFirmware = true; + }); + }, + // 取消按钮 + cancel() { + this.openFirmware = false; + }, + // 获取下载路径前缀 + getDownloadUrl(path) { + return window.location.origin + process.env.VUE_APP_BASE_API + path; }, /**监测图表统计*/ MonitorChart() { - console.log(this.deviceInfo.readOnlyList.length); for (let i = 0; i < this.deviceInfo.readOnlyList.length; i++) { var myChart = echarts.init(this.$refs.map[i]); var option; diff --git a/vue/src/views/iot/firmware/index.vue b/vue/src/views/iot/firmware/index.vue index 1d936aa3..1fa0bfcc 100644 --- a/vue/src/views/iot/firmware/index.vue +++ b/vue/src/views/iot/firmware/index.vue @@ -21,28 +21,33 @@ + + + + + + + + + - - + - - - - - - - + -
提示:查找不到设备,可能已经被删除
+
提示:查找不到设备,可能已经被删除
{{device.deviceId}} {{device.deviceName}} diff --git a/vue/src/views/iot/product/product-firmware.vue b/vue/src/views/iot/product/product-firmware.vue index 1a8d94ef..deea8e30 100644 --- a/vue/src/views/iot/product/product-firmware.vue +++ b/vue/src/views/iot/product/product-firmware.vue @@ -11,22 +11,28 @@ - + - + - + - + + + +