固件升级完善

This commit is contained in:
kerwincui
2022-06-16 23:41:15 +08:00
parent b2fb001618
commit a574bcc5aa
6 changed files with 100 additions and 36 deletions

View File

@@ -10,8 +10,7 @@
OTA升级
</template>
<el-link :underline="false" style="line-height:28px;font-size:16px;padding-right:10px;">Version {{deviceInfo.firmwareVersion}}</el-link>
<el-link type="success" :underline="false" style="font-size:12px;display:none;">已经是最新版本</el-link>
<el-button type="success" size="mini" style="float:right;" @click="otaUpgrade()" :disabled="deviceInfo.status!=3">升级</el-button>
<el-button type="success" size="mini" style="float:right;" @click="getLatestFirmware(deviceInfo.deviceId)" :disabled="deviceInfo.status!=3">检查更新</el-button>
</el-descriptions-item>
<!-- bool类型-->
<el-descriptions-item v-for="(item,index) in deviceInfo.boolList" :key="index" :labelStyle="statusColor">
@@ -165,6 +164,27 @@
</el-row>
</el-col>
</el-row>
<!-- 添加或修改产品固件对话框 -->
<el-dialog title="设备固件升级" :visible.sync="openFirmware" width="600px" append-to-body>
<div v-if="firmware==null || deviceInfo.firmwareVersion>=firmware.version" style="text-align:center;font-size:16px;"><i class="el-icon-success" style="color:#67C23A;"></i> 已经是最新版本不需要升级</div>
<el-descriptions :column="1" border size="large" v-if="firmware!=null && deviceInfo.firmwareVersion<firmware.version" :labelStyle='{"width":"100px","font-weight":"bold"}'>
<template slot="title">
<el-link icon="el-icon-success" type="success" :underline="false"> 可以升级到以下版本</el-link>
</template>
<el-descriptions-item label="固件名称">{{firmware.firmwareName}}</el-descriptions-item>
<el-descriptions-item label="所属产品">{{firmware.productName}}</el-descriptions-item>
<el-descriptions-item label="固件版本">Version {{firmware.version}}</el-descriptions-item>
<el-descriptions-item label="下载地址">
<el-link :href="getDownloadUrl(firmware.filePath)" :underline="false" type="primary">{{getDownloadUrl(firmware.filePath)}}</el-link>
</el-descriptions-item>
<el-descriptions-item label="固件描述">{{firmware.remark}}</el-descriptions-item>
</el-descriptions>
<div slot="footer" class="dialog-footer">
<el-button type="success" @click="otaUpgrade" v-if="firmware!=null && deviceInfo.firmwareVersion<firmware.version"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
@@ -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;

View File

@@ -21,28 +21,33 @@
<el-card style="padding-bottom:100px;">
<el-table v-loading="loading" :data="firmwareList" @selection-change="handleSelectionChange">
<el-table-column label="固件名称" align="center" prop="firmwareName" />
<el-table-column label="固件版本" align="center" prop="version" width="120">
<template slot-scope="scope">
<span>Version </span> {{scope.row.version}}
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="isLatest" width="80">
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.isLatest==1">最新</el-tag>
<el-tag type="info" v-else>默认</el-tag>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="产品名称" align="center" prop="productName">
<template slot-scope="scope">
<el-link :underline="false" type="primary" @click="handleViewProduct(scope.row.productId)">{{scope.row.productName}}</el-link>
</template>
</el-table-column>
<el-table-column label="下载地址" align="center" prop="filePath" width="400">
<el-table-column label="下载地址" align="center" prop="filePath" min-width="100">
<template slot-scope="scope">
<el-link :href="getDownloadUrl(scope.row.filePath)" :underline="false" type="success">{{getDownloadUrl(scope.row.filePath)}}</el-link>
</template>
</el-table-column>
<el-table-column label="固件版本" align="center" prop="version">
<template slot-scope="scope">
<span>Version </span> {{scope.row.version}}
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="固件描述" align="center" prop="remark" min-width="200" />
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
<template slot-scope="scope">
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:firmware:edit']">修改</el-button>

View File

