<template>
  <div id="">
    <a-modal :title="yshRowData.usrName" :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.usrName" 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="formObj.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.isSafTable">
                <a-radio value="1">是</a-radio>
                <a-radio value="2">否</a-radio>
              </a-radio-group>
            </a-form-item>
            <a-form-item label="水量可满足每人每天的生活用水量">
              <a-radio-group v-model:value="formObj.isUsrEnugh">
                <a-radio value="1">达标</a-radio>
                <a-radio value="2">基本达标</a-radio>
                <a-radio value="3">不达标</a-radio>
                <a-tooltip placement="topLeft" class="item" style="padding-left: 10px;">
                  <template slot="title">
                    <p><span>水量</span></p>
                    <p><span>达标：W≥60L/天·人</span></p>
                    <p><span>基本达标：35L/天·人≤W＜60L/天·人</span></p>
                    <p><span>不达标：W＜35L/天·人</span></p>
                    <p><span><br></span></p>
                  </template>
                  <a-icon type="message" />
                </a-tooltip>
              </a-radio-group>
            </a-form-item>
            <a-form-item label="饮用水水质符合有关标准">
              <a-radio-group v-model:value="formObj.isRoleUsr">
                <a-radio value="1">达标</a-radio>
                <a-radio value="2">基本达标</a-radio>
                <a-radio value="3">不达标</a-radio>
                <a-tooltip placement="topLeft" class="item" style="padding-left: 10px;">
                  <template slot="title">
                    <p><span>水质</span></p>
                    <p><span>达标：1.千吨万人供水工程，依据工程运行期出厂水或末梢水水质检测报告，水质检测结果符合GB5749的规定；</span></p>
                    <p><span>2.千吨万人以下集中式供水工程，依据工程出厂水水质检测报告或现场检测，水质检测结果符合GB5749中的农村供水水质宽限规定；</span></p>
                    <p><span>3.分散式供水工程，水质检测结果符合GB5749中的农村供水水质宽限规定。</span></p>
                    <p><span>基本达标：分散式供水工程的用水户，可采用“望、闻、问、尝”等简便适宜方法进行现场评价，饮用水中无肉眼可见杂质、无异色异味、用水户长期饮用无不良反应可评价为基本达标</span></p>
                    <p><span>不达标：不符合前述标准</span></p>
                  </template>
                  <a-icon type="message" />
                </a-tooltip>
              </a-radio-group>
            </a-form-item>
            <a-form-item label="用水户获得饮用水便利">
              <a-radio-group v-model:value="formObj.isEasyUsr">
                <a-radio value="1">达标</a-radio>
                <a-radio value="2">基本达标</a-radio>
                <a-radio value="3">不达标</a-radio>
                <a-tooltip placement="topLeft" class="item" style="padding-left: 10px;">
                  <template slot="title">
                    <p><span>用水方便程度</span></p>
                    <p><span>达标：集中式：已供水入户（含具备入户条件但因个人意愿未入户的）；分散式：人力取水往返时间不超过10分钟，或取水水平距离不超过400米、垂直距离不超过40米。</span></p>
                    <p><span>基本达标：人力取水往返时间不超过20分钟，或取水水平距离不超过800米、垂直距离不超过80米</span></p>
                    <p><span>不达标：不符合前述标准的</span></p>
                  </template>
                  <a-icon type="message" />
                </a-tooltip>
              </a-radio-group>
            </a-form-item>
            <a-form-item label="一年中实际供水量符合标准的天数与一年总天数的比值">
              <a-radio-group v-model:value="formObj.isConform">
                <a-radio value="1">达标</a-radio>
                <a-radio value="2">基本达标</a-radio>
                <a-radio value="3">不达标</a-radio>
                <a-tooltip placement="topLeft" class="item" style="padding-left: 10px;">
                  <template slot="title">
                    <p><span>供水保证率</span></p>
                    <p><span>达标：P≥95%（1年内不正常供水的天数不超过18天）</span></p>
                    <p><span>基本达标：90%≤P＜95%（1年内不正常供水的天数在18至36天之间）</span></p>
                    <p><span>不达标：P＜90%（1年内不正常供水的天数超过36天）</span></p>
                  </template>
                  <a-icon type="message" />
                </a-tooltip>
              </a-radio-group>
            </a-form-item>
            <a-form-item label="饮水安全评价成果">
              <a-radio-group v-model:value="formObj.isSafWhle">
                <a-radio value="1">饮水安全</a-radio>
                <a-radio value="2">饮水基本安全</a-radio>
                <a-radio value="3">饮水不安全</a-radio>
              </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="88"
          :villType="88"
          curType="0"
          :objId="currentObjectId"
          :objName="currentObjectName"
          :curNm="yshRowData.usrName"
          :curId="yshRowData.id"
          :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',
    'yshRowData',
    'oriFatherName',
    'villageNm',
    'openType',
  ],
  data() {
    return {
      xx: '',
      objtbStatu: {
        presStat: '',
        rgstrId: '',
      },
      rules: {},
      formObj: {
        usrName: '',
        usrTel: '',
        usrLoc: '',
        prjDutyPers: '',
        uswtType: '',
        othrNote: '',
        isSafTable: '1',
        isUsrEnugh: '1',
        isRoleUsr: '1',
        isEasyUsr: '1',
        isConform: '1',
        isSafWhle: '1',
      },
      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/hshlds/${this.yshRowData.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/hshlds', 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_HSHLDS',
      };
      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>
