<template>
    <div class="charge-table">
      <div class="charge-table-bottom">
        <control-box
          title="架载机温度配置"
          img="c1"
          :showTemp="showTemp"
          @handleset="handleset"
          @handleDefault="resetTemp"
          unit="(°C)"
        ></control-box>
      </div>
      <!--设置弹窗-->
      <div class="rolemanage chargeshow">
        <el-dialog
          :title="`设置${dialogtext.title}`"
          :visible.sync="dialogConfigVisible"
          :destroy-on-close="true"
        >
          <div class="setConfig">
            <span>温度(°C)：</span>
            <el-input v-model="tempValue" placeholder="请输入温度"></el-input>
            <el-button type="primary" class="set" @click="handleSave">保存</el-button>
          </div>
        </el-dialog>
      </div>
      <!--设置弹窗结束-->
    </div>
  </template>
  
  <script>
  import { serchTemp,setTemp } from '@/api/statistics'
  import ControlBox from './components/ControlBox.vue'
  export default {
    name: "SetFile",
    components:{
      ControlBox
    },
    data() {
      return {
        ws: null,
        dialogConfigVisible: false,
        tempValue: "",
        showTemp:undefined,
        dialogtext: {}
      };
    },
    mounted() {
      this.showSerchTemp()
    },
    destroyed() {
      
    },
    methods: {
      handleset(obj) {
        this.dialogtext=obj
        this.dialogConfigVisible = true;
      },
      handleSave(){
        setTemp(this.tempValue).then(res=>{
          this.showTemp=this.tempValue
          if(res.code === 0){
            this.$message({
                type: 'success',
                message: '设置成功！'
            })
            this.dialogConfigVisible = false;
          }
        })
      },
      showSerchTemp(){
        serchTemp().then(res=>{
          this.showTemp=res.data
        })
      },
      resetTemp(){
        setTemp(90).then(res=>{
          if(res.code === 0){
            this.showTemp=90
            this.$message({
                type: 'success',
                message: '恢复成功！'
            })
          }
        })
      }
    },
  };
  </script>
  
  <style lang="scss" scoped>
  .setConfig {
    margin: 35px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 45px;
  
    span {
      color: #fff;
      font-size: 15px;
      text-align: right;
    }
  
    .el-input {
      width: 240px;
      margin-right: 15px;
    }
  }
  
  .set {
    background-color: #91fdb9;
    color: #0b111d;
    border-color: #91fdb9;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 0px 15px;
    height: 36px;
  }
  
  .charge-table {
    padding: 50px;
    background-color: #111827;
    border: #192337 solid 1px;
    min-height: 68vh;
    margin: 35px;
    margin-top: 0px;
    display: flex;
    flex-direction: column;
  
    .charge-table-bottom {
      width: 100%;
      min-height: 100%;
      background-color: #111827;
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
  
      
    }
  }
  </style>