<template>
  <div class="wind-site-base-info">
    <!-- 电机基本信息 -->
    <el-row class="mg-b-16">
      <div class="wind-site-name green mg-r-8">
        <span class="svg-icon svg-icon-green mg-r-8">
          <svg-icon class="" :svgid="'svg-normal-power'" />
        </span>
        {{ sourceMap.code }}
      </div>
      <div class="wind-site-tag">
        <div class="tag-text">所属线路</div>
        <div class="tag-value">{{ sourceMap.lnname }}</div>
      </div>
      <div class="wind-site-tag">
        <div class="tag-text">机型</div>
        <div class="tag-value">{{ sourceMap.model }}</div>
      </div>
      <div class="wind-site-tag">
        <div class="tag-text">告警时间</div>
        <div class="tag-value">{{ sourceMap.gxkmap && sourceMap.gxkmap.bjsj }}</div>
      </div>
      <div class="wind-site-tag">
        <div class="tag-text">告警内容</div>
        <div class="tag-value">{{ sourceMap.gxkmap && sourceMap.gxkmap.bjmc }}</div>
      </div>
    </el-row>
    <!-- 发电信息 -->
    <el-row class="mg-b-16">
      <el-col :span="14">
        <el-row class="generation background pd-8 mg-r-8">
          <div class="mg-r-8">
            <div class="generation-text">日发电量</div>
            <div class="generation-value green">{{ sourceMap.jczbmap && sourceMap.jczbmap.RFDL }}<span class="unit">kwh</span></div>
          </div>
          <el-row class="wind-site-state">
            <el-col :span="6" class="generation-item">
              <i class="svg-icon svg-icon-lg svg-icon-gray">
                <svg-icon :svgid="'svg-availability'" />
              </i>
              <div class="value">{{ sourceMap.jczbmap && sourceMap.jczbmap.FJKYL }}</div>
              <div class="text">月可利用率</div>
            </el-col>
            <el-col :span="6" class="generation-item">
              <i class="svg-icon svg-icon-lg svg-icon-gray not-first">
                <svg-icon :svgid="'svg-availability'" />
              </i>
              <div class="value">{{ sourceMap.gxkmap && sourceMap.gxkmap.ygzxs }}</div>
              <div class="text">月故障小时数</div>
            </el-col>
            <el-col :span="6" class="generation-item">
              <i class="svg-icon svg-icon-lg svg-icon-gray not-first">
                <svg-icon :svgid="'svg-availability'" />
              </i>
              <div class="value">{{ sourceMap.gxkmap && sourceMap.gxkmap.ytjxs }}</div>
              <div class="text">月待机小时数</div>
            </el-col>
            <el-col :span="6" class="generation-item">
              <i class="svg-icon svg-icon-lg svg-icon-gray not-first">
                <svg-icon :svgid="'svg-availability'" />
              </i>
              <div class="value">{{ sourceMap.gxkmap && sourceMap.gxkmap.yyxxs }}</div>
              <div class="text">月发电小时数</div>
            </el-col>
          </el-row>
        </el-row>
      </el-col>
      <el-col :span="10" class="background">
        <el-row type="flex" justify="center" :align="'middle'" class="power-load">
          <!-- 功率复核 PowerLoad -->
          <el-col v-for="item in PowerLoad" :key="item" :span="6">
            <dash-pie-chart :title="item.title" :value="sourceMap.jczbmap && sourceMap.jczbmap[item.key]" height="9.722vh" />
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <!-- 基本信息 -->
    <el-row>
      <el-col :span="12">
        <!-- 基本信息 -->
        <div class="info-panel base-info">
          <div class="panel-title gary-l">
            <div class="svg-icon svg-icon-gray-l mg-r-16">
              <svg-icon :svgid="'svg-base-info'" style="margin: 3px 0 -3px 0;" />
            </div>
            <div class="title">发电机</div>
          </div>
          <div class="panel-body">
            <table class="table-form">
              <template v-for="(item,index) in fdjmap" :key="index">
                <tr v-for="i in fdjmap.length / 2" :key="i">
                  <td v-if="index%2==0" class="text gray">{{ item.name }}</td>
                  <td v-if="index%2==0" class="value green">{{ item.value }}</td>
                  <td v-if="index%2==0" class="unit gray">{{ item.unit }}</td>
                </tr>
                <tr>
                  <td v-if="index%2==1" class="text gray">{{ item.name }}</td>
                  <td v-if="index%2==1" class="value green">{{ item.value }}</td>
                  <td v-if="index%2==1" class="unit gray">{{ item.unit }}</td>
                </tr>
              </template>
            </table>
          </div>
        </div>
        <!-- 运行参数 -->
        <div class="info-panel base-info">
          <div class="panel-title gary-l">
            <div class="svg-icon svg-icon-gray-l mg-r-16">
              <svg-icon :svgid="'svg-parameter'" style="margin: 6px 0 -6px 0;" />
            </div>
            <div class="title">齿轮箱</div>
          </div>
          <div class="panel-body">
            <table class="table-form">
              <template v-for="(item,index) in clxmap" :key="index" :v-if="index%2==0">
                <tr>
                  <td class="text gray">{{ item.name }}</td>
                  <td class="value green">{{ item.value }}</td>
                  <td class="unit gray">{{ item.unit }}</td>
                  <td class="text gray" v-if="index+1<clxmap.length">{{clxmap[index+1].name}}</td>
                  <td class="value green" v-if="index+1<clxmap.length">{{clxmap[index+1].value}}</td>
                  <td class="unit gray" v-if="index+1<clxmap.length">{{clxmap[index+1].unit}}</td>
                </tr>
              </template>
            </table>
          </div>
        </div>
        <!-- 变桨信息 -->
        <div class="info-panel base-info">
          <div class="panel-title gary-l">
            <div class="svg-icon svg-icon-gray-l mg-r-16">
              <svg-icon :svgid="'svg-pitch-info'" style="margin: 3px 0 -3px 0;padding: 2px;" />
            </div>
            <div class="title">变桨信息</div>
          </div>
          <div class="panel-body">
            <table class="table-form">
              <template v-for="(item,index) in bjmap" :key="index" :v-if="index%2==0">
                <tr>
                  <td class="text gray">{{ item.name }}</td>
                  <td class="value green">{{ item.value }}</td>
                  <td class="unit gray">{{ item.unit }}</td>
                  <td class="text gray" v-if="index+1<bjmap.length">{{bjmap[index+1].name}}</td>
                  <td class="value green" v-if="index+1<bjmap.length">{{bjmap[index+1].value}}</td>
                  <td class="unit gray" v-if="index+1<bjmap.length">{{bjmap[index+1].unit}}</td>
                </tr>
              </template>
            </table>
          </div>
        </div>
      </el-col>
      <el-col :span="12">
        <!-- 电网信息 -->
        <div class="info-panel base-info">
          <div class="panel-title gary-l">
            <div class="svg-icon svg-icon-gray-l mg-r-16">
              <svg-icon :svgid="'svg-power-grid'" />
            </div>
            <div class="title">偏航信息</div>
          </div>
          <div class="panel-body">
            <table class="table-form">
              <template v-for="(item,index) in phmap" :key="index" :v-if="index%2==0">
                <tr>
                  <td class="text gray">{{ item.name }}</td>
                  <td class="value green">{{ item.value }}</td>
                  <td class="unit gray">{{ item.unit }}</td>
                  <td class="text gray" v-if="index+1<phmap.length">{{phmap[index+1].name}}</td>
                  <td class="value green" v-if="index+1<phmap.length">{{phmap[index+1].value}}</td>
                  <td class="unit gray" v-if="index+1<phmap.length">{{phmap[index+1].unit}}</td>
                </tr>
              </template>
            </table>
          </div>
        </div>
        <!-- 温度信息 -->
        <div class="info-panel base-info">
          <div class="panel-title gary-l">
            <div class="svg-icon svg-icon-gray-l mg-r-16">
              <svg-icon :svgid="'svg-temperature-info'" style="margin: 3px -5px -3px 5px;" />
            </div>
            <div class="title">液压信息</div>
          </div>
          <div class="panel-body">
            <table class="table-form">
              <template v-for="(item,index) in yymap" :key="index" :v-if="index%2==0">
                <tr>
                  <td class="text gray">{{ item.name }}</td>
                  <td class="value green">{{ item.value }}</td>
                  <td class="unit gray">{{ item.unit }}</td>
                  <td class="text gray" v-if="index+1<yymap.length">{{yymap[index+1].name}}</td>
                  <td class="value green" v-if="index+1<yymap.length">{{yymap[index+1].value}}</td>
                  <td class="unit gray" v-if="index+1<yymap.length">{{yymap[index+1].unit}}</td>
                </tr>
              </template>
            </table>
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import DashPieChart from "../../../../components/chart/pie/dash-pie-chart.vue";
import SvgIcon from "../../../../components/coms/icon/svg-icon.vue";
export default {
  name: "wind-site-base-info",
  components: { SvgIcon, DashPieChart },
  props: {
    id: {
      type: String,
      default: "",
    },
    data: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {
      sourceMap: {},
      fdjmap: [],
      clxmap: [],
      bjmap: [],
      phmap: [],
      yymap: [],
      // 功率复核数据
      PowerLoad: [
        {
          title: "风速",
          key: "FS",
        },
        {
          title: "保证功率",
          key: "LLGL",
        },
        {
          title: "应发功率",
          key: "YFGL",
        },
        {
          title: "实发功率",
          key: "GL",
        },
      ],
    };
  },
  methods: {},

  mounted() {
    this.sourceMap = this.data;
  },

  watch: {
    data(value) {
      this.sourceMap = value
      this.fdjmap = value.fdjmap.ai
      this.clxmap = value.clxmap.ai
      this.bjmap = value.bjmap.ai
      this.phmap = value.phmap.ai
      this.yymap = value.yymap.ai
    }
  },
};
</script>

