<template>
  <div id="">
    <a-layout style="height:520px;">
      <a-layout-content style="border:1px solid #d5d5ff;margin-left:5px;padding:0px;overflow: auto;">
        <p style="font-weight:bolder;background-color:#d5d5ff;padding:3px;margin-bottom: 20px">信息填报</p>
        <a-form :model="formObj" :rules="rules" :label-col="{ span: 10 }" :wrapper-col="{ span: 14 }">
          <p style="margin-top:10px;margin-bottom: 10px;overflow: hidden;">
            <a-icon type="caret-right" />
            <span style="width:120px;padding-left: 10px">日常管理</span>
            <span class="hrs"></span>
          </p>
          <a-form-item label="是否落实管护责任主体" required>
            <a-radio-group v-model:value="formObj.isDutyDep">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutyDep == '2'" type="link" @click="addProblem('isDutyDep')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否落实防汛责任人" required>
            <a-radio-group v-model:value="formObj.isDutyPers">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否落实防汛行政责任人" required v-if="formObj.isDutyPers =='2'">
            <a-radio-group v-model:value="formObj.isDutyGovPers">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutyGovPers == '2'" type="link" @click="addProblem('isDutyGovPers')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否落实防汛管理责任人" required v-if="formObj.isDutyPers =='2'">
            <a-radio-group v-model:value="formObj.isDutyFldPers">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutyFldPers == '2'" type="link" @click="addProblem('isDutyFldPers')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否落实防汛技术责任人" required v-if="formObj.isDutyPers =='2'">
            <a-radio-group v-model:value="formObj.isDutyTchPers">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutyTchPers == '2'" type="link" @click="addProblem('isDutyTchPers')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否落实防汛巡查责任人" required v-if="formObj.isDutyPers =='2'">
            <a-radio-group v-model:value="formObj.isDutyChkPers">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutyChkPers == '2'" type="link" @click="addProblem('isDutyChkPers')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否落实防汛安全员责任人" required v-if="formObj.isDutyPers =='2'">
            <a-radio-group v-model:value="formObj.isDutySafPers">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutySafPers == '2'" type="link" @click="addProblem('isDutySafPers')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置责任人牌" required>
            <a-radio-group v-model:value="formObj.isDutyLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutyLogo == '2'" type="link" @click="addProblem('isDutyLogo')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否在跨县级行政区域交界处设立界桩" required>
            <a-radio-group v-model:value="formObj.isDutySite">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDutySite == '2'" type="link" @click="addProblem('isDutySite')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="穿堤建筑物与堤防的接合是否完好、紧密，无裂缝、渗漏、沉陷等现象" required>
            <a-radio-group v-model:value="formObj.isCrossFull">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="穿堤建筑物与堤防的接合处是否无裂缝现象" required v-if="formObj.isCrossFull=='2'">
            <a-radio-group v-model:value="formObj.isCrossFissure">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isCrossFissure == '2'" type="link" @click="addProblem('isCrossFissure')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="穿堤建筑物与堤防的接合处是否无渗漏现象" required v-if="formObj.isCrossFull=='2'">
            <a-radio-group v-model:value="formObj.isCrossLeak">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isCrossLeak == '2'" type="link" @click="addProblem('isCrossLeak')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="穿堤建筑物与堤防的接合处是否无沉陷现象" required v-if="formObj.isCrossFull=='2'">
            <a-radio-group v-model:value="formObj.isCrossSink">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isCrossSink == '2'" type="link" @click="addProblem('isCrossSink')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="穿堤建筑物闸门、金属结构及启闭设备养护是否良好、运转灵活" required>
            <a-radio-group v-model:value="formObj.isCrossRun">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isCrossRun == '2'" type="link" @click="addProblem('isCrossRun')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="穿堤建筑物混凝土构件是否无老化破损现象" required>
            <a-radio-group v-model:value="formObj.isCrossOld">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isCrossOld == '2'" type="link" @click="addProblem('isCrossOld')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无乱垦、乱挖、乱占、养禽放牧现象" required>
            <a-radio-group v-model:value="formObj.isManUnrule">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无乱垦现象" required v-if="formObj.isManUnrule=='2'">
            <a-radio-group v-model:value="formObj.isManAssart">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isManAssart == '2'" type="link" @click="addProblem('isManAssart')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无乱挖现象" required v-if="formObj.isManUnrule=='2'">
            <a-radio-group v-model:value="formObj.isManDig">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isManDig == '2'" type="link" @click="addProblem('isManDig')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无养禽放牧现象" required v-if="formObj.isManUnrule=='2'">
            <a-radio-group v-model:value="formObj.isManAquat">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isManAquat == '2'" type="link" @click="addProblem('isManAquat')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无爆破、打井、挖沙、取土、违章建筑等危害工程安全活动" required>
            <a-radio-group v-model:value="formObj.isManBreak">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无爆破活动" required v-if="formObj.isManBreak =='2'">
            <a-radio-group v-model:value="formObj.isManBlast">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isManBlast == '2'" type="link" @click="addProblem('isManBlast')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无打井活动" required v-if="formObj.isManBreak =='2'">
            <a-radio-group v-model:value="formObj.isManWell">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isManWell == '2'" type="link" @click="addProblem('isManWell')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无取土活动" required v-if="formObj.isManBreak =='2'">
            <a-radio-group v-model:value="formObj.isManSoil">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isManSoil == '2'" type="link" @click="addProblem('isManSoil')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="管理范围内是否无违章建筑活动" required v-if="formObj.isManBreak =='2'">
            <a-radio-group v-model:value="formObj.isManBuld">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isManBuld == '2'" type="link" @click="addProblem('isManBuld')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item :wrapper-col="{ span: 10, offset: 14 }">
            <a-button type="primary" @click="addHandler" v-if="openType">保 存</a-button>
          </a-form-item>
        </a-form>
      </a-layout-content>
      <problem-dialog
        v-if="showAddProblemDialog && openType"
        :objType="90"
        :villType="90"
        :objId="currentObjectId"
        :objName="currentObjectName"
        :problemMiddleType="'堤防工程安全度汛'"
        :problData="probId"
        @closeDialog="closePlDialog"
        :currentObjectRgstrId="currentObjectRgstrId"></problem-dialog>
    </a-layout>
  </div>
