<template>
  <div id="">
    <a-modal :title="gsgcRowData.cwsName" :open="dialogFormVisible" @cancel="closeTianBaoDialog" :footer="null" width="70%">
      <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="用水户姓名">
              <a-input type="text" v-model:value="formObj.cwsName" class="w200" allow-clear placeholder="请输入用水户姓名"></a-input>
            </a-form-item>
            <a-form-item label="饮水工程运行管理责任人">
              <a-input type="text" v-model:value="formObj.prjDutyPers" class="w200" allow-clear placeholder="请输入饮水工程运行管理责任人">
              </a-input>
            </a-form-item>
            <a-form-item label="联系方式">
              <a-input type="text" v-model:value="formObj.usrTel" class="w200" allow-clear placeholder="请输入联系方式"></a-input>
            </a-form-item>
            <a-form-item label="家庭住址">
              <a-input type="text" v-model:value="formObj.usrLoc" class="w200" allow-clear placeholder="请输入家庭住址"></a-input>
            </a-form-item>
            <a-form-item label="饮水方式">
              <a-select v-model:value="uswtType" placeholder="请选择" allow-clear class="w200">
                <a-select-option value="1">集中式</a-select-option>
                <a-select-option value="2">分散式-压水井</a-select-option>
                <a-select-option value="3">分散式-山泉水</a-select-option>
                <a-select-option value="4">其他</a-select-option>
              </a-select>
            </a-form-item>
            <a-form-item label="其他" v-if="formObj.uswtType == '4'">
              <a-input type="text" v-model:value="formObj.othrNote" class="w200" allow-clear placeholder="请输入其他饮水方式">
              </a-input>
            </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="是否制定水价">
              <a-radio-group v-model:value="formObj.isMakCost">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isMakCost == '2'" type="link" @click="addProblem('isMakCost')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="是否收取水费">
              <a-radio-group v-model:value="formObj.isCollCost">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isCollCost == '2'" type="link" @click="addProblem('isCollCost')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="是否安装计量设施并计量收费">
              <a-radio-group v-model:value="formObj.isBuldSure">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isBuldSure == '2'" type="link" @click="addProblem('isBuldSure')">
                <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="是否按要求制定应急供水预案">
              <a-radio-group v-model:value="formObj.isBuldPlan">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isBuldPlan == '2'" type="link" @click="addProblem('isBuldPlan')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="工程运行管理人员是否熟悉应急供水预案情况">
              <a-radio-group v-model:value="formObj.isKnowPlan">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isKnowPlan == '2'" type="link" @click="addProblem('isKnowPlan')">
                <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="万人工程是否具备水质化验室，是否配备水质检测实施设备">
              <a-radio-group v-model:value="formObj.isDutyChk">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isDutyChk == '2'" type="link" @click="addProblem('isDutyChk')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="万人工程是否进行水质日检，有无自检记录">
              <a-radio-group v-model:value="formObj.isDayChk">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isDayChk == '2'" type="link" @click="addProblem('isDayChk')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="是否具备水质净化设备，且正常运行">
              <a-radio-group v-model:value="formObj.isClnRun">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isClnRun == '2'" type="link" @click="addProblem('isClnRun')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="是否具备水质消毒设备，且正常运行">
              <a-radio-group v-model:value="formObj.isStrlRun">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isStrlRun == '2'" type="link" @click="addProblem('isStrlRun')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="关键岗位是否存在相应的制度上墙或口袋书或汇编材料。关键岗位包括：水工艺技术管理、机电设备管理、制水净化、制水消毒、安全生产、水质检测等。">
              <a-radio-group v-model:value="formObj.isMakSys">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
            </a-form-item>
            <a-form-item label="水工艺技术管理岗位是否没有相应的制度上墙或口袋书或汇编材料。" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isWttmManu">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isWttmManu == '2'" type="link" @click="addProblem('isWttmManu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="水质检测管理岗位是否没有相应的制度上墙或口袋书或汇编材料" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isWqdtmManu">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isWqdtmManu == '2'" type="link" @click="addProblem('isWqdtmManu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="机电设备管理岗位是否没有相应的制度上墙或口袋书或汇编材料" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isEetmManu">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isEetmManu == '2'" type="link" @click="addProblem('isEetmManu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="制水净化管理岗位是否没有相应的制度上墙或口袋书或汇编材料" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isWptmManu">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isWptmManu == '2'" type="link" @click="addProblem('isWptmManu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="制水消毒管理岗位是否没有相应的制度上墙或口袋书或汇编材料" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isWdtmManu">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isWdtmManu == '2'" type="link" @click="addProblem('isWdtmManu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="安全生产管理岗位是否没有相应的制度上墙或口袋书或汇编材料" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isSptmManu">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isSptmManu == '2'" type="link" @click="addProblem('isSptmManu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="其他关键管理岗位是否没有相应的制度上墙或口袋书或汇编材料" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isOktmManu">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isOktmManu == '2'" type="link" @click="addProblem('isOktmManu')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="工程建（构）筑物范围内是否无明显杂草、杂物、垃圾，不影响巡查及正常运行" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isWaste">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isWaste == '2'" type="link" @click="addProblem('isWaste')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </a-form-item>
            <a-form-item label="净化、消毒、水质检测的药品、设备是否规范存放、管理、使用" v-if="formObj.isMakSys=='2'">
              <a-radio-group v-model:value="formObj.isEqNusr">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
              <a-button v-if="formObj.isEqNusr == '2'" type="link" @click="addProblem('isEqNusr')">
                <a-icon type="plus-circle" theme="filled" />
              </a-button>
            </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="88"
          :villType="88"
          :objId="currentObjectId"
          :objName="currentObjectName"
          :curNm="gsgcRowData.cwsName"
          :curId="gsgcRowData.id"
          curType="1"
          :problemMiddleType="'农村饮水安全'"
          :problData="probId"
          @closeDialog="closePlDialog"
          :currentObjectRgstrId="currentObjectRgstrId"></problem-dialog>
      </a-layout>
    </a-modal>
  </div>
</template>

<script>
import request from '../../../utils/gw_ajax_request';
import inputWith from '../../../widgets/inuptWith.vue';
import problemDialog from '../../duChaWenTi/problemDialog.vue';

export default {
  components: {
    inputWith: inputWith,
    problemDialog: problemDialog,
  },
  props: [
    'rowData',
    'currentObjectId',
    'currentObjectName',
    'currentObjectRgstrId',
    'gsgcRowData',
    'oriFatherName',
    'villageNm',
    'openType',
  ],
  data() {
    return {
      xx: '',
      xx: '',
      objtbStatu: {
        presStat: '',
        rgstrId: '',
      },
      rules: {},
      formObj: {
        cwsCode: '',
        cwsName: '',
        cwsLoc: '',
        desWasuScal: '',
        isMakCost: '',
        isCollCost: '',
        isBuldSure: '',
        isBuldPlan: '',
        isKnowPlan: '',
        isDutyChk: '',
        isDayChk: '',
        isClnRun: '',
        isStrlRun: '',
        isMakSys: '',
        isWaste: '',
        isEqNusr: '',
        isWttmManu: '',
        isWqdtmManu: '',
        isEetmManu: '',
        isWptmManu: '',
        isWdtmManu: '',
        isSptmManu: '',
        isOktmManu: '',
      },
      dialogFormVisible: true,
      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: {},
  methods: {
    formatDate(val) {
      if (val == null || val == '') {
        return '';
      } else {
        var d = new Date(val);
        return d.getFullYear + '-' + (d.getMonth() + 1) + '-' + d.getDate();
      }
    },
    getRgstridObj() {
      request
        .get(`/bis/insp/villjx/prjct/${this.gsgcRowData.id}`)
        .then((res) => {
          if (res.data) {
            this.formObj = res.data;
            this.initDefault();
          }
        });
    },
    initDefault() {
      for (var k in this.formObj) {
        if (k.indexOf('is') > -1) {
          if (this.formObj[k] == null) {
            this.formObj[k] = '1';
          }
        }
      }
    },
    addHandler() {
      this.formObj['rgstrId'] = this.rowData.rgstrId;
      this.formObj['recPersId'] = this.recPersId;
      this.$confirm({
        title: '提示',
        content: '确认保存脱贫户情况信息？',
        okType: 'warning',
        onOk: () => {
          try {
            request.post('/bis/insp/villjx/prjct', this.formObj).then((res) => {
              if (res.success) {
                this.$message.success('添加成功');
              }
            });
          } catch (e) {}
        },
      });
    },
    cancelHandler() {
      this.$emit('cancelHandler');
    },
    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;
      }
    },
    findItemByType() {
      const obj = {
        tname: 'BIS_INSP_VILLJX_PRJCT',
      };
      request
        .post('/bis/insp/item/ques/info/findItemByType', obj)
        .then((res) => {
          this.rsvrRules = res.data;
        });
    },
    closeTianBaoDialog() {
      this.$emit('closeDialog');
    },
    getdialogFormVisible(val) {
      this.showProblemList = 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>
