<template>
  <div class="popupContentClass" :style="{'height':testHeight1+'px'}">
    <div style="margin-top:20px;">
      <div style="display: flex;align-items: center;margin-bottom: 10px">
        <div style="width: 4px;height: 14px;background: rgba(44,158,255,1);border-radius: 1px;margin-right: 10px;"></div>
        <span style="font-size:14px;font-family:MicrosoftYaHei;color:rgba(51,51,51,1);">水雨情预测预报</span>
      </div>
    </div>
    <a-row class="rowClass">
      <a-col :span="8" class="nameClass">是否具有能力开展：</a-col>
      <a-col :span="4" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.rainForc&&addObj.rainForc == "1"?"是":
          addObj.rainForc&&addObj.rainForc == "2"?"否":"" }}
      </a-col>
      <a-col :span="8" v-if="addObj.rainForc == '2'" class="nameClass">有其他方法及时了解水雨情：</a-col>
      <a-col :span="4" v-if="addObj.rainForc == '2'" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.rainForcNote&&addObj.rainForcNote == "1"?"是":
          addObj.rainForcNote&&addObj.rainForcNote == "2"?"否":"" }}
      </a-col>
    </a-row>
    <div style="margin-top:20px;">
      <div style="display: flex;align-items: center;margin-bottom: 10px">
        <div style="width: 4px;height: 14px;background: rgba(44,158,255,1);border-radius: 1px;margin-right: 10px;"></div>
        <span style="font-size:14px;font-family:MicrosoftYaHei;color:rgba(51,51,51,1);">水库调度运用方案</span>
      </div>
    </div>
    <a-row class="rowClass1">
      <a-col :span="8" class="nameClass">是否有水库调度运用方案：</a-col>
      <a-col :span="4" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.schPlanSameExta&&addObj.schPlanSameExta == "1"?"是":
          addObj.schPlanSameExta&&addObj.schPlanSameExta == "2"?"否":"" }}
      </a-col>
      <a-col :span="6" v-if="addObj.schPlanSameExta == '1'" class="nameClass">是否获得批复：</a-col>
      <a-col :span="6" v-if="addObj.schPlanSameExta == '1'" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.schPlanSameAppr&&addObj.schPlanSameAppr == "1"?"是":
          addObj.schPlanSameAppr&&addObj.schPlanSameAppr == "2"?"否":"" }}
      </a-col>
    </a-row>
    <a-row class="rowClass" v-if="addObj.schPlanSameExta == '1'">
      <a-col :span="8" class="nameClass">是否进行演练：</a-col>
      <a-col :span="4" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.schPlanSameEme&&addObj.schPlanSameEme == "1"?"是":
          addObj.schPlanSameEme&&addObj.schPlanSameEme == "2"?"否":"" }}
      </a-col>
      <a-col :span="6" class="nameClass">可操作性：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.schPlanSameSpeed&&addObj.schPlanSameSpeed == "1"?"较强":
          addObj.schPlanSameSpeed&&addObj.schPlanSameSpeed == "2"?"一般":
          addObj.schPlanSameSpeed&&addObj.schPlanSameSpeed == "3"?"较差":"" }}
      </a-col>
    </a-row>
    <div style="margin-top:20px;">
      <div style="display: flex;align-items: center;margin-bottom: 10px">
        <div style="width: 4px;height: 14px;background: rgba(44,158,255,1);border-radius: 1px;margin-right: 10px;"></div>
        <span style="font-size:14px;font-family:MicrosoftYaHei;color:rgba(51,51,51,1);">安全管理(防汛)应急预案</span>
      </div>
    </div>
    <a-row class="rowClass1">
      <a-col :span="8" class="nameClass">是否有安全管理（防汛）应急方案：</a-col>
      <a-col :span="4" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.emerPlanSameExta&&addObj.emerPlanSameExta == "1"?"是":
          addObj.emerPlanSameExta&&addObj.emerPlanSameExta == "2"?"否":"" }}
      </a-col>
      <a-col :span="6" v-if="addObj.emerPlanSameExta == '1'" class="nameClass">是否获得批复：</a-col>
      <a-col :span="6" v-if="addObj.emerPlanSameExta == '1'" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.emerPlanSameAppr&&addObj.emerPlanSameAppr == "1"?"是":
          addObj.emerPlanSameAppr&&addObj.emerPlanSameAppr == "2"?"否":"" }}
      </a-col>
    </a-row>
    <a-row class="rowClass" v-if="addObj.emerPlanSameExta == '1'">
      <a-col :span="8" class="nameClass">是否进行演练：</a-col>
      <a-col :span="4" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.emerPlanSameEme&&addObj.emerPlanSameEme == "1"?"是":
          addObj.emerPlanSameEme&&addObj.emerPlanSameEme == "2"?"否":""
        }}
      </a-col>
      <a-col :span="6" class="nameClass">可操作性：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ addObj.emerPlanSameSpeed&&addObj.emerPlanSameSpeed == "1"?"较强":
          addObj.emerPlanSameSpeed&&addObj.emerPlanSameSpeed == "2"?"一般":
          addObj.emerPlanSameSpeed&&addObj.emerPlanSameSpeed == "3"?"较差":"" }}
      </a-col>
    </a-row>
  </div>
