<template>
  <div class="popupContentClass" :style="{'height':testHeight1+'px'}">
    <a-row class="rowClass">
      <a-col :span="4" class="nameClass">水库名称：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.rsName }}</a-col>
      <a-col :span="4" class="nameClass">水库编码：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.rsCode }}</a-col>
    </a-row>
    <a-row class="rowClass">
      <a-col :span="4" class="nameClass">管理机构：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.rsAdmName }}</a-col>
      <a-col :span="4" class="nameClass">所在地点：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.location }}</a-col>
    </a-row>
    <a-row class="rowClass">
      <a-col :span="4" class="nameClass">工程规模：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.engScal1 }}</a-col>
      <a-col :span="4" class="nameClass">总库容(万m3)：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.totCap }}</a-col>
    </a-row>
    <a-row class="rowClass">
      <a-col :span="4" class="nameClass">最大坝高(m)：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.damSizeHig }}</a-col>
      <a-col :span="4" class="nameClass">主坝坝型：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.damTypeStr1 }}</a-col>
    </a-row>
    <a-row class="rowClass">
      <a-col :span="4" class="nameClass">经度：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.longitude }}</a-col>
      <a-col :span="4" class="nameClass">纬度：</a-col>
      <a-col :span="8" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.latitude }}</a-col>
    </a-row>
  </div>
</template>

<script>
import { getResBaseInfo } from '../../../../api/zhxxAPI.js';
import request from '../../../../utils/gw_ajax_request';
import { dateFormat } from '../../../../utils/gw_date.js';
export default {
  props: ['currentResCode', 'isJiangXi'],
  data() {
    return {
      testHeight: (window.innerHeight * 0.5 - 114) / 6,
      testHeight1: window.innerHeight * 0.5,
      formObj: {
        rsName: '',
        rsAdmName: '',
        rsLoc: '',
        intm: '',
        engScal: '',
        totCap: '',
        damMaxHigh: '',
        damTypeStr: '',
        regCode: '',
        rsvrLong: '',
        rsvrLat: '',
        resCreateTime: '',
      },
      formLabelWidth: '160px',
      loading: true,
      currentResCode1: '',
    };
  },
  computed: {
    recPersId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '';
    },
  },
  watch: {
    currentResCode(n, o) {
      this.currentResCode1 = this.currentResCode;
      this.getBaseInfo();
    },
  },
  mounted() {
    this.dialogFormVisible = true;
    this.currentResCode1 = this.currentResCode;
    this.getBaseInfo();
  },
  methods: {
    showDialog() {
      this.dialogFormVisible = true;
    },
    getBaseInfo() {
      if (this.currentResCode1 == '') {
        return;
      }
      let url;
      if (this.isJiangXi) {
        url = `/dc/att/rsBase/${this.currentResCode1}?repeat=0`;
      } else {
        url = `/dc/att/rsBase/${this.currentResCode1}`;
      }
      request.get(url).then(
        (res) => {
          if (res.data) {
            this.formObj = res.data;
            this.formObj['damTypeStr1'] = this.formatdamType(
              this.formObj.damTypeStr,
            );
            this.formObj['engScal1'] = this.formatEngScal(this.formObj.engScal);
            // _self.value1 = dateFormat(res.data.compDate, "yyyy-MM-dd");
          } else {
            this.formObj = {};
          }
        },
        (err) => {},
      );
    },
    formatRadio(val) {
      if (val == '1') {
        return '是';
      } else if (val == '0') {
        return '否';
      } else {
        return val;
      }
    },
    formatEngScal(val) {
      switch (val) {
        case '1':
          val = '大（1）型';
          break;
        case '2':
          val = '大（2）型';
          break;
        case '3':
          val = '中型';
          break;
        case '4':
          val = '小（1）型';
          break;
        case '5':
          val = '小（2）型';
          break;
        case '9':
          val = '其他';
          break;
      }
      return val;
    },
    formatdamType(val) {
      switch (val) {
        case '1':
          val = '混凝土坝';
          break;
        case '2':
          val = '碾压混凝土坝';
          break;
        case '3':
          val = '浆砌石坝';
          break;
        case '4':
          val = '土坝';
          break;
        case '5':
          val = '堆石坝';
          break;
        case '6':
          val = '挡水坝';
          break;
        case '7':
          val = '其它';
          break;
      }
      return val;
    },
  },
};
</script>

<style lang='less' scoped>
@import "../../../../assets/style/popup.css";
</style>
