<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="rowClass1">
      <a-col :span="6" class="nameClass">是否有行政责任人：</a-col>
      <a-col :span="18" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.hasWiunWaoLegPers == "1"?"是":formObj.hasWiunWaoLegPers == "2"?"否":"" }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasWiunWaoLegPers == '1'&&formObj.hasWiunWaoLegPers != ''">
      <a-col :span="6" class="nameClass">责任人名称：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.wiunWaoLegPers }}</a-col>
      <a-col :span="6" class="nameClass">责任人电话：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.wiunWaoLegPersTel }}</a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasWiunWaoLegPers == '1'&&formObj.hasWiunWaoLegPers != ''">
      <a-col :span="6" class="nameClass">责任人职务：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.wiunWaoLegPersDuty }}</a-col>
      <a-col :span="6" class="nameClass">是否接受过岗位培训：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.wiunWaoLegPersTrain == '1' ? '是' : formObj.wiunWaoLegPersTrain == '2' ? '否' : '' }}
      </a-col>
    </a-row>
    <a-row class="rowClass" v-if="formObj.hasWiunWaoLegPers == '1'&&formObj.hasWiunWaoLegPers != ''">
      <a-col :span="6" class="nameClass">是否明确规范性履职标准：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.wiunWaoLegPersCnps == '1' ? '是' : formObj.wiunWaoLegPersCnps == '2' ? '否' : '' }}
      </a-col>
      <a-col :span="6" class="nameClass">履职情况：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.wiunWaoLegPersResu&&formObj.wiunWaoLegPersResu == "1"?"好":
          formObj.wiunWaoLegPersResu&&formObj.wiunWaoLegPersResu == "2"?"基本到位":
          formObj.wiunWaoLegPersResu&&formObj.wiunWaoLegPersResu == "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="6" class="nameClass">是否有主管责任人：</a-col>
      <a-col :span="18" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.hasSuperPers == "1"?"是":formObj.hasSuperPers == "2"?"否":"" }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasSuperPers == '1'&&formObj.hasSuperPers != ''">
      <a-col :span="6" class="nameClass">责任人名称：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.superPers }}</a-col>
      <a-col :span="6" class="nameClass">责任人电话：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.superPersTel }}</a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasSuperPers == '1'&&formObj.hasSuperPers != ''">
      <a-col :span="6" class="nameClass">责任人职务：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.superPersDuty }}</a-col>
      <a-col :span="6" class="nameClass">是否接受过岗位培训：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.superPersTrain == '1' ? '是' : formObj.superPersTrain == '2' ? '否' : '' }}
      </a-col>
    </a-row>
    <a-row class="rowClass" v-if="formObj.hasSuperPers == '1'&&formObj.hasSuperPers != ''">
      <a-col :span="6" class="nameClass">是否明确规范性履职标准：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.superPersCnps == '1' ? '是' : formObj.superPersCnps == '2' ? '否' : '' }}
      </a-col>
      <a-col :span="6" class="nameClass">履职情况：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.superPersResu&&formObj.superPersResu == "1"?"好":
          formObj.superPersResu&&formObj.superPersResu == "2"?"基本到位":
          formObj.superPersResu&&formObj.superPersResu == "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="6" class="nameClass">是否有管理责任人：</a-col>
      <a-col :span="18" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.hasManagePers == "1"?"是":formObj.hasManagePers == "2"?"否":"" }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasManagePers == '1'&&formObj.hasManagePers != ''">
      <a-col :span="6" class="nameClass">责任人名称：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.managePers }}</a-col>
      <a-col :span="6" class="nameClass">责任人电话：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.managePersTel }}</a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasManagePers == '1'&&formObj.hasManagePers != ''">
      <a-col :span="6" class="nameClass">责任人职务：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">{{ formObj.managePersDuty }}</a-col>
      <a-col :span="6" class="nameClass">是否接受过岗位培训：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.managePersTrain == '1' ? '是' : formObj.managePersTrain == '2' ? '否' : '' }}
      </a-col>
    </a-row>
    <a-row class="rowClass" v-if="formObj.hasManagePers == '1'&&formObj.hasManagePers != ''">
      <a-col :span="6" class="nameClass">是否明确规范性履职标准：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.managePersCnps == '1' ? '是' : formObj.managePersCnps == '2' ? '否' : '' }}
      </a-col>
      <a-col :span="6" class="nameClass">履职情况：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.managePersResu&&formObj.managePersResu == "1"?"好":
          formObj.managePersResu&&formObj.managePersResu == "2"?"基本到位":
          formObj.managePersResu&&formObj.managePersResu == "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="6" class="nameClass">是否有技术责任人：</a-col>
      <a-col :span="18" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.hasTechPers&&formObj.hasTechPers == "1"?"是":
          formObj.hasTechPers&&formObj.hasTechPers == "2"?"否":"" }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasTechPers == '1'&&formObj.hasTechPers != ''">
      <a-col :span="6" class="nameClass">责任人名称：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.techPers }}
      </a-col>
      <a-col :span="6" class="nameClass">责任人电话：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.techPersTel }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasTechPers == '1'&&formObj.hasTechPers != ''">
      <a-col :span="6" class="nameClass">责任人职务：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.techPersDuty }}
      </a-col>
      <a-col :span="6" class="nameClass">是否接受过岗位培训：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.techPersTrain == '1' ? '是' : formObj.techPersTrain == '2' ? '否' : '' }}
      </a-col>
    </a-row>
    <a-row class="rowClass" v-if="formObj.hasTechPers == '1'&&formObj.hasTechPers != ''">
      <a-col :span="6" class="nameClass">是否明确规范性履职标准：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.techPersCnps == '1' ? '是' : formObj.techPersCnps == '2' ? '否' : '' }}
      </a-col>
      <a-col :span="6" class="nameClass">履职情况：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.techPersResu&&formObj.techPersResu == "1"?"好":
          formObj.techPersResu&&formObj.techPersResu == "2"?"基本到位":
          formObj.techPersResu&&formObj.techPersResu == "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="6" class="nameClass">是否有巡查责任人：</a-col>
      <a-col :span="18" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.hasPatrolPers&&formObj.hasPatrolPers == "1"?"是":
          formObj.hasPatrolPers&&formObj.hasPatrolPers == "2"?"否":"" }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasPatrolPers == '1'&&formObj.hasPatrolPers != ''">
      <a-col :span="6" class="nameClass">责任人名称：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.patrolPers }}
      </a-col>
      <a-col :span="6" class="nameClass">责任人电话：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.patrolPersTel }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasPatrolPers == '1'&&formObj.hasPatrolPers != ''">
      <a-col :span="6" class="nameClass">是否接受过岗位培训：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.patrolPersTrain == '1' ? '是' : formObj.patrolPersTrain == '2' ? '否' : '' }}
      </a-col>
      <a-col :span="6" class="nameClass">是否明确规范性履职标准：</a-col>
      <a-col :span="6" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.patrolPersCnps == '1' ? '是' : formObj.patrolPersCnps == '2' ? '否' : '' }}
      </a-col>
    </a-row>
    <a-row class="rowClass1" v-if="formObj.hasPatrolPers == '1'&&formObj.hasPatrolPers != ''">
      <a-col :span="6" class="nameClass">履职情况：</a-col>
      <a-col :span="18" class="valueClass" :style="{'height':testHeight+'px'}">
        {{ formObj.patrolPersResu&&formObj.patrolPersResu == "1"?"好":
          formObj.patrolPersResu&&formObj.patrolPersResu == "2"?"基本到位":
          formObj.patrolPersResu&&formObj.patrolPersResu == "3"?"差":"" }}
      </a-col>
    </a-row>
  </div>
