<template>
  <div class="gcsthyxglqk">
    <a-layout>
      <a-layout-content style="border:1px solid #d5d5ff;margin-left:5px;padding:0px;">
        <p style="font-weight:bolder;background-color:#d5d5ff;padding:3px;">信息填报</p>
        <a-form :model="addObj" :label-col="{span: 10}" :wrapper-col="{span: 14}" :rules="rules" ref="addObj">
          <p style="margin-top:10px;margin-bottom: 10px">
            <a-icon type="caret-right" />
            <span style="width:120px;padding-left: 10px">组织机构、制度建设及落实</span>
            <span class="hrs"> </span>
          </p>
          <a-form-item label="重要小型水库是否明确水库管理机构">
            <a-radio-group v-model:value="addObj.jgGljg">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否有管护人员" prop="jgGhry" v-if="addObj.jgGljg == '0'">
            <a-radio-group v-model:value="addObj.jgGhry">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button @click="addProblem('jgGhry',addObj.jgGhry)" type="link" v-if="addObj.jgGhry =='1' || addObj.jgGhry =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="一般小型水库是否专人管理" prop="jgZrgl">
            <a-radio-group v-model:value="addObj.jgZrgl">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button @click="addProblem('jgZrgl',addObj.jgZrgl)" type="link" v-if="addObj.jgZrgl =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否制定水库运行管理需要的各项制度" prop="zdZdzd">
            <a-radio-group v-model:value="addObj.zdZdzd">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否影响运行安全" prop="zdYxaqyx" v-if="addObj.zdZdzd == '0'">
            <a-radio-group v-model:value="addObj.zdYxaqyx">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button @click="addProblem('zdYxaqyx',addObj.zdYxaqyx)" type="link" v-if="addObj.zdYxaqyx =='1' || addObj.zdYxaqyx =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="水库管理制度是否满足运行管理工作需要，针对性、操作性是否明确" prop="zdMzglxy" v-if="addObj.zdZdzd == '1'">
            <a-radio-group v-model:value="addObj.zdMzglxy">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button @click="addProblem('zdMzglxy',addObj.zdMzglxy)" type="link" v-if="addObj.zdMzglxy =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否按照要求执行水库管理制度" prop="isRuleApplied" v-if="addObj.zdZdzd == '1'">
            <a-radio-group v-model:value="addObj.zdZxzd">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否影响运行安全" prop="zdZxzdyxaqyx" v-if="addObj.zdZxzd == '0' && addObj.zdZdzd == '1'">
            <a-radio-group v-model:value="addObj.zdZxzdyxaqyx">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button
                @click="addProblem('zdZxzdyxaqyx',addObj.zdZxzdyxaqyx)"
                type="link"
                v-if="addObj.zdZxzdyxaqyx =='1' || addObj.zdZxzdyxaqyx =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="水库管理经费来源是否稳定（检查重点：2019年维养资金是否足额落实到位）">
            <a-radio-group v-model:value="addObj.jfJflywd">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="水库管理经费情况" v-if="addObj.jfJflywd == '0'">
            <a-radio-group v-model:value="addObj.jfJfglqk">
              <a-radio value="1">经费不足</a-radio>
              <a-radio value="0">无经费来源</a-radio>
              <a-button
                @click="addProblem('jfJfglqk',addObj.jfJfglqk)"
                type="link"
                v-if="addObj.jfJfglqk =='1' || addObj.jfJfglqk =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <p style="margin-top:10px;margin-bottom: 10px">
            <a-icon type="caret-right" />
            <span style="width:120px;padding-left: 10px">水库大坝安全责任制</span>
            <span class="hrs"> </span>
          </p>
          <a-form-item label="大坝安全责任人是否明确">
            <a-radio-group v-model:value="addObj.aqzrrMq">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="大坝安全责任人落实情况" v-if="addObj.aqzrrMq == '0'">
            <a-radio-group v-model:value="addObj.aqzrrLs">
              <a-radio value="1">未公示</a-radio>
              <a-radio value="0">不落实、不明确</a-radio>
              <a-button
                @click="addProblem('aqzrrLs',addObj.aqzrrLs)"
                type="link"
                v-if="addObj.aqzrrLs =='1' || addObj.aqzrrLs =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="大坝安全责任人履责情况" v-if="addObj.aqzrrMq == '1'">
            <a-radio-group v-model:value="addObj.aqzrrLzqk">
              <a-radio value="1">好</a-radio>
              <a-radio value="2">差</a-radio>
              <a-radio value="3">差，并影响运行安全</a-radio>
              <a-button
                @click="addProblem('aqzrrLzqk',addObj.aqzrrLzqk)"
                type="link"
                v-if="addObj.aqzrrLzqk =='2' || addObj.aqzrrLzqk =='3'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="工程管理范围和保护范围是否明确">
            <a-radio-group v-model:value="addObj.aqGlfw">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button @click="addProblem('aqGlfw',addObj.aqGlfw)" type="link" v-if="addObj.aqGlfw =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否按规定进行年度安全检查">
            <a-radio-group v-model:value="addObj.aqJxndjc">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="年度安全检查情况" v-if="addObj.aqJxndjc == '0'">
            <a-radio-group v-model:value="addObj.aqNdjcjg">
              <a-radio value="1">未形成检查报告</a-radio>
              <a-radio value="0">未开展检查</a-radio>
              <a-button @click="addProblem('aqNdjcjg',addObj.aqNdjcjg)" type="link" v-if="addObj.aqNdjcjg =='0' || addObj.aqNdjcjg =='1'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <p style="margin-top:10px;margin-bottom: 10px">
            <a-icon type="caret-right" />
            <span style="width:120px;padding-left: 10px">注册登记</span>
            <span class="hrs"> </span>
          </p>
          <a-form-item label="水库是否按要求注册登记">
            <a-radio-group v-model:value="addObj.zcZcdj">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button @click="addProblem('zcZcdj',addObj.zcZcdj)" type="link" v-if="addObj.zcZcdj =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="注册登记信息是否存在问题" v-if="addObj.zcZcdj == '1'">
            <a-radio-group v-model:value="addObj.zcCzwt">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="注册登记信息问题" v-if="addObj.zcCzwt == '1' && addObj.zcZcdj == '1'">
            <a-radio-group v-model:value="addObj.zcZcxxwt">
              <a-radio value="1">其他问题</a-radio>
              <a-radio value="2">错误信息</a-radio>
              <a-radio value="3">虚假信息</a-radio>
              <a-button @click="addProblem('zcZcxxwt',addObj.zcZcxxwt)" type="link" v-if="ddObj.zcZcxxwt =='2' || addObj.zcZcxxwt =='3' || addObj.zcZcxxwt =='1'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <p style="margin-top:10px;margin-bottom: 10px">
            <a-icon type="caret-right" />
            <span style="width:120px;padding-left: 10px">信息档案管理</span>
            <span class="hrs"> </span>
          </p>
          <a-form-item label="水库原始资料或施工等档案资料是否齐全">
            <a-radio-group v-model:value="addObj.zcZlqq">
              <a-radio value="1">是</a-radio>
              <a-radio value="0">否</a-radio>
              <a-button @click="addProblem('zcZlqq',addObj.zcZlqq)" type="link" v-if="addObj.zcZlqq =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="运行管理工作信息记录情况">
            <a-radio-group v-model:value="addObj.zzXxjlqk">
              <a-radio value="1">记录完整</a-radio>
              <a-radio value="2">记录不完整</a-radio>
              <a-radio value="3">无记录或记录不真实</a-radio>
              <a-button @click="addProblem('zzXxjlqk',addObj.zzXxjlqk)" type="link" v-if="addObj.zzXxjlqk =='2' || addObj.zzXxjlqk =='3'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="档案存储情况">
            <a-radio-group v-model:value="addObj.zcDaccqk">
              <a-radio value="1">存储正常</a-radio>
              <a-radio value="0">查找困难</a-radio>
              <a-button @click="addProblem('zcDaccqk',addObj.zcDaccqk)" type="link" v-if="addObj.zcDaccqk =='0'">
                <a-icon type="plus-circle" theme="filled" class="add-problem-icon" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item :wrapper-col="{ span: 14, offset: 10 }">
            <a-button type="primary" @click="makesure('addObj')" v-if="openType">保 存</a-button>
          </a-form-item>
        </a-form>
      </a-layout-content>
      <problem-dialog
        v-if="showAddProblemDialog && openType"
        :objType="pType"
        :villType="0"
        :objId="currentObjectId"
        :objName="currentObjectName"
        :problemMiddleType="'小水库'"
        :problData="probId"
        @closeDialog="closePlDialog"
        :currentObjectRgstrId="currentObjectRgstrId"> </problem-dialog>
    </a-layout>
  </div>
