<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.isPmpIn">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPmpIn == '2'" type="link" @click="addProblem('isPmpIn')">
                <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.isTelIn">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isTelIn == '2'" type="link" @click="addProblem('isTelIn')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="3.安全员是否到岗到位">
            <a-radio-group v-model:value="formObj.isSafIn">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
            <a-button v-if="formObj.isSafIn == '2'" type="link" @click="addProblem('isSafIn')">
              <a-icon type="plus-circle" theme="filled" />
            </a-button>
          </a-form-item>
          <a-form-item label="4.人员变更是否履行手续">
            <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>
          <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="5.项目经理是否对项目进行实质管理">
            <a-radio-group v-model:value="formObj.isPmMgr">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPmMgr == '2'" type="link" @click="addProblem('isPmMgr')">
                <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.isBulQul">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBulQul == '2'" type="link" @click="addProblem('isBulQul')">
                <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.isPresQul">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPresQul == '2'" type="link" @click="addProblem('isPresQul')">
                <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.isPrfQul">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPrfQul == '2'" type="link" @click="addProblem('isPrfQul')">
                <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.isPresDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPresDuty == '2'" type="link" @click="addProblem('isPresDuty')">
                <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.isBudMgr">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBudMgr == '2'" type="link" @click="addProblem('isBudMgr')">
                <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.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>
          <a-form-item label="12.是否配备专职安全员">
            <a-radio-group v-model:value="formObj.isBudPers">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isBudPers == '2'" type="link" @click="addProblem('isBudPers')">
                <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.isSafPersDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSafPersDuty == '2'" type="link" @click="addProblem('isSafPersDuty')">
                <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="14.工程总体进度是否满足合同要求">
            <a-radio-group v-model:value="formObj.isPlanPact">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanPact == '2'" type="link" @click="addProblem('isPlanPact')">
                <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.isPlanReq">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPlanReq == '2'" type="link" @click="addProblem('isPlanReq')">
                <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.isActPlan">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isActPlan == '2'" type="link" @click="addProblem('isActPlan')">
                <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="17.建筑物结构尺寸是否符合要求">
            <a-radio-group v-model:value="formObj.isSizeReq">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSizeReq == '2' || formObj.isSizeReq =='3'" type="link" @click="addProblem('isSizeReq')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="18.原材料是否有检测">
            <a-radio-group v-model:value="formObj.isChkFpr">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChkFpr == '2' || formObj.isChkFpr =='3'" type="link" @click="addProblem('isChkFpr')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="19.中间产品是否有检测">
            <a-radio-group v-model:value="formObj.isChkMdl">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChkMdl == '2' || formObj.isChkMdl =='3'" type="link" @click="addProblem('isChkMdl')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="20.工程支付报表是否附具合格工程量资料证明">
            <a-radio-group v-model:value="formObj.isRptProve">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isRptProve == '2' || formObj.isRptProve =='3'" type="link" @click="addProblem('isRptProve')">
                <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="21.总承包方是否配置劳资专管员">
            <a-radio-group v-model:value="formObj.isDplResp">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDplResp == '2'" type="link" @click="addProblem('isDplResp')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="22.劳资专管员是否履职到位">
            <a-radio-group v-model:value="formObj.isRespDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isRespDuty == '2'" type="link" @click="addProblem('isRespDuty')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="23.是否编制工资支付台账">
            <a-radio-group v-model:value="formObj.isMkPay">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isMkPay == '2' || formObj.isMkPay =='3'" type="link" @click="addProblem('isMkPay')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="24.工资支付表是否经农民本人签字确认">
            <a-radio-group v-model:value="formObj.isPersSgn">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPersSgn == '2'" type="link" @click="addProblem('isPersSgn')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="25.现场是否设立维权告示牌">
            <a-radio-group v-model:value="formObj.isSetBul">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSetBul == '2'" type="link" @click="addProblem('isSetBul')">
                <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="26.五牌一图是否设立">
            <a-radio-group v-model:value="formObj.isSetPag">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isSetPag == '2' || formObj.isSetPag =='3'" type="link" @click="addProblem('isSetPag')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="27.材料设备摆（堆）放是否符合要求">
            <a-radio-group v-model:value="formObj.isStackReq">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isStackReq == '2' || formObj.isStackReq =='3'" type="link" @click="addProblem('isStackReq')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="28.施工现场安全警示标识是否到位">
            <a-radio-group v-model:value="formObj.isWarnId">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isWarnId == '2' || formObj.isWarnId =='3'" type="link" @click="addProblem('isWarnId')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="29.用电是否规范">
            <a-radio-group v-model:value="formObj.isPow">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isPow == '2' || formObj.isPow =='3'" type="link" @click="addProblem('isPow')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="30.施工现场是否有降噪措施">
            <a-radio-group v-model:value="formObj.isChirpMsu">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isChirpMsu == '2' || formObj.isChirpMsu =='3'" type="link" @click="addProblem('isChirpMsu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="31.施工现场是否有防尘措施">
            <a-radio-group v-model:value="formObj.isDustMsu">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="formObj.isDustMsu == '2' || formObj.isDustMsu =='3'"
                type="link"
                @click="addProblem('isDustMsu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="32.施工人员是否按规定佩戴安全帽等防护用具">
            <a-radio-group v-model:value="formObj.isDess">
              <a-radio value="1">是</a-radio>
              <a-radio value="3">部分</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="formObj.isDess == '2' || formObj.isDess =='3'" type="link" @click="addProblem('isDess')">
                <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 { getRgstridHystjxBuld } 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: {
        buldState: '',
        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() {
      getRgstridHystjxBuld(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.isPmpIn != null &&
        this.formObj.isTelIn != null &&
        this.formObj.isSafIn != null &&
        this.formObj.isChgPlan != null &&
        this.formObj.isPmMgr != null &&
        this.formObj.isBulQul != null &&
        this.formObj.isPresQul != null &&
        this.formObj.isPrfQul != null &&
        this.formObj.isPresDuty != null &&
        this.formObj.isBudMgr != null &&
        this.formObj.isBudPlan != null &&
        this.formObj.isBudPers != null &&
        this.formObj.isSafPersDuty != null &&
        this.formObj.isPlanPact != null &&
        this.formObj.isPlanReq != null &&
        this.formObj.isActPlan != null &&
        this.formObj.isSizeReq != null &&
        this.formObj.isChkFpr != null &&
        this.formObj.isChkMdl != null &&
        this.formObj.isRptProve != null &&
        this.formObj.isDplResp != null &&
        this.formObj.isRespDuty != null &&
        this.formObj.isMkPay != null &&
        this.formObj.isPersSgn != null &&
        this.formObj.isSetBul != null &&
        this.formObj.isSetPag != null &&
        this.formObj.isStackReq != null &&
        this.formObj.isWarnId != null &&
        this.formObj.isPow != null &&
        this.formObj.isChirpMsu != null &&
        this.formObj.isDustMsu != null &&
        this.formObj.isDess != null
      ) {
        this.formObj['state'] = '2';
        this.objtbStatu.buldState = '2';
        this.objtbStatu.state = '1';
      } else if (
        this.formObj.isPmpIn == null &&
        this.formObj.isTelIn == null &&
        this.formObj.isSafIn == null &&
        this.formObj.isChgPlan == null &&
        this.formObj.isPmMgr == null &&
        this.formObj.isBulQul == null &&
        this.formObj.isPresQul == null &&
        this.formObj.isPrfQul == null &&
        this.formObj.isPresDuty == null &&
        this.formObj.isBudMgr == null &&
        this.formObj.isBudPlan == null &&
        this.formObj.isBudPers == null &&
        this.formObj.isSafPersDuty == null &&
        this.formObj.isPlanPact == null &&
        this.formObj.isPlanReq == null &&
        this.formObj.isActPlan == null &&
        this.formObj.isSizeReq == null &&
        this.formObj.isChkFpr == null &&
        this.formObj.isChkMdl == null &&
        this.formObj.isRptProve == null &&
        this.formObj.isDplResp == null &&
        this.formObj.isRespDuty == null &&
        this.formObj.isMkPay == null &&
        this.formObj.isPersSgn == null &&
        this.formObj.isSetBul == null &&
        this.formObj.isSetPag == null &&
        this.formObj.isStackReq == null &&
        this.formObj.isWarnId == null &&
        this.formObj.isPow == null &&
        this.formObj.isChirpMsu == null &&
        this.formObj.isDustMsu == null &&
        this.formObj.isDess == null
      ) {
        this.objtbStatu.buldState = '0';
        this.formObj['state'] = '0';
      } else {
        this.objtbStatu.buldState = '1';
        this.objtbStatu.state = '1';
        this.formObj['state'] = '1';
      }
      this.$confirm({
        title: '提示',
        content: '确认保存施工单位填报信息吗？',
        okType: 'warning',
        onOk: () => {
          try {
            request.post('/bis/insp/keyjx/buld', 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_BULD',
      };
      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>
