<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.isMakItem">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMakItem == '2'" type="link" @click="addProblem('isMakItem')">
                <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.isPubSys">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPubSys == '2'" type="link" @click="addProblem('isPubSys')">
                <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.isPubSite">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPubSite == '2'" type="link" @click="addProblem('isPubSite')">
                <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.isMakFlow">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMakFlow == '2'" type="link" @click="addProblem('isMakFlow')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="行政处罚、行政许可的执法决定信息是否及时（7个工作日内）在本级政府网站、或在本单位网站、江西省行政执法服务网等平台公开" required>
            <a-radio-group v-model:value="formObj.isPubItm">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPubItm == '2'" type="link" @click="addProblem('isPubItm')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <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.isMakList">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMakList == '2'" type="link" @click="addProblem('isMakList')">
                <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.isMakRole">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMakRole == '2'" type="link" @click="addProblem('isMakRole')">
                <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.isCnfgDvc">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isCnfgDvc == '2'" type="link" @click="addProblem('isCnfgDvc')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <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.isSureSys">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSureSys == '2'" type="link" @click="addProblem('isSureSys')">
                <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.isMakGlist">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMakGlist == '2'" type="link" @click="addProblem('isMakGlist')">
                <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="makesure('addObj')" v-if="openType">保 存</a-button>
          </a-form-item>
        </a-form>
      </a-layout-content>
      <problem-dialog
        v-if="showAddProblemDialog && openType"
        :objType="85"
        :villType="85"
        :objId="currentObjectId"
        :objName="currentObjectName"
        :problemMiddleType="'水行政执法'"
        :problData="probId"
        @closeDialog="closePlDialog"
        :currentObjectRgstrId="currentObjectRgstrId"></problem-dialog>
    </a-layout>
  </div>
</template>

<script>
import { getRgstridWtgovjxSys } 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: {
        isMakItem: '',
        isPubSys: '',
        isPubSite: '',
        isMakFlow: '',
        isPubItm: '',
        isMakList: '',
        isMakRole: '',
        isCnfgDvc: '',
        isSureSys: '',
        isMakGlist: '',
      },
      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() {
      getRgstridWtgovjxSys(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 = {
        isMakItem: '1',
        isPubSys: '1',
        isPubSite: '1',
        isMakFlow: '1',
        isPubItm: '1',
        isMakList: '1',
        isMakRole: '1',
        isCnfgDvc: '1',
        isSureSys: '1',
        isMakGlist: '1',
      };
    },
    addHandler() {
      this.formObj['rgstrId'] = this.currentObjectRgstrId;
      this.formObj['persId'] = this.recPersId;
      if (
        this.formObj.isMakItem == null &&
        this.formObj.isPubSys == null &&
        this.formObj.isPubSite == null &&
        this.formObj.isMakFlow == null &&
        this.formObj.isPubItm == null &&
        this.formObj.isMakList == null &&
        this.formObj.isMakRole == null &&
        this.formObj.isCnfgDvc == null &&
        this.formObj.isSureSys == null &&
        this.formObj.isMakGlist == null
      ) {
        this.formObj['state'] = '0';
      } else if (
        this.formObj.isMakItem != null &&
        this.formObj.isPubSys != null &&
        this.formObj.isPubSite != null &&
        this.formObj.isMakFlow != null &&
        this.formObj.isPubItm != null &&
        this.formObj.isMakList != null &&
        this.formObj.isMakRole != null &&
        this.formObj.isCnfgDvc != null &&
        this.formObj.isSureSys != null &&
        this.formObj.isMakGlist != null
      ) {
        this.formObj['state'] = '2';
      } else {
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存督查情况信息？',
        okType: 'warning',
        onOk: () => {
          request.post('/bis/insp/wtgovjx/sys', this.formObj).then((res) => {
            if (res.success) {
              this.$message.success('提交成功');
            }
          });
        },
      });
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_WTGOVJX_SYS',
      };
      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>