</template>

<script>
import { getRgstridDikenjxday } from '../../../api/duChaTianBao';
import request from '../../../utils/gw_ajax_request';
import { formatDateTimeD } from '../../../utils/gw_date';
import inputWith from '../../../widgets/inuptWith.vue';
import problemDialog from '../../duChaWenTi/problemDialog.vue';
export default {
  components: {
    inputWith: inputWith,
    problemDialog,
  },
  props: [
    'currentObjectId',
    'currentObjectName',
    'currentObjectRgstrId',
    'openType',
  ],
  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 (value && !isMob.test(value) && !isPhone.test(value)) {
        callback(new Error('请输入合理电话'));
      } else if (value && (isMob.test(value) || isPhone.test(value))) {
        callback();
      }
      // setTimeout(() => {
      // }, 1000);
    };
    return {
      id: '',
      objtbStatu: {
        scencState: '',
        rgstrId: '',
        id: '',
        state: '',
      },
      rules: {
        wiunWaoLegPersTel: [{ validator: checkTel, trigger: 'blur' }],
        techPersTel: [{ validator: checkTel, trigger: 'blur' }],
        patrolPersTel: [{ validator: checkTel, trigger: 'blur' }],
      },
      jqmmDialogShow: false,
      type: '',
      formObj: {
        isDutySafPers: '',
        isDutyLogo: '',
        isDutySite: '',
        isCrossFull: '',
        isCrossFissure: '',
        isCrossLeak: '',
        isCrossSink: '',
        isCrossRun: '',
        isCrossOld: '',
        isManUnrule: '',
        isManAssart: '',
        isManDig: '',
        isManOccupa: '',
        isManAquat: '',
        isManBreak: '',
        isManBlast: '',
        isManWell: '',
        isManSand: '',
        isManSoil: '',
        isManBuld: '',
        isDutyDep: '',
        isDutyPers: '',
        isDutyGovPers: '',
        isDutyFldPers: '',
        isDutyTchPers: '',
        isDutyChkPers: '',
      },
      dialogFormVisible: false,
      formLabelWidth: '180px',
      loading: true,
      operationType1: '',
      rsvrRules: null,
      probId: '',
      showAddProblemDialog: false,
    };
  },
  computed: {
    recPersId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '';
    },
  },
  created() {
    this.findItemByType();
  },
  mounted() {
    this.getRgstridObj();
  },
  watch: {
    currentObjectRgstrId(n, o) {
      this.getRgstridObj();
    },
  },
  methods: {
    jqmmDialogClose() {
      this.jqmmDialogShow = false;
    },
    showPic(type) {
      this.type = type;
      this.jqmmDialogShow = true;
    },
    getRgstridObj() {
      getRgstridDikenjxday(this.currentObjectRgstrId).then((res) => {
        if (res.data) {
          this.formObj = res.data;
        } else {
          this.formObj = {};
        }
      });
    },
    addHandler() {
      this.formObj['rgstrId'] = this.currentObjectRgstrId;
      this.formObj['persId'] = this.recPersId;
      if (
        this.formObj.isDutyDep == null &&
        this.formObj.isDutyPers == null &&
        this.formObj.isDutyLogo == null &&
        this.formObj.isDutySite == null &&
        this.formObj.isCrossFull == null &&
        this.formObj.isCrossRun == null &&
        this.formObj.isCrossOld == null &&
        this.formObj.isManUnrule == null &&
        this.formObj.isManBreak == null
      ) {
        this.formObj['state'] = '0';
      } else if (
        this.formObj.isDutyDep != null &&
        this.formObj.isDutyPers != null &&
        this.formObj.isDutyLogo != null &&
        this.formObj.isDutySite != null &&
        this.formObj.isCrossFull != null &&
        this.formObj.isCrossRun != null &&
        this.formObj.isCrossOld != null &&
        this.formObj.isManUnrule != null &&
        this.formObj.isManBreak != null
      ) {
        this.formObj['state'] = '2';
      } else {
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存督查情况信息？',
        okType: 'warning',
        onOk: () => {
          request.post('/bis/insp/dikenjx/day', this.formObj).then((res) => {
            if (res.success) {
              this.$message.success('提交成功');
            }
          });
        },
      });
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_DIKENJX_DAY',
      };
      request
        .post('/bis/insp/item/ques/info/findItemByType', obj)
        .then((res) => {
          this.rsvrRules = res.data;
        });
    },
    addProblem(item) {
      const rest = this.rsvrRules.filter((e) => {
        return e.eName === item;
      });
      this.probId = rest[0].id;
      this.showAddProblemDialog = true;
    },
    formatRadio(val) {
      if (val == '1') {
        return '是';
      } else if (val == '2') {
        return '否';
      } else {
        return val;
      }
    },
    closePlDialog(val) {
      this.showAddProblemDialog = false;
    },
  },
};
</script>

<style lang='less' scoped>
#dcdxHeader {
  padding: 15px 20px;
}

#dxdcFooter {
  text-align: center;
}

#dxdcAside {
  border: 1px solid #d5d5ff;
}

.el-dialog__wrapper .el-treeWhite {
  /* max-height: 260px !important; */
}

.add-problem-icon {
  font-size: 16px;
}

.el-icon-camera-solid,
.el-icon-circle-plus {
  margin-left: 20px;
  color: #00bbff;
  font-size: 18px;
  line-height: 12px;
  vertical-align: middle;
  cursor: pointer;
}

.el-icon-circle-plus {
  vertical-align: top;
}

.tip_info {
  margin-left: 20px;
  font-size: 12px;
  color: #ff0000;
}
</style>
