<template>
  <div id="">
    <a-layout>
      <a-layout-content style="border:1px solid #d5d5ff;margin-left:5px;padding:0px;">
        <p style="font-weight:bolder;background-color:#d5d5ff;padding:3px;">信息填报</p>
        <a-form
          :model="addObj"
          :label-col="{ span: 10 }"
          :wrapper-col="{ span: 14 }"
          :rules="diRongYangMaoRules"
          ref="addObj">
          <a-form-item label="是否设置公告宣传类标识标牌">
            <a-radio-group v-model:value="addObj.isPubLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置工程简介牌" v-if="addObj.isPubLogo === '2'">
            <a-radio-group v-model:value="addObj.isPrjtLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="addObj.isPrjtLogo == '2'"
                type="link"
                @click="addProblem('isPrjtLogo', addObj.isPrjtLogo)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置工程建设永久性责任牌" v-if="addObj.isPubLogo === '2'">
            <a-radio-group v-model:value="addObj.isDutyLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="addObj.isDutyLogo == '2'"
                type="link"
                @click="addProblem('isDutyLogo', addObj.isDutyLogo)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置运行管理责任人牌" v-if="addObj.isPubLogo === '2'">
            <a-radio-group v-model:value="addObj.isRunLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button
                v-if="addObj.isRunLogo == '2'"
                type="link"
                @click="addProblem('isRunLogo', addObj.isRunLogo)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置界桩" v-if="addObj.isPubLogo === '2'">
            <a-radio-group v-model:value="addObj.isSetLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetLogo == '2'" type="link" @click="addProblem('isSetLogo', addObj.isSetLogo)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置公告牌" v-if="addObj.isPubLogo === '2'">
            <a-radio-group v-model:value="addObj.isPubpLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isPubpLogo == '2'" type="link" @click="addProblem('isPubpLogo', addObj.isPubpLogo)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>

          <a-form-item label="是否设置名称类标识标牌">
            <a-radio-group v-model:value="addObj.isPubnLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置堤段序号牌" v-if="addObj.isPubnLogo === '2'">
            <a-radio-group v-model:value="addObj.isNoLogo">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isNoLogo == '2'" type="link" @click="addProblem('isNoLogo', addObj.isNoLogo)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置监测设施名称牌" v-if="addObj.isPubnLogo === '2'">
            <a-radio-group v-model:value="addObj.isSetName">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetName == '2'" type="link" @click="addProblem('isSetName', addObj.isSetName)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置设备管理责任牌" v-if="addObj.isPubnLogo === '2'">
            <a-radio-group v-model:value="addObj.isSetDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetDuty == '2'" type="link" @click="addProblem('isSetDuty', addObj.isSetDuty)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>

          <a-form-item label="是否设置警示类标识标牌">
            <a-radio-group v-model:value="addObj.isSetCaut">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置禁止标牌（识）" v-if="addObj.isSetCaut === '2'">
            <a-radio-group v-model:value="addObj.isSetBan">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetBan == '2'" type="link" @click="addProblem('isSetBan', addObj.isSetBan)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置警告标牌（识）" v-if="addObj.isSetCaut === '2'">
            <a-radio-group v-model:value="addObj.isSetWarn">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetWarn == '2'" type="link" @click="addProblem('isSetWarn', addObj.isSetWarn)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置指令标志" v-if="addObj.isSetCaut === '2'">
            <a-radio-group v-model:value="addObj.isSetCmd">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetCmd == '2'" type="link" @click="addProblem('isSetCmd', addObj.isSetCmd)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置提示标志" v-if="addObj.isSetCaut === '2'">
            <a-radio-group v-model:value="addObj.isSetHint">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetHint == '2'" type="link" @click="addProblem('isSetHint', addObj.isSetHint)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>

          <a-form-item label="是否设置警示类标识标牌">
            <a-radio-group v-model:value="addObj.isSetLead">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置巡查路线导向牌" v-if="addObj.isSetLead === '2'">
            <a-radio-group v-model:value="addObj.isSetRout">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetRout == '2'" type="link" @click="addProblem('isSetRout', addObj.isSetRout)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置巡查路线指引牌" v-if="addObj.isSetLead === '2'">
            <a-radio-group v-model:value="addObj.isSetCrout">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetCrout == '2'" type="link" @click="addProblem('isSetCrout', addObj.isSetCrout)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="是否设置交通指引牌" v-if="addObj.isSetLead === '2'">
            <a-radio-group v-model:value="addObj.isSetTra">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetTra == '2'" type="link" @click="addProblem('isSetTra', addObj.isSetTra)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>

          <a-form-item label="是否设置险工险段标识牌">
            <a-radio-group v-model:value="addObj.isSetRisk">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isSetRisk == '2'" type="link" @click="addProblem('isSetRisk', addObj.isSetRisk)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="险工险段标识牌是否标明管护主体" v-if="addObj.isSetRisk ==='1'">
            <a-radio-group v-model:value="addObj.isMakRun">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isMakRun == '2'" type="link" @click="addProblem('isMakRun', addObj.isMakRun)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="险工险段标识牌是否标明行政责任人" v-if="addObj.isSetRisk ==='1'">
            <a-radio-group v-model:value="addObj.isMakDuty">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isMakDuty == '2'" type="link" @click="addProblem('isMakDuty', addObj.isMakDuty)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="险工险段标识牌是否标明管理责任人" v-if="addObj.isSetRisk ==='1'">
            <a-radio-group v-model:value="addObj.isMakMan">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isMakMan == '2'" type="link" @click="addProblem('isMakMan', addObj.isMakMan)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="险工险段标识牌是否标明技术责任人" v-if="addObj.isSetRisk ==='1'">
            <a-radio-group v-model:value="addObj.isMakTch">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isMakTch == '2'" type="link" @click="addProblem('isMakTch', addObj.isMakTch)">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-radio-group>
          </a-form-item>
          <a-form-item label="险工险段标识牌是否标明巡查责任人" v-if="addObj.isSetRisk ==='1'">
            <a-radio-group v-model:value="addObj.isMakRout">
              <a-radio value="1">是</a-radio>
              <a-radio value="2">否</a-radio>
              <a-button v-if="addObj.isMakRout == '2'" type="link" @click="addProblem('isMakRout', addObj.isMakRout)">
                <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"
        :objType="58"
        :villType="58"
        :objId="rowData.objId"
        :objName="rowData.nm"
        :problemMiddleType="'堤防'"
        :problData="probId"
        @closeDialog="closePlDialog"
        :rgstrId="rowData.rgstrId"
        :szRuls="[]">
      </problem-dialog>
    </a-layout>
  </div>
