HistoryConfigToDevice.vue 7.82 KB
Newer Older
YazhouChen's avatar
YazhouChen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
<template>
  <!-- 查看配置历史对话框 -->
  <el-dialog v-dialogDrag
             @close="close"
             style="font-size: 10px; " width='600px'
             :title="$t('DeviceConfigurationManagement.configurationHistory')"
             v-if="ConfigFileHistory"
             :visible.sync="ConfigFileHistory">

    <el-table
      :row-class-name="tableRowClassName"
      header-row-class-name="table-header"
      cell-class-name="table-cell"
      height="350"
      ref="singleTable"
      :data="historyConfList"
      stripe
      tooltip-effect="dark"
      @current-change="handleCurrentChange"
      @selection-change="handleSelectionChangeRestory">
      <el-table-column
        type="selection"
        :selectable='checkboxTHistory'
        width="28">
      </el-table-column>
      <el-table-column
        prop="configFileName"
        :label="$t('ProfileManagement.configFileName')"
        :show-overflow-tooltip="true">

      </el-table-column>
      <el-table-column
        prop="source"
        :label="$t('ProfileManagement.source')"
        :show-overflow-tooltip="true"
        :formatter="formatHistorySource">
      </el-table-column>

      <el-table-column
        prop="modifyTime"
        :label="$t('DeviceConfigurationManagement.modifyTime')"
        :show-overflow-tooltip="true">
      </el-table-column>

    </el-table>


    <el-row style="line-height: 30px;" slot="footer" class="dialog-footer">
      <el-checkbox style="margin:0px;position: absolute;left:14px;" v-model="flagCopy">
        {{$t("ProfileManagement.effectiveImmediately")}}
      </el-checkbox>
      <el-button size='mini' type="primary" @click="restoreProfile"
                 v-loading.fullscreen.lock="fullscreenLoading">{{$t("DeviceConfigurationManagement.restore")}}
      </el-button>
      <el-button size='mini' @click="close">
        {{$t("common.cancel")}}
      </el-button>
    </el-row>
  </el-dialog>


</template>

<script>
  let curThis = '';

  import ConfigFileService from '@/domain/services/ConfigFileService.js'
  import DeviceService from '@/domain/services/DeviceService.js'
  import HelperUtil from '../../../utils/HelperUtil'
  export default {


    props: ['command'],

    data() {
      return {
        historyConfList: [],

        //为了禁用当前行
        currentIndex: -1,

        //是否立即生效提示
        restoryToDeviceFlag: -1,
        flagCopy: false,

        multipleSelectionHistory: [],

        ConfigFileHistory: true,
        currentDeviceKey: this.command.target,
        // 数据加载过程中,覆盖界面
        fullscreenLoading: false,
      };
    },
    methods: {
      //历史配置文件:复选框
      checkboxTHistory(row, rowIndex) {
        if (rowIndex == 0) {
          return false;
        } else {
          return true;
        }
      },

      //标红历史配置文件第一行
      tableRowClassName({row, rowIndex}) {
        if (rowIndex === 0) {
          return 'warning-row';
        }
        return '';
      },

      close() {
        this.command.done()
      },


      /**
       * @Description  :过滤历史配置页面
       */
      formatHistorySource: function (row, column) {

        if (row.source == 0) {
          return '上传'
        }
        else if (row.source == 1) {
          return '下载'
        }

      },

      /**
       * @Description  :设备配置恢复表格多选框改变时,将所选行进行保存
       * @author       :
       * @param        :
       * @return       :
       * @exception    :
       * @date         :
       */
      handleSelectionChangeRestory(val) {
        this.multipleSelectionHistory = val
      },


      /**
       * @Description  :获取全部配历史配置信息
       * @author       ::
       * @date         :
       */
      getAllHistory(vue) {

        var selectList = new Array()
        selectList.push({
          quaryAttribute: 'deviceKey',
          compareSymbol: '=',
          compareValue: this.currentDeviceKey,
        })
        console.log(selectList)
//        const loading = vue.$loading({
//          lock: true,
//          text: 'Loading',
//          spinner: 'el-icon-loading',
//          background: 'rgba(0, 0, 0, 0.7)',
//          target: document.querySelector('.el-row')
//        });
        let _this = this;
        DeviceService.getDeviceHistoryConfig(selectList).then(result => {
          //成功
          vue.historyConfList = Object.values(result)

//          loading.close();
        }).catch(err => {
          //失败
          _this.InfoTip.errorTip(_this,err);
//          loading.close();
        })

      },

      /**
       * @Description  :第二步:恢复配置信息选中条数验证
       * @author       :
       * @param        :
       * @date         :
       */
      restoreProfile: function () {
        if (this.multipleSelectionHistory.length == 0) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.UPDATE_SELECT_CODE))
          return
        }
        else if (this.multipleSelectionHistory.length > 1) {
          this.InfoTip.warningTip(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.UPDATE_ONLY_ONE_CODE))
          return
        }
        else {
          //生效提示
          this.restoryEffectiveTip()


        }
      },

      /**
       * @Description  :第三步:恢复配置信息生效提示
       * @author       :
       * @param        :
       * @date         :
       */
      restoryEffectiveTip: function () {
        if (this.flagCopy == true) {
          this.$confirm(this.$t("ProfileManagement.EffectiveImmediatelyRebootNow"),
            this.$t("ProfileManagement.Attention") , {
              confirmButtonText:  this.$t("common.ok"),
              cancelButtonText: this.$t("common.cancel"),
              type: 'warning',
              center: true
            }).then(() => {
            this.restoryToDeviceFlag = 1
            this.$options.methods.restoryToDevice(this)

          }).catch(() => {
//            this.$message({
//              type: 'info',
//              message: '已取消'
//            });
          });
        }
        else if (this.flagCopy == false) {
          this.$confirm(this.$t("ProfileManagement.NotEffectiveImmediatelyNotRebootNow"),
            this.$t("ProfileManagement.Attention"), {
              confirmButtonText:  this.$t("common.ok"),
              cancelButtonText: this.$t("common.cancel"),
              type: 'warning',
              center: true
          }).then(() => {
            this.restoryToDeviceFlag = 0
            this.$options.methods.restoryToDevice(this)

          }).catch(() => {
//            this.$message({
//              type: 'info',
//              message: '已取消'
//            });
          });
        }
      },

      /**
       * @Description  :第四步:恢复配置信息
       * @author       :
       * @param        :
       * @date         :
       */
      restoryToDevice: function (vue) {
        let _this = vue;
//        //传参
        var selectDeviceList = new Array()
        selectDeviceList[0] = _this.currentDeviceKey

        let loadingInstance = _this.Loading.openLoading();
        ConfigFileService.downloadConfigToDevice(
          _this.multipleSelectionHistory[0].configFileKey,
          _this.restoryToDeviceFlag, selectDeviceList).then(result => {
          //成功
          _this.InfoTip.successTip(_this,HelperUtil.getStatusCodeObjectByCode(_this.successCode.OTHERS_CODE));
          _this.Loading.closeLoading(loadingInstance);
          _this.close()
        }).catch(err => {
          _this.InfoTip.errorTip(_this,err);
          //失败
          _this.Loading.closeLoading(loadingInstance);
//          _this.close()
        })
      },

    },
    watch: {},
    created() {
      curThis = this
      this.getAllHistory(this)

    },

  };
</script>

<style scoped>


</style>