<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.isEntReq">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isEntReq == '2'" type="link" @click="addProblem('isEntReq')">
                <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.isTelReq">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isTelReq == '2'" type="link" @click="addProblem('isTelReq')">
                <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="3.项目法人组建是否经政府或其授权部门批准">
            <a-radio-group v-model:value="formObj.isEntApp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
            <a-button v-if="formObj.isEntApp == '2'" type="link" @click="addProblem('isEntApp')">
              <a-icon type="plus-circle" theme="filled" />
            </a-button>
          </a-form-item>
          <a-form-item label="4.项目法人是否组建了现场管理机构">
            <a-radio-group v-model:value="formObj.isEntMgr">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isEntMgr == '2'" type="link" @click="addProblem('isEntMgr')">
                <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.isIntDep">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isIntDep == '2' || formObj.isIntDep =='3'"
                type="link"
                @click="addProblem('isIntDep')">
                <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.isIntTel">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isIntTel == '2' || formObj.isIntTel =='3'"
                type="link"
                @click="addProblem('isIntTel')">
                <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.isIntPay">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isIntPay == '2' || formObj.isIntPay == '3'" type="link" @click="addProblem('isIntPay')">
                <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.isIntDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isIntDuty == '2'" type="link" @click="addProblem('isIntDuty')">
                <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.isBudPlan">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBudPlan == '2'" type="link" @click="addProblem('isBudPlan')">
                <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="10.是否组织完成了设计交底工作">
            <a-radio-group v-model:value="formObj.isBudDsg">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isBudDsg == '2'"
                type="link"
                @click="addProblem('isBudDsg')">
                <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.isMgrDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isMgrDuty == '2' || formObj.isMgrDuty == '3'"
                type="link"
                @click="addProblem('isMgrDuty')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="12.是否履行了对参建各方的监督检查职责">
            <a-radio-group v-model:value="formObj.isBudChk">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBudChk == '2' || formObj.isBudChk =='3'" type="link" @click="addProblem('isBudChk')">
                <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.isExpDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isExpDuty == '2'"
                type="link"
                @click="addProblem('isExpDuty')">
                <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.isPayDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isPayDuty == '2' || formObj.isPayDuty =='3'"
                type="link"
                @click="addProblem('isPayDuty')">
                <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.isMeet">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isMeet == '2'"
                type="link"
                @click="addProblem('isMeet')">
                <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.isAffect">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isAffect == '2' || formObj.isAffect == '3'"
                type="link"
                @click="addProblem('isAffect')">
                <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.isPay">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isPay == '2' || formObj.isPay == '3'"
                type="link"
                @click="addProblem('isPay')">
                <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 { getRgstridHystjxPres } 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: {
        presState: '',
        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() {
      getRgstridHystjxPres(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.isEntReq != null &&
        this.formObj.isTelReq != null &&
        this.formObj.isEntApp != null &&
        this.formObj.isEntMgr != null &&
        this.formObj.isIntDep != null &&
        this.formObj.isIntTel != null &&
        this.formObj.isIntPay != null &&
        this.formObj.isIntDuty != null &&
        this.formObj.isBudPlan != null &&
        this.formObj.isBudDsg != null &&
        this.formObj.isMgrDuty != null &&
        this.formObj.isBudChk != null &&
        this.formObj.isExpDuty != null &&
        this.formObj.isPayDuty != null &&
        this.formObj.isMeet != null &&
        this.formObj.isAffect != null &&
        this.formObj.isPay != null
      ) {
        this.formObj['state'] = '2';
        this.objtbStatu.presState = '2';
        this.objtbStatu.state = '1';
      } else if (
        this.formObj.isEntReq == null &&
        this.formObj.isTelReq == null &&
        this.formObj.isEntApp == null &&
        this.formObj.isEntMgr == null &&
        this.formObj.isIntDep == null &&
        this.formObj.isIntTel == null &&
        this.formObj.isIntPay == null &&
        this.formObj.isIntDuty == null &&
        this.formObj.isBudPlan == null &&
        this.formObj.isBudDsg == null &&
        this.formObj.isMgrDuty == null &&
        this.formObj.isBudChk == null &&
        this.formObj.isExpDuty == null &&
        this.formObj.isPayDuty == null &&
        this.formObj.isMeet == null &&
        this.formObj.isAffect == null &&
        this.formObj.isPay == null
      ) {
        this.objtbStatu.presState = '0';
        this.formObj['state'] = '0';
      } else {
        this.objtbStatu.presState = '1';
        this.objtbStatu.state = '1';
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存监理单位填报信息吗？',
        okType: 'warning',
        onOk: () => {
          try {
            request.post('/bis/insp/keyjx/pres', 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_PRES',
      };
      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>