</template>

<script>
import request from '../../../utils/gw_ajax_request';
import problemDialog from '../../duChaWenTi/problemDialog.vue';
export default {
  props: {
    rowData: {
      type: Object,
      default: {},
    },
    openType: {
      type: Boolean,
      default: true,
    },
  },
  components: {
    problemDialog,
  },
  data() {
    return {
      formLabelWidth: '530px',
      diRongYangMaoRules: {},
      probId: '',
      operationType1: '',
      id: '',
      rsvrRules: null,
      showAddProblemDialog: false,
      addObj: {
        isPubLogo: '',
        isPrjtLogo: '',
        isDutyLogo: '',
        isRunLogo: '',
        isSetLogo: '',
        isPubpLogo: '',
        isPubnLogo: '',
        isNoLogo: '',
        isSetName: '',
        isSetDuty: '',
        isSetCaut: '',
        isSetBan: '',
        isSetWarn: '',
        isSetCmd: '',
        isSetHint: '',
        isSetLead: '',
        isSetRout: '',
        isSetCrout: '',
        isSetTra: '',
        isSetRisk: '',
        isMakRun: '',
        isMakDuty: '',
        isMakMan: '',
        isMakTch: '',
        isMakRout: '',
      },
      objtbStatu: {
        jxqState: '',
        rgstrId: '',
        id: '',
        state: '',
      },
    };
  },
  computed: {
    // 监听属性 类似于data概念
    recPersId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '';
    },
  },
  created() {
    this.findItemByType();
  },
  mounted() {
    if (this.rowData.rgstrId) {
      this.getInfoData();
    }
  },
  methods: {
    makesure(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.addObj['rgstrId'] = this.rowData.rgstrId;
          this.addObj['recPersId'] = this.recPersId;
          this.objtbStatu.rgstrId = this.rowData.rgstrId;
          this.objtbStatu.id = this.rowData.rgstrId;
          if (
            this.addObj.isPubLogo != null &&
            this.addObj.isPubnLogo != null &&
            this.addObj.isSetCaut != null &&
            this.addObj.isSetLead != null &&
            this.addObj.isSetRisk != null
          ) {
            this.addObj['state'] = '2';
            this.objtbStatu.logoState = '2';
            this.objtbStatu.state = '1';
          } else if (
            this.addObj.isPubLogo == null &&
            this.addObj.isPubnLogo == null &&
            this.addObj.isSetCaut == null &&
            this.addObj.isSetLead == null &&
            this.addObj.isSetRisk == null
          ) {
            this.objtbStatu.logoState = '0';
            this.addObj['state'] = '0';
          } else {
            this.objtbStatu.logoState = '1';
            this.objtbStatu.state = '1';
            this.addObj['state'] = '1';
          }

          this.$confirm({
            title: '提示',
            content: '确认保存运行管理情况信息吗？',
            okType: 'warning',
            onOk: () => {
              request.post('/bis/insp/dikejx/logo', this.addObj).then((res) => {
                if (res.success) {
                  this.$message.success('添加成功');
                  request
                    .post('/bis/insp/dikejx/update', this.objtbStatu)
                    .then((res) => {
                      res;
                    });
                  this.$emit('addDiFangSuccess');
                }
              });
            },
          });
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 如果已经填报  则查询
    getInfoData() {
      request
        .get('/bis/insp/dikejx/logo/' + this.rowData.rgstrId, {})
        .then((res) => {
          if (res.success) {
            this.addObj = res.data;
          }
          if (res.data && Object.keys(res.data).length) {
            this.addObj = res.data;
            this.operationType1 = 'update';
            this.id = res.data.id;
          } else {
            this.addObj = {};
            this.operationType1 = 'add';
          }
        });
    },
    addProblem(item, iValue) {
      const rest = this.rsvrRules.filter((e) => {
        return e.iValue === iValue && e.eName === item;
      });
      if (rest[0]) {
        this.probId = rest[0].id;
      }
      this.showAddProblemDialog = true;
    },
    closePlDialog(val) {
      this.showAddProblemDialog = false;
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_DIKEJX_LOGO',
      };
      request
        .post('/bis/insp/item/ques/info/findItemByType', obj)
        .then((res) => {
          this.rsvrRules = res.data;
        });
    },
  },
};
</script>

<style lang='less' scoped>

</style>
