<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.isWrrPlan">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isWrrPlan == '2'" type="link" @click="addProblem('isWrrPlan')">
                <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.isChgPlan">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChgPlan == '2'" type="link" @click="addProblem('isChgPlan')">
                <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.isPlanApp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanApp == '2'" type="link" @click="addProblem('isPlanApp')">
                <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.isIntmApp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isIntmApp == '2'" type="link" @click="addProblem('isIntmApp')">
                <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.isPlanPut">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanPut == '2'" type="link" @click="addProblem('isPlanPut')">
                <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.isPlanCntn">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanCntn == '2'" type="link" @click="addProblem('isPlanCntn')">
                <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.isPlanIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanIssu == '2'" type="link" @click="addProblem('isPlanIssu')">
                <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.isNotPlanIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNotPlanIssu == '2'" type="link" @click="addProblem('isNotPlanIssu')">
                <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.isPlanRain">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanRain == '2'" type="link" @click="addProblem('isPlanRain')">
                <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.isNissuOrdr">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNissuOrdr == '2'" type="link" @click="addProblem('isNissuOrdr')">
                <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.isSendDep">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSendDep == '2'" type="link" @click="addProblem('isSendDep')">
                <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.isNsurParam">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNsurParam == '2'" type="link" @click="addProblem('isNsurParam')">
                <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.isRefuseIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isRefuseIssu == '2'" type="link" @click="addProblem('isRefuseIssu')">
                <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.isNplanIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNplanIssu == '2'" type="link" @click="addProblem('isNplanIssu')">
                <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.isIssuBack">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isIssuBack == '2'" type="link" @click="addProblem('isIssuBack')">
                <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.isSetDvc">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSetDvc == '2'" type="link" @click="addProblem('isSetDvc')">
                <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.isBuldSys">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBuldSys == '2'" type="link" @click="addProblem('isBuldSys')">
                <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.isPlanSend">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanSend == '2'" type="link" @click="addProblem('isPlanSend')">
                <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.isRunSendDep">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isRunSendDep == '2'" type="link" @click="addProblem('isRunSendDep')">
                <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.isWarnSend">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isWarnSend == '2'" type="link" @click="addProblem('isWarnSend')">
                <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.isNlogIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isNlogIssu == '2'" type="link" @click="addProblem('isNlogIssu')">
                <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.isLackIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isLackIssu == '2'" type="link" @click="addProblem('isLackIssu')">
                <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.isDsgIssu">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDsgIssu == '2'" type="link" @click="addProblem('isDsgIssu')">
                <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 { getRgstridRsfcojxFcs } 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: {
        isWrrPlan: '1',
        isChgPlan: '1',
        isPlanApp: '1',
        isIntmApp: '1',
        isPlanPut: '1',
        isPlanCntn: '1',
        isPlanIssu: '1',
        isNotPlanIssu: '1',
        isPlanRain: '1',
        isNissuOrdr: '1',
        isSendDep: '1',
        isNsurParam: '1',
        isRefuseIssu: '1',
        isNplanIssu: '1',
        isIssuBack: '1',
        isSetDvc: '1',
        isBuldSys: '1',
        isPlanSend: '1',
        isRunSendDep: '1',
        isWarnSend: '1',
        isNlogIssu: '1',
        isLackIssu: '1',
        isDsgIssu: '1',
      },
      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() {
      getRgstridRsfcojxFcs(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 = {
        isWrrPlan: '1',
        isChgPlan: '1',
        isPlanApp: '1',
        isIntmApp: '1',
        isPlanPut: '1',
        isPlanCntn: '1',
        isPlanIssu: '1',
        isNotPlanIssu: '1',
        isPlanRain: '1',
        isNissuOrdr: '1',
        isSendDep: '1',
        isNsurParam: '1',
        isRefuseIssu: '1',
        isNplanIssu: '1',
        isIssuBack: '1',
        isSetDvc: '1',
        isBuldSys: '1',
        isPlanSend: '1',
        isRunSendDep: '1',
        isWarnSend: '1',
        isNlogIssu: '1',
        isLackIssu: '1',
        isDsgIssu: '1',
      };
    },
    addHandler() {
      this.formObj['rgstrId'] = this.currentObjectRgstrId;
      this.formObj['persId'] = this.recPersId;
      if (
        this.formObj.isWrrPlan == null &&
        this.formObj.isChgPlan == null &&
        this.formObj.isPlanApp == null &&
        this.formObj.isIntmApp == null &&
        this.formObj.isPlanPut == null &&
        this.formObj.isPlanCntn == null &&
        this.formObj.isPlanIssu == null &&
        this.formObj.isNotPlanIssu == null &&
        this.formObj.isPlanRain == null &&
        this.formObj.isNissuOrdr == null &&
        this.formObj.isSendDep == null &&
        this.formObj.isNsurParam == null &&
        this.formObj.isRefuseIssu == null &&
        this.formObj.isNplanIssu == null &&
        this.formObj.isIssuBack == null &&
        this.formObj.isSetDvc == null &&
        this.formObj.isBuldSys == null &&
        this.formObj.isPlanSend == null &&
        this.formObj.isRunSendDep == null &&
        this.formObj.isWarnSend == null &&
        this.formObj.isNlogIssu == null &&
        this.formObj.isLackIssu == null &&
        this.formObj.isDsgIssu == null
      ) {
        this.formObj['state'] = '0';
      } else if (
        this.formObj.isWrrPlan != null &&
        this.formObj.isChgPlan != null &&
        this.formObj.isPlanApp != null &&
        this.formObj.isIntmApp != null &&
        this.formObj.isPlanPut != null &&
        this.formObj.isPlanCntn != null &&
        this.formObj.isPlanIssu != null &&
        this.formObj.isNotPlanIssu != null &&
        this.formObj.isPlanRain != null &&
        this.formObj.isNissuOrdr != null &&
        this.formObj.isSendDep != null &&
        this.formObj.isNsurParam != null &&
        this.formObj.isRefuseIssu != null &&
        this.formObj.isNplanIssu != null &&
        this.formObj.isIssuBack != null &&
        this.formObj.isSetDvc != null &&
        this.formObj.isBuldSys != null &&
        this.formObj.isPlanSend != null &&
        this.formObj.isRunSendDep != null &&
        this.formObj.isWarnSend != null &&
        this.formObj.isNlogIssu != null &&
        this.formObj.isLackIssu != null &&
        this.formObj.isDsgIssu != null
      ) {
        this.formObj['state'] = '2';
      } else {
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存督查情况信息？',
        okType: 'warning',
        onOk: () => {
          request.post('/bis/insp/rsfcojx/fcs', this.formObj).then((res) => {
            if (res.success) {
              this.$message.success('提交成功');
            }
          });
        },
      });
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_RSFCOJX_FCS',
      };
      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>