</template>

<script>
import { addBasePres, getRgstrid } from '../../../../api/duChaTianBao.js';
import request from '../../../../utils/gw_ajax_request';
import { formatDateTimeD } from '../../../../utils/gw_date.js';
import inputWith from '../../../../widgets/inuptWith.vue';
export default {
  components: {
    inputWith: inputWith,
  },
  props: ['currentObjectRgstrId', 'dialogHeightA', 'isJiangXi'],
  data() {
    var checkTel = (rule, value, callback) => {
      var isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/; // 座机
      var isMob = /^[1][3,4,5,7,8][0-9]{9}$/; // 座机格式
      if (!isMob.test(value) && !isPhone.test(value)) {
        callback(new Error('请输入合理电话'));
      } else {
        callback();
      }
    };
    return {
      testHeight: (window.innerHeight * 0.5 - 114) / 6,
      testHeight1: window.innerHeight * 0.5,
      rules: {
        wiunWaoLegPersTel: [{ validator: checkTel, trigger: 'blur' }],
        techPersTel: [{ validator: checkTel, trigger: 'blur' }],
        patrolPersTel: [{ validator: checkTel, trigger: 'blur' }],
      },
      formObj: {
        dutyId: '',
        hasPatrolPers: '', // 是否有巡查责任人
        hasTechPers: '', // 是否有技术责任人
        hasWiunWaoLegPers: '', // 是否有行政责任人
        patrolPers: '', // 巡查责任人姓名
        patrolPersDuty: '', // 巡查责任人职务
        patrolPersResu: '', // 巡查责任人履职情况 0  1  2
        patrolPersTel: '', // 巡查责任人电话
        rgstrId: '', // 水库督查登记ID
        techPers: '', // 技术责任人姓名
        techPersDuty: '', // 技术责任人职务
        techPersResu: '', // 技术责任人履职情况
        techPersTel: '', // 技术责任人电话
        wiunWaoLegPers: '', // 行政责任人姓名
        wiunWaoLegPersDuty: '', // 行政责任人职务
        wiunWaoLegPersResu: '', // 行政责任人履职情况
        wiunWaoLegPersTel: '', // 行政责任人电话
      },
      dialogFormVisible: false,
      formLabelWidth: '160px',
      loading: true,
      operationType1: '',
    };
  },
  computed: {
    recPersId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '';
    },
  },
  mounted() {
    this.getRgstridObj();
  },
  watch: {
    currentObjectRgstrId(n, o) {
      this.getRgstridObj();
    },
  },
  created() {},
  methods: {
    getRgstridObj() {
      let url;
      if (this.isJiangXi) {
        url = `/dc/insp/basePres/get/${this.currentObjectRgstrId}?repeat=0`;
      } else {
        url = `/dc/insp/basePres/get/${this.currentObjectRgstrId}`;
      }
      request.get(url).then((res) => {
        if (res.data) {
          this.formObj = res.data;
          this.operationType1 = 'update';
        } else {
          this.formObj = {};
          this.operationType1 = 'add';
        }
      });
    },
    addHandler() {
      this.formObj['rgstrId'] = this.currentObjectRgstrId;
      this.formObj['recPersId'] = this.recPersId;
      console.log(this.formObj);
      if (this.operationType1 == 'add') {
        try {
          request.post('/dc/insp/basePres', this.formObj).then((res) => {
            if (res.success) {
              this.$message.success('添加成功');
              this.$emit('addShuiKuSuccess');
            }
          });
        } catch (e) {}
      } else if (this.operationType1 == 'update') {
        try {
          request.post('/dc/insp/basePres/update', this.formObj).then((res) => {
            if (res.success) {
              this.$message.success('修改成功');
              this.$emit('addShuiKuSuccess');
            }
          });
        } catch (e) {}
      }
      this.$emit('cancelHandler');
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    formatRadio(val) {
      if (val == '1') {
        return '是';
      } else if (val == '0') {
        return '否';
      } else {
        return val;
      }
    },
  },
};
</script>

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