</template>

<script>
import { getLyjglist, getZhgllist } from '../../../api/duChaTianBao';
import request from '../../../utils/gw_ajax_request';
import problemDialog from '../../duChaWenTi/problemDialog.vue';
export default {
  components: {
    problemDialog,
  },
  props: [
    'currentObjectId',
    'currentObjectName',
    'currentObjectRgstrId',
    'pType',
    'openType',
  ],
  data() {
    return {
      objtbStatu: {
        resRunStat: '',
        rgstrId: '',
      },
      dxdcMainHeight: window.innerHeight - 197,
      dialogFormVisible: false,
      formLabelWidth: '300px',
      loading: true,
      addObj: {
        rgstrId: '',
        jgGljg: '',
        jgGhry: '',
        jgZrgl: '',
        zdZdzd: '',
        // safeComment: "",
        zdYxaqyx: '',
        zdMzglxy: '',
        zdZxzd: '',
        zdZxzdyxaqyx: '',
        jfJflywd: '',
        jfJfglqk: '',
        aqzrrMq: '', // 是否有安全管理（防汛）应急方案
        aqzrrLs: '', // 是否鉴定为三类坝的水库
        aqzrrLzqk: '', // 是否采取限制运用措施
        aqGlfw: '', // 其他水库
        aqJxndjc: '', // 坝体周边是否整洁
        aqNdjcjg: '', // 是否有管护人员
        zcCzwt: '',
        zcZcdj: '',
        zcZcxxwt: '',
        zcZlqq: '',
        zzXxjlqk: '',
        zcDaccqk: '',
        recPersId: '',
        recPers2: '',
        recPersTel: '',
        createTime: '',
        updateTime: '',
        status: '',
      },
      rules: {},
      operationType1: '',
      lyjg: [],
      placeholder: '',
      rsvrRules: null,
      probId: '',
      showAddProblemDialog: false,
    };
  },
  computed: {
    recPersId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '1098101939614724096';
    },
  },
  created() {
    this.findItemByType();
    this.getformList();
  },
  mounted() {
    this.getLyjgList();
  },
  watch: {
    currentObjectRgstrId(n, o) {
      this.getformList();
    },
  },
  methods: {
    getLyjgList() {
      getLyjglist().then((res) => {
        if (res.success) {
          this.lyjg = res.data;
          this.placeholder = this.lyjg[0].pnm;
          this.addObj.reverOrg = this.lyjg[0].id;
          this.getformList();
        } else {
          this.getformList();
        }
      });
    },
    getformList() {
      getZhgllist(this.currentObjectRgstrId).then((res) => {
        if (res.success) {
          if (res.data && Object.keys(res.data).length) {
            this.addObj = res.data;
            this.operationType1 = 'update';
          } else {
            this.addObj = {};
            this.operationType1 = 'add';
          }
        } else {
        }
        console.log(res.data);
      });
    },
    // 保存
    makesure(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const _self = this;
          this.addObj['rgstrId'] = this.currentObjectRgstrId;
          this.addObj['recPersId'] = this.recPersId;
          this.objtbStatu.rgstrId = this.currentObjectRgstrId;

          this.$confirm({
            title: '提示',
            content: '确认保存运行管理情况信息吗？',
            okType: 'warning',
            onOk: () => {
              if (_self.operationType1 == 'add') {
                request.post('/dc/insp/xskaqZhgl', _self.addObj).then((res) => {
                  if (res.success) {
                    _self.$message.success('添加成功');
                    /* request
                        .post("/dc/insp/rsvrRgstr/update", _self.objtbStatu)
                        .then(res => {
                            res;
                        }); */
                    _self.$emit('addShuiKuSuccess');
                  }
                });
              } else {
                request
                  .post('/dc/insp/xskaqZhgl/update', _self.addObj)
                  .then((res) => {
                    if (res.success) {
                      _self.$message.success('修改成功');
                      /* request
                          .post("/dc/insp/rsvrRgstr/update", _self.objtbStatu)
                          .then(res => {
                              res;
                          }); */
                      _self.$emit('addShuiKuSuccess');
                    }
                  });
              }
            },
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 查看
    makeshow(type, row) {
      this.dialogFormVisible = true;
    },
    formatRadio(val) {
      if (val == '1') {
        return '是';
      } else if (val == '0') {
        return '否';
      } else {
        return val;
      }
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_XSKAQ_ZHGL',
        type: this.pType,
      };
      request
        .post('/bis/insp/item/ques/info/findItemByType', obj)
        .then((res) => {
          this.rsvrRules = res.data;
        });
    },
    addProblem(item, iValue) {
      const rest = this.rsvrRules.filter((e) => {
        return e.iValue === iValue && e.eName === item;
      });
      if (rest[0]) {
        this.probId = rest[0].id;
      }
      this.showAddProblemDialog = true;
    },
    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;
}
</style>
