<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" :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="1.监理是否到岗到位">
            <a-radio-group v-model:value="formObj.isInDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isInDuty == '2'" type="link" @click="addProblem('isInDuty')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="2.变更是否报项目法人批准">
            <a-radio-group v-model:value="formObj.isChgApp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChgApp == '2'" type="link" @click="addProblem('isChgApp')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
              <span class="tip_info">注：监理工程师未变更则默认为“是”，不产生问题</span>
            </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="3.是否编制监理规划">
            <a-radio-group v-model:value="formObj.isMkPlan">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
            <a-button v-if="formObj.isMkPlan == '2'" type="link" @click="addProblem('isMkPlan')">
              <a-icon type="plus-circle" theme="filled" />
            </a-button>
          </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="4.施工组织设计或施工技术方案（以下简称施工计划）审查（签）是否符合要求">
            <a-radio-group v-model:value="formObj.isDezCnf">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDezCnf == '2'" type="link" @click="addProblem('isDezCnf')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="5.工程进度支付报表审签是否符合要求">
            <a-radio-group v-model:value="formObj.isRptCnf">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isRptCnf == '2' || formObj.isRptCnf =='3'" type="link" @click="addProblem('isRptCnf')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="6.监理履职是否到位">
            <a-radio-group v-model:value="formObj.isWorkDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isWorkDuty == '2' || formObj.isWorkDuty =='3'" type="link" @click="addProblem('isWorkDuty')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="7.是否对施工单位的测量方案、成果进行批准">
            <a-radio-group v-model:value="formObj.isSchemeApp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSchemeApp == '2'" type="link" @click="addProblem('isSchemeApp')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="8.监理是否进行了跟踪检测">
            <a-radio-group v-model:value="formObj.isMon">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMon == '2' || formObj.isMon =='3'" type="link" @click="addProblem('isMon')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="9.监理是否进行了平行检测">
            <a-radio-group v-model:value="formObj.isChk">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChk == '2' || formObj.isChk == '3'" type="link" @click="addProblem('isChk')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="10.对进度控制是否到位">
            <a-radio-group v-model:value="formObj.isProgressIn">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isProgressIn == '2' || formObj.isProgressIn == '3'" type="link" @click="addProblem('isProgressIn')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="11.对质量控制是否到位">
            <a-radio-group v-model:value="formObj.isQualityIn">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isQualityIn == '2' || formObj.isQualityIn == '3'" type="link" @click="addProblem('isQualityIn')">
                <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="12.是否编制安全生产监理措施方案">
            <a-radio-group v-model:value="formObj.isBudScheme">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBudScheme == '2'" type="link" @click="addProblem('isBudScheme')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="13.是否组织进行各类安全检查">
            <a-radio-group v-model:value="formObj.isSafChk">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSafChk == '2' || formObj.isSafChk =='3'" type="link" @click="addProblem('isSafChk')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="14.是否组织进行召开安全例会">
            <a-radio-group v-model:value="formObj.isSafMeet">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSafMeet == '2' || formObj.isSafMeet =='3'" type="link" @click="addProblem('isSafMeet')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="15.是否对安全技术措施进行审查">
            <a-radio-group v-model:value="formObj.isSafTec">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSafTec == '2' || formObj.isSafTec =='3'" type="link" @click="addProblem('isSafTec')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="16.是否对专项施工方案进行审查">
            <a-radio-group v-model:value="formObj.isSchemeChk">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSchemeChk == '2' || formObj.isSchemeChk == '3'" type="link" @click="addProblem('isSchemeChk')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="17.是否对各项应急预案进行审查">
            <a-radio-group v-model:value="formObj.isPlanChk">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isPlanChk == '2' || formObj.isPlanChk == '3'"
                type="link"
                @click="addProblem('isPlanChk')">
                <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="65"
        :villType="65"
        :objId="currentObjectId"
        :objName="currentObjectName"
        :problemMiddleType="'重点水利工程'"
        :problData="probId"
        @closeDialog="closePlDialog"
        :currentObjectRgstrId="currentObjectRgstrId"></problem-dialog>
    </a-layout>
  </div>
</template>

<script>
import { getRgstridKeyjxStn } 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() {
    return {
      id: '',
      objtbStatu: {
        stnState: '',
        rgstrId: '',
        id: '',
        state: '',
      },
      type: '',
      formObj: {},
      dialogFormVisible: false,
      formLabelWidth: '300px',
      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: {
    getRgstridObj() {
      getRgstridKeyjxStn(this.currentObjectRgstrId).then((res) => {
        if (res.data && Object.keys(res.data).length) {
          this.formObj = res.data;
          this.operationType1 = 'update';
          this.id = res.data.id;
        } else {
          this.formObj = {};
          this.operationType1 = 'add';
        }
      });
    },
    addHandler() {
      this.formObj['rgstrId'] = this.currentObjectRgstrId;
      this.formObj['recPersId'] = this.recPersId;
      this.objtbStatu.rgstrId = this.currentObjectRgstrId;
      this.objtbStatu.id = this.currentObjectRgstrId;

      if (
        this.formObj.isInDuty != null &&
        this.formObj.isChgApp != null &&
        this.formObj.isMkPlan != null &&
        this.formObj.isDezCnf != null &&
        this.formObj.isRptCnf != null &&
        this.formObj.isWorkDuty != null &&
        this.formObj.isSchemeApp != null &&
        this.formObj.isMon != null &&
        this.formObj.isChk != null &&
        this.formObj.isProgressIn != null &&
        this.formObj.isQualityIn != null &&
        this.formObj.isBudScheme != null &&
        this.formObj.isSafChk != null &&
        this.formObj.isSafMeet != null &&
        this.formObj.isSafTec != null &&
        this.formObj.isSchemeChk != null &&
        this.formObj.isPlanChk != null
      ) {
        this.formObj['state'] = '2';
        this.objtbStatu.stnState = '2';
        this.objtbStatu.state = '1';
      } else if (
        this.formObj.isInDuty == null &&
        this.formObj.isChgApp == null &&
        this.formObj.isMkPlan == null &&
        this.formObj.isDezCnf == null &&
        this.formObj.isRptCnf == null &&
        this.formObj.isWorkDuty == null &&
        this.formObj.isSchemeApp == null &&
        this.formObj.isMon == null &&
        this.formObj.isChk == null &&
        this.formObj.isProgressIn == null &&
        this.formObj.isQualityIn == null &&
        this.formObj.isBudScheme == null &&
        this.formObj.isSafChk == null &&
        this.formObj.isSafMeet == null &&
        this.formObj.isSafTec == null &&
        this.formObj.isSchemeChk == null &&
        this.formObj.isPlanChk == null
      ) {
        this.objtbStatu.stnState = '0';
        this.formObj['state'] = '0';
      } else {
        this.objtbStatu.stnState = '1';
        this.objtbStatu.state = '1';
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存监理单位填报信息吗？',
        okType: 'warning',
        onOk: () => {
          try {
            request.post('/bis/insp/keyjx/stn', this.formObj).then((res) => {
              if (res.success) {
                this.$message.success('修改成功');
                request
                  .post('/bis/insp/keyjx/update', this.objtbStatu)
                  .then((res) => {
                    res;
                  });
                this.$emit('addShuiKuSuccess');
              }
            });
          } catch (e) {}
        },
      });
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_KEYJX_STN',
      };
      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;
    },
    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>