@@ -28,7 +28,7 @@
<el-card :body-style="{ padding: '20px'}" shadow="always" class="card-item">
<el-row type="flex" :gutter="10" justify="space-between">
<el-col :span="20" style="text-align:left;">
<el-link type="" :underline="false" @click="handleEditProduct(item)" style="font-weight:bold;font-size:16px;line-height:32px;">
<el-link type="" :underline="false" @click="handleEditProduct(item)" style="font-weight:bold;font-size:16px;line-height:32px;white-space:nowrap;">
<svg-icon icon-class="product" /> {{item.productName}}
<el-tag type="info" size="mini" style="margin-left:5px;font-weight:200" v-if="item.isSys==1">系统</el-tag>
</el-link>
@@ -44,7 +44,7 @@
</el-row>
<el-row :gutter="10">
<el-col :span="14">
<el-descriptions :column="1" size="small" style="margin-top:10px;">
<el-descriptions :column="1" size="small" style="margin-top:10px;white-space:nowrap;">
<el-descriptions-item label="所属分类">
<el-link type="primary" :underline="false">{{item.categoryName}}</el-link>
</el-descriptions-item>
@@ -67,7 +67,7 @@
</div>
</el-col>
</el-row>
<el-button-group style="margin-top:15px;">
<el-button-group style="margin-top:15px;height:28px;">
<el-button size="mini" type="primary" icon="el-icon-edit" @click="handleEditProduct(item)" v-hasPermi="['iot:product:edit']">详情</el-button>
<el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(item)" v-hasPermi="['iot:product:remove']" v-if="item.status==1">删除</el-button>
<el-button size="mini" type="success" icon="el-icon-s-check" @click="handleDeviceAuthorize(item)" v-hasPermi="['iot:product:edit']" v-if="item.status==2" :disabled="item.isAuthorize!=1">设备授权</el-button>

View File

@@ -108,7 +108,7 @@
<!-- 设备详情对话框 -->
<el-dialog title="设备详情" :visible.sync="openDevice" width="600px" append-to-body>
<div v-if="device==null" style="text-align:center;">提示查找不到设备可能已经被删除</div>
<div v-if="device==null" style="text-align:center;"><i class="el-icon-warning" style="color:#E6A23C;"></i> 提示查找不到设备可能已经被删除</div>
<el-descriptions border :column="2" size="medium" v-if="device!=null">
<el-descriptions-item label="设备ID">{{device.deviceId}}</el-descriptions-item>
<el-descriptions-item label="设备名称">{{device.deviceName}}</el-descriptions-item>

View File

@@ -11,22 +11,28 @@
<el-table v-loading="loading" :data="firmwareList" @selection-change="handleSelectionChange" size="small">
<el-table-column label="固件名称" align="center" prop="firmwareName" />
<el-table-column label="固件版本" align="center" prop="version">
<el-table-column label="固件版本" align="center" prop="version" width="120">
<template slot-scope="scope">
<span>Version </span> {{scope.row.version}}
</template>
</el-table-column>
<el-table-column label="下载地址" align="center" prop="filePath" width="400">
<el-table-column label="状态" align="center" prop="isLatest" width="80">
<template slot-scope="scope">
<el-link :href="getDownloadUrl(scope.row.filePath)" :underline="false" type="success">{{getDownloadUrl(scope.row.filePath)}}</el-link>
<el-tag type="success" v-if="scope.row.isLatest==1">最新</el-tag>
<el-tag type="info" v-else>默认</el-tag>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime">
<el-table-column label="创建时间" align="center" prop="createTime" width="100">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="下载地址" align="center" prop="filePath" min-width="100">
<template slot-scope="scope">
<el-link :href="getDownloadUrl(scope.row.filePath)" :underline="false" type="success">{{getDownloadUrl(scope.row.filePath)}}</el-link>
</template>
</el-table-column>
<el-table-column label="固件描述" align="center" prop="remark" min-width="200" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="200">
<template slot-scope="scope">
<el-button size="small" type="primary" style="padding:5px;" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['iot:firmware:edit']">修改</el-button>
@@ -44,12 +50,16 @@
<el-form-item label="固件版本" prop="version">
<el-input v-model="form.version" placeholder="请输入固件版本" type="number" step="0.1" />
</el-form-item>
<el-form-item label="最新固件" prop="isLatest">
<el-switch v-model="form.isLatest" active-text="" inactive-text="" :active-value="1" :inactive-value="0">
</el-switch>
<el-link type="info" :underline="false" style="font-size:12px;margin-left:15px;">提示产品中只能有一个最新固件</el-link>
</el-form-item>
<el-form-item label="固件上传" prop="filePath">
<fileUpload ref="file-upload" :value="form.filePath" :limit="1" :fileSize="10" :fileType='["bin", "zip", "pdf"]' @input="getFilePath($event)"></fileUpload>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
<el-form-item label="固件描述" prop="remark">
<el-input v-model="form.remark" type="textarea" rows="4" placeholder="请输入固件信息" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@@ -92,8 +102,8 @@ export default {
this.productInfo = newVal;
if (this.productInfo && this.productInfo.productId != 0) {
this.queryParams.productId = this.productInfo.productId;
this.form.productId=this.productInfo.productId;
this.form.productName=this.productInfo.productName;
this.form.productId = this.productInfo.productId;
this.form.productName = this.productInfo.productName;
this.getList();
}
}
@@ -167,8 +177,7 @@ export default {
};
},
created() {
},
created() {},
methods: {
getDownloadUrl(path) {
return window.location.origin + process.env.VUE_APP_BASE_API + path;
@@ -194,9 +203,10 @@ export default {
firmwareName: null,
tenantId: null,
tenantName: null,
productId:this.form.productId,
productName:this.form.productName,
productId: this.form.productId,
productName: this.form.productName,
isSys: null,
isLatest: 0,
version: 1.0,
filePath: null,
delFlag: null,