<template>
  <div class="dashboard-container">
    <!-- 首页 -->
    <header class="header_title">FSU({{ form.baseInfo.equipName }})</header>
    <el-row :gutter="24">
      <el-col :span="11" class="mb20">
        <el-card shadow="never">
          <div slot="header" class="clearfix posa">
            <span>管理范围</span>
          </div>
          <div>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">监测设备</div>
              </el-col>
              <el-col :span="10">
                <div class="item_data">{{ form.type4 }}台</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">漏缆</div>
              </el-col>
              <el-col :span="10">
                <div class="item_data">{{ form.type5 }}根</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">天馈线</div>
              </el-col>
              <el-col :span="10">
                <div class="item_data">{{ form.count.LEAKY }}根</div>
              </el-col>
            </el-row>
          </div>
        </el-card>
      </el-col>
      <el-col :span="11" class="mb20">
        <el-card shadow="never">
          <div slot="header" class="clearfix posa">
            <span>基础信息</span>
             <el-button
              style="float: right; padding: 3px 0; margin-right: 20px"
              type="text"
              class="savebtn"
              v-if="flag == true"
              @click="editbtn()"
              ><svg-icon
              icon-class="edit"
            /> 编辑</el-button
            >
            <el-button
              style="float: right; padding: 3px 0; margin-right: 20px"
              type="text"
              class="savebtn"
              v-else
              @click="savebtn()"
              ><svg-icon
              icon-class="save"
            /> 保存</el-button
            >
          </div>
          <div>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">FSU身份编号</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.fsuCode }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">FSU端口数</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.fsuPort }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">设备名称</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.equipName }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">IP地址</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.ip }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">所在铁路线</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.railWayName }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">所在站点</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.siteName }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">设备厂商</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.equipFactory }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">设备备用方式</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.backModeName }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">通信方式</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.connectModeName }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">设备类型</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.equipTypeName }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">设备子类型</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">
                  {{ form.baseInfo.equipSubTypeName }}
                </div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">软件版本号</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.softVersion }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">设备生产序列号</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">
                  {{ form.baseInfo.equipSerialNumber }}
                </div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">安装日期</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.creationTime }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">维护日期</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.openTime }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">设备所铁路公里标</div>
              </el-col>
              <el-col :span="colspan">
                <div class="item_data">{{ form.baseInfo.kmSign }}</div>
              </el-col>
            </el-row>
            <el-row class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">开通状态</div>
              </el-col>
              <el-col :span="colspan">
                <el-select
                  v-model="form.baseInfo.isOpen"
                  :disabled="flag"
                  style="width: 100%"
                >
                  <el-option
                    v-for="item in isOpenSelect"
                    :key="item.key"
                    :label="item.label"
                    :value="item.key"
                  ></el-option>
                </el-select>
              </el-col>
            </el-row>
          </div>
        </el-card>
      </el-col>
      <el-col :span="11" class="mb20 specialCard">
        <el-card shadow="never">
          <div slot="header" class="clearfix posa">
            <span>当前状态</span>
          </div>
          <div>
            <el-row v-for="(item, i) in statusList" class="text" :gutter="24">
              <el-col :span="10">
                <div class="item_name">{{ item.name }}</div>
              </el-col>
              <el-col :span="8">
                <div class="item_data levelData">{{ item.value }}</div>
              </el-col>
              <el-col :span="6" >
                <el-button class="alarmbtn" type="primary" size="mini" 
                v-if="item.value == '连接异常' || item.value == '紧急' || item.value == '重要' || item.value == '一般'"
                     @click="toalarm(item)" >处理告警</el-button>
                  </el-col>
            </el-row>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { DetailMixins } from "./mixins";

import { fsuOpen } from "../api";
export default {
  name: "Dashboard",
  data() {
    return {
      colspan:14,
    
    };
  },
  mixins: [DetailMixins],
  methods: {
    savebtn() {
      this.flag = true;
      fsuOpen(this.info()).then((res) => {
        this.$message.success("修改成功");
      });
    },
    toalarm(item){
     let topath = ''
     let toquery = {}
     if (item.name == '设备状态') {
       topath = '/alarm/device'
       toquery = { fsuId:this.form.baseInfo.id }
     } else{
       topath = '/alarm/cableTime'
       toquery = { alarmTargetName:item.name }
     }
      this.$router.push({
        path: topath,
        query: toquery,
      });
    },
  },
  
  watch: {
    statusList: {
      immediate: true,
      handler(newV) {
        if (newV) {
           this.$nextTick(function () {
            this.levelcolor();
          });
         
        }
      },
    },
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
::v-deep.el-card {
  border: 1px solid #e3e3e3;
  border-radius: 8px;
  // min-height: 243px;
  .el-card__header {
    font-size: 18px;
    color: #333333;
    font-weight: 500;
    text-align: center;
    background: rgba(226, 235, 255, 0.39);
    opacity: 1;
  }
  .el-card__body {
    padding: 0px;
  }
}
.specialCard {
  position: absolute;
  top: 268px;
}
.posa {
  position: relative;
}
.savebtn {
  position: absolute;
  right: 2%;
}
.text {
  padding: 10px 20px 10px 20px;
  border-bottom: 1px solid #e3e3e3;
  &:last-child {
    border-bottom: none;
  }
  .item_name,
  .item_data {
    height: 16px;
    line-height: 16px;
    margin-top: 12px;
    margin-bottom: 12px;
  }
  .item_name {
    width: 262px;
    height: 16px;
    line-height: 16px;
    color: #7e7e7e;
    margin-top: 12px;
    margin-bottom: 12px;
  }

  .el-card:last-child .text {
    border-bottom: none !important;
  }
}
</style>
