<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.isTopDstr">
              <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.isTopDstr=='2'">
            <a-radio-group v-model:value="formObj.isTopRoad">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isTopRoad == '2'" type="link" @click="addProblem('isTopRoad')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="堤顶雨后无积水" required v-if="formObj.isTopDstr=='2'">
            <a-radio-group v-model:value="formObj.isTopRain">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isTopRain == '2'" type="link" @click="addProblem('isTopRain')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="堤顶无杂物垃圾" required v-if="formObj.isTopDstr=='2'">
            <a-radio-group v-model:value="formObj.isTopRubb">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isTopRubb == '2'" type="link" @click="addProblem('isTopRubb')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="迎水坡是否无杂物垃圾，草皮（高度不超过30cm）是否平整、无高杆杂草、杂灌、乔木，其它护坡是否无破损、塌陷" required>
            <a-radio-group v-model:value="formObj.isFaceDstr">
              <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.isFaceDstr =='2'">
            <a-radio-group v-model:value="formObj.isFaceSubs">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isFaceSubs == '2'" type="link" @click="addProblem('isFaceSubs')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="迎水坡护坡草皮平整" required v-if="formObj.isFaceDstr =='2'">
            <a-radio-group v-model:value="formObj.isFaceWeed">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isFaceWeed == '2'" type="link" @click="addProblem('isFaceWeed')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="迎水坡护坡无高杆杂草、杂灌、乔木" required v-if="formObj.isFaceDstr =='2'">
            <a-radio-group v-model:value="formObj.isFaceClean">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isFaceClean == '2'" type="link" @click="addProblem('isFaceClean')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="迎水坡护坡无杂物垃圾" required v-if="formObj.isFaceDstr =='2'">
            <a-radio-group v-model:value="formObj.isFaceRubb">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isFaceRubb == '2'" type="link" @click="addProblem('isFaceRubb')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="背水坡是否无杂物垃圾，草皮（高度不超过30cm）是否平整、无高杆杂草、杂灌、乔木，其它护坡是否无破损、塌陷" required>
            <a-radio-group v-model:value="formObj.isBackDstr">
              <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.isBackDstr =='2'">
            <a-radio-group v-model:value="formObj.isBackRoad">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBackRoad == '2'" type="link" @click="addProblem('isBackRoad')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="背水坡护坡草皮平整" required v-if="formObj.isBackDstr =='2'">
            <a-radio-group v-model:value="formObj.isBackWeed">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBackWeed == '2'" type="link" @click="addProblem('isBackWeed')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="背水坡护坡无高杆杂草、杂灌、乔木" required v-if="formObj.isBackDstr =='2'">
            <a-radio-group v-model:value="formObj.isBackClean">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBackClean == '2'" type="link" @click="addProblem('isBackClean')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="背水坡护坡无杂物垃圾" required v-if="formObj.isBackDstr =='2'">
            <a-radio-group v-model:value="formObj.isBackRubb">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBackRubb == '2'" type="link" @click="addProblem('isBackRubb')">
                <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.isCrossSmooth">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isCrossSmooth == '2'" type="link" @click="addProblem('isCrossSmooth')">
                <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.isChkDstr">
              <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.isChkDstr =='2'">
            <a-radio-group v-model:value="formObj.isChkClean">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChkClean == '2'" type="link" @click="addProblem('isChkClean')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="巡查通道通畅，无杂物垃圾" required v-if="formObj.isChkDstr =='2'">
            <a-radio-group v-model:value="formObj.isBottomDstr">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBottomDstr == '2'" type="link" @click="addProblem('isBottomDstr')">
                <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.isBottomSubb">
              <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.isBottomSubb =='2'">
            <a-radio-group v-model:value="formObj.isBottomRise">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBottomRise == '2'" type="link" @click="addProblem('isBottomRise')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="堤脚是否无下沉现象" required v-if="formObj.isBottomSubb =='2'">
            <a-radio-group v-model:value="formObj.isBottomSink">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBottomSink == '2'" type="link" @click="addProblem('isBottomSink')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="堤脚是否无残缺现象" required v-if="formObj.isBottomSubb =='2'">
            <a-radio-group v-model:value="formObj.isBottomDisable">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBottomDisable == '2'" type="link" @click="addProblem('isBottomDisable')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="堤脚是否无冲刷现象" required v-if="formObj.isBottomSubb =='2'">
            <a-radio-group v-model:value="formObj.isBottomWash">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBottomWash == '2'" type="link" @click="addProblem('isBottomWash')">
                <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 { getRgstridDikenjxface } 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: {
        isTopDstr: '',
        isTopRoad: '',
        isTopRain: '',
        isTopRubb: '',
        isFaceDstr: '',
        isFaceSubs: '',
        isFaceWeed: '',
        isFaceClean: '',
        isFaceRubb: '',
        isBackDstr: '',
        isBackRoad: '',
        isBackWeed: '',
        isBackClean: '',
        isBackRubb: '',
        isCrossSmooth: '',
        isChkDstr: '',
        isChkClean: '',
        isBottomDstr: '',
        isBottomSubb: '',
        isBottomRise: '',
        isBottomSink: '',
        isBottomDisable: '',
        isBottomWash: '',
      },
      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() {
      getRgstridDikenjxface(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.isTopDstr == null &&
        this.formObj.isFaceDstr == null &&
        this.formObj.isBackDstr == null &&
        this.formObj.isCrossSmooth == null &&
        this.formObj.isChkDstr == null &&
        this.formObj.isBottomSubb == null
      ) {
        this.formObj['state'] = '0';
      } else if (
        this.formObj.isTopDstr != null &&
        this.formObj.isFaceDstr != null &&
        this.formObj.isBackDstr != null &&
        this.formObj.isCrossSmooth != null &&
        this.formObj.isChkDstr != null &&
        this.formObj.isBottomSubb != null
      ) {
        this.formObj['state'] = '2';
      } else {
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存督查情况信息？',
        okType: 'warning',
        onOk: () => {
          request.post('/bis/insp/dikenjx/face', this.formObj).then((res) => {
            if (res.success) {
              this.$message.success('提交成功');
            }
          });
        },
      });
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_DIKENJX_FACE',
      };
      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>
