无人机管理后台前端(已迁走)
zhongrj
2024-11-22 f86a1b2bcc9787b02fa831f781f4314c7d7c9b74
固件升级修改
1 files modified
48 ■■■■■ changed files
src/views/device/airport.vue 48 ●●●●● patch | view | raw | blame | history
src/views/device/airport.vue
@@ -137,9 +137,14 @@
    </el-dialog>
    <el-dialog title="固件版本管理" append-to-body v-model="rollFirmwareBox" width="455px">
      <div style="display: flex;flex-direction: row;align-items: center ">
      <div style="display: flex; flex-direction: row; align-items: center">
        固件版本升级/回退:
        <el-select v-model="rollFirmVersion" clearable placeholder="请选择固件版本" style="width: 240px">
        <el-select
          v-model="rollFirmVersion"
          clearable
          placeholder="请选择固件版本"
          style="width: 240px"
        >
          <el-option
            v-for="item in firmList"
            :key="item.firmware_version"
@@ -206,7 +211,7 @@
  data() {
    return {
      rollFirmVersion:'',
      rollFirmVersion: '',
      firmList: [],
      rollFirmwareBox: false,
      // 用于记录已经创建的websocket,防止重复创建
@@ -626,11 +631,29 @@
        // 3-普通升级,2-一致性升级;
        that.firmwareInfo['firmware_upgrade_type'] = 3;
        that.firmwareInfo['workspaceId'] = row.workspace_id;
        // domain 0:飞机  3:机场
        that.firmwareInfo['domain'] = row.domain;
        that.firmwareInfo['child_sn'] = row.child_sn;
        that.firmwareInfo['now_version'] = row.firmware_version;
      });
    },
    // 比较版本大小
    compare(version1, version2) {
      let arr1 = version1.split('.');
      let arr2 = version2.split('.');
      let length = Math.max(arr1.length, arr2.length);
      for (let i = 0; i < length; i++) {
        const n1 = Number(arr1[i] || 0);
        const n2 = Number(arr2[i] || 0);
        // version1 > version2 返回1,如果 version1 < version2 返回-1,不然返回0
        if (n1 > n2) return 1;
        if (n1 < n2) return -1;
      }
      return 0;
    },
    // 版本回退
    rollFirmwareConfirm() {
      if(this.rollFirmVersion==''){
      if (this.rollFirmVersion == '') {
        this.$message({
          type: 'warning',
          message: '请先选择回退的固件版本!',
@@ -640,7 +663,24 @@
      var that = this;
      var arr = [];
      that.firmwareInfo['product_version'] = this.rollFirmVersion;
      // 无人机升级/回滚
      arr.push(that.firmwareInfo);
      //判断是机场升级还是飞机升级,如果是机场升级则把无人机信息一起带过去
      // if (that.firmwareInfo.domain === 3) {
      //   // 机场升级
      //   arr.push(that.firmwareInfo);
      //   // 比对当前版本和需要升级/回滚版本,如果是升级则一起升级,如果是降级就单个进行(一起降级时飞机有回滚机制会失败)
      //   var verFlag = this.compare(this.rollFirmVersion, that.firmwareInfo.now_version);
      //   if (verFlag == 1) {
      //     // 升级
      //     arr.push({
      //       sn: that.firmwareInfo.child_sn,
      //       product_version: this.rollFirmVersion,
      //       firmware_upgrade_type: 3,
      //     });
      //   }
      // }
      // console.log(arr,888)
      ota(that.firmwareInfo.workspaceId, arr).then(res => {
        that.firmwareVersion = '';
        that.firmwareInfo = {};