<style lang="less">
.wind-site-base-info {
  // 风机名称
  .wind-site-name {
    padding: 0.37vh 2.222vh;
    display: flex;
    align-items: center;
    font-size: @fontsize-s;
    border: 1px solid @green;
    .svg-icon {
      svg {
        height: 1.481vh;
        width: 1.481vh;
      }
    }
  }

  // 风机信息 tag样式
  .wind-site-tag {
    flex: 1 1 auto;
    padding: 0.37vh 0.741vh;
    display: flex;
    align-items: center;
    font-size: @fontsize-s;
    background: fade(@darkgray, 30);

    .tag-text {
      color: @gray;
      flex: 0 0 auto;
      margin-right: 0.741vh;
      font-weight: 600;
    }

    .tag-value {
      min-width: 9.259vh;
      color: fade(@white, 80);
    }

    & + .wind-site-tag {
      margin-left: 0.741vh;
    }
  }

  .generation {
    height: 100%;
    align-items: center;

    .generation-text {
      font-size: 2.037vh;
      letter-spacing: 1px;
    }

    .generation-value {
      font-size: 3.704vh;
      .unit {
        margin-left: 0.37vh;
        font-size: 2.037vh;
      }
    }

    .generation-item {
      position: relative;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      text-align: center;
      i {
        position: absolute;
        left: calc(50% - 44px);
        top: -8px;
        svg {
          width: 90px;
          height: 90px;
        }

        &.not-first {
          left: calc(50% - 38px);
        }
      }
      .value {
        margin: 32px 0;
        align-items: center;
        flex: 1 0 auto;
        font-size: 12px;
      }
      .text {
        font-size: 12px;
      }
    }
  }

  .power-load {
    height: 100%;
    padding: 0.7407vh 0.3704vh;
  }

  .wind-site-state {
    flex: 1 1 auto;
  }

  .info-panel {
    flex: 1 0 auto;
    width: 100%;
    .panel-title {
      display: flex;
      width: 100%;
      background: fade(@darkgray, 20);
      padding: 0.37vh;
      padding-left: 2.222vh;
      align-items: center;
      font-size: @fontsize-s;
      color: #b2bdc0;

      svg {
        .svg-use path {
          fill: @gray;
        }

        width: 2.222vh;
        height: 2.222vh;
      }
    }

    .panel-body {
      border: 1px solid fade(@darkgray, 40);
      border-top: 0px;
    }

    & + .info-panel {
      margin-top: 1.481vh;
    }
  }
}
</style>
