
<template>
  <div class="pcs-ems-dashboard-editor-container">
    <real-time-base-info/>
    <el-container class="pcs-container">
      <el-header class="pcs-header">
        <div class="pcs-title">PCS</div>
        <div class="pcs-status">
          <div>通信中断</div>
          <div>数据更新时间：2024-10-11 12:00:00</div>
        </div>
        <div class="pcs-btns">
          <el-button type="warning" size="small" @click="problemSaved">故障复位</el-button>
          <el-button size="small" @click="machineClosed">关机</el-button>
        </div>
      </el-header>
      <el-main style="padding: 0">
        <div class="descriptions-main">
          <el-descriptions direction="vertical" :column="4" :colon="false">
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction danger"  :span="1" label="工作状态">停止</el-descriptions-item>
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction"  :span="1" label="并网状态">并网</el-descriptions-item>
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction save"  :span="1" label="设备状态">在线</el-descriptions-item>
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction"  :span="1" label="控制模式">远程</el-descriptions-item>
          </el-descriptions>
        </div>
        <div class="descriptions-main descriptions-main-bg-color">
          <el-descriptions labelClassName="descriptions-label" contentClassName="descriptions-direction" direction="vertical" :column="4" :colon="false">
            <el-descriptions-item v-for="(item,index) in infoData" :key="index+'pcsInfoData'" :span="1" :label="item.label">{{item.value}} <span v-if="item.unit" v-html="item.unit"></span></el-descriptions-item>
          </el-descriptions>
        </div>
        <div class="descriptions-main">
          <el-descriptions labelClassName="descriptions-label" contentClassName="descriptions-direction keep" direction="vertical" :column="4" :colon="false">
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction keep"  :span="4" label="支路一">放电中</el-descriptions-item>
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction"  :span="1" label="直流功率">-9.8kW</el-descriptions-item>
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction"  :span="1" label="直流电压">720.4V</el-descriptions-item>
            <el-descriptions-item labelClassName="descriptions-label" contentClassName="descriptions-direction"  :span="1" label="直流电流">-13.1A</el-descriptions-item>
          </el-descriptions>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
import RealTimeBaseInfo from "./../RealTimeBaseInfo.vue";

export default {
  name:'ZdjkSbjkPcs',
  components:{RealTimeBaseInfo},
  data() {
    return {
      infoData:[
        {label:'总交流有功电率',value:'-7.2',attr:'',unit:'kW'},
        {label:'当天交流充电量',value:'0',attr:'',unit:'kWh'},
        {label:'A相电压',value:'12',attr:'',unit:'V'},
        {label:'A相电流',value:'20',attr:'',unit:'A'},
        {label:'总交流无功电率',value:'-0.1',attr:'',unit:'kVar'},
        {label:'当天交流放电量',value:'145',attr:'',unit:'kWh'},
        {label:'B相电压',value:'12',attr:'',unit:'V'},
        {label:'B相电流',value:'20',attr:'',unit:'A'},
        {label:'总交流视在功率',value:'8',attr:'',unit:'kVA'},
        {label:'PCS模块温度',value:'40',attr:'',unit:'&#8451;'},
        {label:'C相电压',value:'12',attr:'',unit:'V'},
        {label:'C相电流',value:'20',attr:'',unit:'A'},
        {label:'总交流功率因数',value:'-0.9',attr:'',unit:''},
        {label:'PCS环境温度',value:'12',attr:'',unit:'&#8451;'},
        {label:'交流频率',value:'102',attr:'',unit:'Hz'}
      ],
    }
  },
  methods:{
    problemSaved(){
      this.$confirm('确认故障已复位?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        showClose:false,
        closeOnClickModal:false,
        type: 'warning',
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true;
            setTimeout(() => {
              // todo 调用接口如果关机成功 调用done方法 否则不关闭弹窗
              done();
              // setTimeout(() => {
              instance.confirmButtonLoading = false;
              // }, 300);
            }, 3000);
          } else {
            done();
          }
        }
      }).then(() => {
        //只有在故障复位成功的情况下会走到这里
        this.$message({
          type: 'success',
          message: '故障复位成功!'
        });
      }).catch(() => {
        //取消复位
      });
    },
    machineClosed(){
      this.$confirm('确认要关机吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        showClose:false,
        closeOnClickModal:false,
        type: 'warning',
        beforeClose: (action, instance, done) => {
          if (action === 'confirm') {
            instance.confirmButtonLoading = true;
            setTimeout(() => {
              // todo 调用接口如果关机成功 调用done方法 否则不关闭弹窗
              done();
              // setTimeout(() => {
              instance.confirmButtonLoading = false;
              // }, 300);
            }, 3000);
          } else {
            done();
          }
        }
      }).then(() => {
        //只有在关机成功的情况下会走到这里
        this.$message({
          type: 'success',
          message: '关机成功!'
        });
      }).catch(() => {
        //取消关机
      });
    }
  }

}
</script>

<style scoped lang="scss">
.pcs-container{
  margin-top: 25px;
  //红色标题
  .pcs-header{
    background: #FC6B69;
    display: flex;
    position: relative;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    height: 60px;
    border-radius: 6px 6px 0 0;
    .pcs-title{
      color: #ffffff;
      font-size: 20px;
      font-weight: 500;
      line-height: 20px;
      padding: 0 50px 0 25px;
    }
    .pcs-status{
      color: #ffffff;
      font-size: 12px;
      line-height: 20px;
    }
    .pcs-btns{
      position: absolute;
      right: 25px;
      top: 50%;
      transform: translateY(-50%);
    }
  }
}
</style>
