<template>
  <div id="">
    <a-layout>
      <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" :label-col="{ span: 10 }" :wrapper-col="{ span: 14 }" :rules="rules">
          <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.isFloodApp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isFloodApp == '2'" type="link" @click="addProblem('isFloodApp')">
                <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.isPrjtApp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPrjtApp == '2'" type="link" @click="addProblem('isPrjtApp')">
                <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.isPrjtTerm">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPrjtTerm == '2'" type="link" @click="addProblem('isPrjtTerm')">
                <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.isChkFlood">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChkFlood == '2'" type="link" @click="addProblem('isChkFlood')">
                <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.isSendFlood">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSendFlood == '2'" type="link" @click="addProblem('isSendFlood')">
                <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.isSendSys">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSendSys == '2'" type="link" @click="addProblem('isSendSys')">
                <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.isSendTerm">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSendTerm == '2'" type="link" @click="addProblem('isSendTerm')">
                <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.isRunOver">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isRunOver == '2'" type="link" @click="addProblem('isRunOver')">
                <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.isNrunIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNrunIssu == '2'" type="link" @click="addProblem('isNrunIssu')">
                <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.isNreasonIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNreasonIssu == '2'" type="link" @click="addProblem('isNreasonIssu')">
                <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.isSafLow">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSafLow == '2'" type="link" @click="addProblem('isSafLow')">
                <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.isMend">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMend == '2'" type="link" @click="addProblem('isMend')">
                <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.isChk">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChk == '2'" type="link" @click="addProblem('isChk')">
                <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.isNchk">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNchk == '2'" type="link" @click="addProblem('isNchk')">
                <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.isRefuseChk">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isRefuseChk == '2'" type="link" @click="addProblem('isRefuseChk')">
                <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.isPblm">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPblm == '2'" type="link" @click="addProblem('isPblm')">
                <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="86"
        :villType="86"
        :objId="currentObjectId"
        :objName="currentObjectName"
        :problemMiddleType="'水库防洪调度'"
        :problData="probId"
        @closeDialog="closePlDialog"
        :currentObjectRgstrId="currentObjectRgstrId"></problem-dialog>
    </a-layout>
  </div>
</template>

<script>
import { getRgstridRsfcojxTflwlii } from '../../../api/duChaTianBao';
import request from '../../../utils/gw_ajax_request';
import { formatDateTimeD } from '../../../utils/gw_date.js';
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: {
        isFloodApp: '',
        isPrjtApp: '',
        isPrjtTerm: '',
        isChkFlood: '',
        isSendFlood: '',
        isSendSys: '',
        isSendTerm: '',
        isRunOver: '',
        isNrunIssu: '',
        isNreasonIssu: '',
        isSafLow: '',
        isMend: '',
        isChk: '',
        isNchk: '',
        isRefuseChk: '',
        isPblm: '',
      },
      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() {
      getRgstridRsfcojxTflwlii(this.currentObjectRgstrId).then((res) => {
        if (res.data) {
          if (res.data.state == null) {
            this.initDefault();
          } else {
            this.formObj = res.data;
          }
        } else {
          this.initDefault();
        }
      });
    },
    initDefault() {
      this.formObj = {
        isFloodApp: '1',
        isPrjtApp: '1',
        isPrjtTerm: '1',
        isChkFlood: '1',
        isSendFlood: '1',
        isSendSys: '1',
        isSendTerm: '1',
        isRunOver: '1',
        isNrunIssu: '1',
        isNreasonIssu: '1',
        isSafLow: '1',
        isMend: '1',
        isChk: '1',
        isNchk: '1',
        isRefuseChk: '1',
        isPblm: '1',
      };
    },
    addHandler() {
      this.formObj['rgstrId'] = this.currentObjectRgstrId;
      this.formObj['persId'] = this.recPersId;
      if (
        this.formObj.isFloodApp == null &&
        this.formObj.isPrjtApp == null &&
        this.formObj.isPrjtTerm == null &&
        this.formObj.isChkFlood == null &&
        this.formObj.isSendFlood == null &&
        this.formObj.isSendSys == null &&
        this.formObj.isSendTerm == null &&
        this.formObj.isRunOver == null &&
        this.formObj.isNrunIssu == null &&
        this.formObj.isNreasonIssu == null &&
        this.formObj.isSafLow == null &&
        this.formObj.isMend == null &&
        this.formObj.isChk == null &&
        this.formObj.isNchk == null &&
        this.formObj.isRefuseChk == null &&
        this.formObj.isPblm == null
      ) {
        this.formObj['state'] = '0';
      } else if (
        this.formObj.isFloodApp != null &&
        this.formObj.isPrjtApp != null &&
        this.formObj.isPrjtTerm != null &&
        this.formObj.isChkFlood != null &&
        this.formObj.isSendFlood != null &&
        this.formObj.isSendSys != null &&
        this.formObj.isSendTerm != null &&
        this.formObj.isRunOver != null &&
        this.formObj.isNrunIssu != null &&
        this.formObj.isNreasonIssu != null &&
        this.formObj.isSafLow != null &&
        this.formObj.isMend != null &&
        this.formObj.isChk != null &&
        this.formObj.isNchk != null &&
        this.formObj.isRefuseChk != null &&
        this.formObj.isPblm != null
      ) {
        this.formObj['state'] = '2';
      } else {
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存督查情况信息？',
        okType: 'warning',
        onOk: () => {
          request
            .post('/bis/insp/rsfcojx/tflwlii', this.formObj)
            .then((res) => {
              if (res.success) {
                this.$message.success('提交成功');
              }
            });
        },
      });
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_RSFCOJX_TFLWLII',
      };
      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>