</template>

<script>
import { getBaseExt } from '../../../../api/duChaTianBao';
import request from '../../../../utils/gw_ajax_request';
export default {
  props: ['currentObjectRgstrId', 'dialogHeightA', 'isJiangXi'],
  data() {
    return {
      testHeight: (window.innerHeight * 0.5 - 114) / 6,
      testHeight1: window.innerHeight * 0.5,
      addObj: {
        rgstrId: '',
        recPersId: '',
        isGovRes: '',
        isConRes: '',
        isDeptRes: '',
        isCntyDept: '',
        isCntyFunc: '',
        isCntyFee: '',
        isQuailtyChk: '',
        isPracFee: '',
      },
      curOperate: '',
      formLabelWidth: '250px',
      loading: true,
      operationType1: '',
    };
  },
  computed: {
    recPersId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '1098101939614724096';
    },
  },
  mounted() {
    this.getRgstridObj();
  },
  watch: {
    currentObjectRgstrId(n, o) {
      this.getRgstridObj();
    },
  },
  methods: {
    getRgstridObj() {
      let url;
      if (this.isJiangXi) {
        url = `/dc/insp/baseExt/get/${this.currentObjectRgstrId}?repeat=0`;
      } else {
        url = `/dc/insp/baseExt/get/${this.currentObjectRgstrId}`;
      }
      request.get(url).then((res) => {
        if (res.data) {
          this.addObj = res.data;
          this.operationType1 = 'update';
          console.log(this.addObj);
        } else {
          this.addObj = {};
          this.operationType1 = 'add';
        }
      });
    },
    addMember() {
      this.addObj['rgstrId'] = this.currentObjectRgstrId;
      this.addObj['recPersId'] = this.recPersId;
      const gllsObj = {
        rgstrId: this.currentObjectRgstrId,
        recPersId: this.recPersId,
        emerPlanSameExta: this.addObj.emerPlanSameExta,
        emerPlanSameAppr: this.addObj.emerPlanSameAppr,
        emerPlanSameEme: this.addObj.emerPlanSameEme,
        emerPlanSameSpeed: this.addObj.emerPlanSameSpeed,
        schPlanSameExta: this.addObj.schPlanSameExta,
        schPlanSameAppr: this.addObj.schPlanSameAppr,
        schPlanSameSpeed: this.addObj.schPlanSameSpeed,
        rainForc: this.addObj.rainForc,
      };
      const addObj = {};
      Object.assign(addObj, gllsObj);
      if (this.operationType1 == 'add') {
        request
          .post('/dc/insp/baseExt', addObj)
          .then((res) => {
            if (res.success) {
              this.$message.success('添加成功!');
              this.$emit('addShuiKuSuccess');
            } else {
              this.$message.error(res.message);
            }
          })
          .catch((err) => {
            this.$message.error(err.message);
          });
      } else {
        request
          .post('/dc/insp/baseExt/update', addObj)
          .then((res) => {
            if (res.success) {
              this.$message.success('修改成功!');
              this.$emit('addShuiKuSuccess');
            } else {
              this.$message.error(res.message);
            }
          })
          .catch((err) => {
            this.$message.error(err.message);
          });
      }
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
  },
};
</script>

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