<template>
  <div class="border-style">
    <div class="inner-style">
      <div class="statelist">
        <div class="white-border"></div>
        <div class="align-center">
          <div class="name">{{ name }}</div>
          <div class="statement">{{ statement }}</div>
          <div class="warn"><img src="../assets/warn.png" v-if="logInfo"><span>{{ logInfo }}</span></div>
        </div>
      </div>
      <div class="timestate">
        <div class="times" v-if="swapTime">
          换电时间：<font>{{ swapTime }}</font>
        </div>  
        <div class="store-list active" @click="changePower" v-if="logInfo">开始换电</div>
      </div>
    </div>
  </div>
</template>

<script>
import { beginSwap } from '@/api/equipment'
export default {
  name: "SubTitle",
  props: ["name", "statement","logInfo","swapTime"],
  methods:{
    // 手动发起换电
    changePower() {
      this.loading=true
      this.$confirm('请确认站控系统手动发起换电？', '开始换电', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async() => {
          const res = await beginSwap()
          if(res.code === 0){
              this.$message({
              type: 'success',
              message: res.data,
            })
          }else{
              this.$message({
              type: 'warning',
              message: res.msg,
            })
          }
          this.loading=false
        })
        .catch(err => { console.error(err) })
    },
  }
};
</script>

<style scoped>
.timestate{
  display: flex;
  align-items: center;
}
.times {
  color: #596189;
  font-size: 14px;
  font-weight: 600;
  margin-right: 40px;
}
.times font{
  color: white;
  font-size: 14px;
}
.warn{
  color: red;
  font-size: 14px;
  display: flex;
}
.warn img{
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 5px;
}
.border-style {
  border: 1px solid rgb(25, 34, 51);
  padding: 3px;
}
.inner-style {
  background: #121a29;
  padding: 3px;
  display: flex;
  height: 38px;
  flex-direction: row;
  justify-content: space-between;
}
.statelist{
  display: flex;
}
.white-border {
  width: 28px;
  height: 18px;
  background-image: url("../assets/ico2.png");
  background-size: 100% 100%;
}
.align-center {
  display: flex;
  margin: 0 5px;
  align-items: center;
}
.name {
  color: white;
  font-size: 1.2rem;
  font-weight: 600;
  text-shadow: 0 0 3px #1753ce,0 0 4px #1753ce,0 0 3px #1753ce,0 0 3px #1753ce;
  margin-left: -4.2%;
}
.statement {
  color: #324264;
  font-size: 0.6rem;
  margin: 0 8px;
  font-weight: 600;
  padding-top: 6px;
  width: 220px;
}
.store-list {
  padding: 0 12px;
  height: 32px;
  text-align: center;
  line-height: 32px;
  border: #414a63 solid 1px;
  color: #84988c;
  font-size: 14px;
  font-weight: 600;
  margin-right: 15px;
  cursor: pointer;
}

.active {
  border: #91fdb9 solid 1px;
  color: #91fdb9;
}
</style>
