<template>
  <div class="add">
    <div class="form-group">
      <p>生活条件</p>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>户类型</span>
          </div>
          <div class="right">
            <AiSelect dict="fpType" v-model="form.objectType"></AiSelect>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>住房面积</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>与村主干路距离</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>入户路类型</span>
          </div>
          <div class="right">
            <AiSelect dict="fpType" v-model="form.objectType"></AiSelect>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>主要燃料类型</span>
          </div>
          <div class="right">
            <AiSelect dict="fpType" v-model="form.objectType"></AiSelect>
          </div>
        </div>
      </div>
    </div>

    <div class="form-group" style="margin-top: 8px;">
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否危房</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.dilapidatedHousehold == '01' ? 'check-active' : '' " @click="form.dilapidatedHousehold='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.dilapidatedHousehold != '01' ? 'check-active' : '' " @click="form.dilapidatedHousehold='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否解决安全饮水</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.drinkingWaterSafety == '01' ? 'check-active' : '' " @click="form.drinkingWaterSafety='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.drinkingWaterSafety != '01' ? 'check-active' : '' " @click="form.drinkingWaterSafety='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否住房损坏</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.move == '01' ? 'check-active' : '' " @click="form.move='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.move !='01' ? 'check-active' : '' " @click="form.move='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否饮水设施损坏</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.move == '01' ? 'check-active' : '' " @click="form.move='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.move !='01' ? 'check-active' : '' " @click="form.move='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否有卫生厕所</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.move == '01' ? 'check-active' : '' " @click="form.move='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.move !='01' ? 'check-active' : '' " @click="form.move='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否通生活用电</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.move == '01' ? 'check-active' : '' " @click="form.move='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.move !='01' ? 'check-active' : '' " @click="form.move='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否通广播电视</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.move == '01' ? 'check-active' : '' " @click="form.move='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.move !='01' ? 'check-active' : '' " @click="form.move='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
    </div>

    <div class="form-group" style="margin-top: 8px;">
      <p>生产条件</p>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>耕地面积(亩)</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>

      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>林果面积(亩)</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>

      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>林地面积(亩)</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>

      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>退耕还林面积(亩)</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>牧草地面积(亩)</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i></i>
            <span>水面面积(亩)</span>
          </div>
          <div class="right">
            <u-input v-model="value" placeholder="请输入" placeholder-style="font-size: 15px;" type="text"  />
          </div>
        </div>
      </div>
    </div>

    <div class="form-group" style="margin-top: 8px;">
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否有龙头企业带动</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.dilapidatedHousehold == '01' ? 'check-active' : '' " @click="form.dilapidatedHousehold='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.dilapidatedHousehold != '01' ? 'check-active' : '' " @click="form.dilapidatedHousehold='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否通生产用电</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.drinkingWaterSafety == '01' ? 'check-active' : '' " @click="form.drinkingWaterSafety='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.drinkingWaterSafety != '01' ? 'check-active' : '' " @click="form.drinkingWaterSafety='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否加入农民专业合作社</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.move == '01' ? 'check-active' : '' " @click="form.move='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.move !='01' ? 'check-active' : '' " @click="form.move='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
      <div class="form-item">
        <div class="form-item__wrapper">
          <div class="left">
            <i>*</i>
            <span>是否有创业致富带头人带动</span>
          </div>
          <div class="right">
            <div class="check-item" :class="form.move == '01' ? 'check-active' : '' " @click="form.move='01'">是<img src="./components/img/check-icon.png" alt=""></div>
            <div class="check-item" :class="form.move !='01' ? 'check-active' : '' " @click="form.move='02'">否<img src="./components/img/check-icon.png" alt=""></div>
          </div>
        </div>
      </div>
    </div>

    <div class="btn" hover-class="text" @click="submit">保存</div>
  </div>
</template>

<script>

export default {
  data() {
    return {
      form: {
        objectType: '',
        dilapidatedHousehold: '02',
        drinkingWaterSafety: '02',
        move: '02'
      },
      id: '',
      girdId: '',
      girdName: '',
      value: '',
    }
  },


  onLoad(query) {
    this.$dict.load(['fpYesOrNo', 'fpRiskType']).then(() => {
      this.getInfo(query.id)
    })
    this.id = query.id
    this.girdId = query.girdId
    this.girdName = query.girdName
    
    
  },

  onShow() {
    document.title = '生活生产条件'
  },

  methods: {
    getInfo(id) {
      this.$http.post(`/app/apppreventionreturntopoverty/queryDetailById?id=${id}`).then(res => {
        if (res.code === 0) {
          this.form = {
            ...this.form,
            ...res.data
          }
        }

        uni.hideLoading()
      })
    },

    submit() {
      this.form.girdId = this.girdId
      this.form.girdName = this.girdName
      this.$http.post('/app/apppreventionreturntopoverty/addByEwechat', {
        ...this.form,
        id: this.id
      }).then(res => {
        if (res.code === 0) {
          this.$u.toast('保存成功')
          uni.$emit('reload')
          uni.navigateBack({
            delta: 1
          })
        }
      })
    },
  }
}
</script>

<style lang="scss">
.add {
  padding-bottom: 120px;

  .form-textarea {
    padding: 32px;

    h2 {
      margin-bottom: 32px;
      color: #333333;
      font-size: 32px;
      font-weight: 500;
    }

    textarea {
      width: 100%;
      height: 200px;
    }
  }

  & > div {
    margin-bottom: 16px;
    // background: #fff;
  }

  ::v-deep .u-radio {
    &:last-child {
      .u-radio__label {
        margin-right: 0;
      }
    }
  }

  .form-group {
    background: #fff;
    p {
      color: #333333;
      font-size: 36px;
      padding: 20px 32px;
      // border-bottom: 1px solid #E4E5E6;
      font-weight: 600;
    }
    .form-item {
      padding: 0 32px;

      .form-item__wrapper {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 112px;
        border-bottom: 1px solid #E4E5E6;
      }

      .left {
        width: 300px;
      }

      .right {
        width: calc(100% - 300px);
        text-align: right;
        ::v-deep .u-input .u-input__input .uni-input-wrapper {
          text-align: right;
        }

        span {
          font-size: 30px;
          color: #999999;
        }
        .check-item{
          display: inline-block;
          width: 160px;
          height: 64px;
          line-height: 64px;
          text-align: center;
          background: #F5F5F5;
          border-radius: 4px;
          font-size: 30px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #333;
          position: relative;
          img{
            display: none;
          }
        }
        .check-item:nth-of-type(1) {
          margin-right: 36px;
        }
        .check-active{
          background: #E7F1FE;
          color: #1174FE;
          img{
            display: block;
            position: absolute;
            bottom: 0;
            right: 0;
            width: 48px;
            height: 48px;
          }
        }
      }

      input {
        height: 100%;
        text-align: right;
      }

      .left {
        display: flex;
        align-items: center;

        span {
          color: #333333;
          font-size: 32px;
        }

        i {
          margin-right: 4px;
          font-style: normal;
          color: #FF4466;
          font-size: 32px;
        }
      }

      &:last-child {
        .form-item__wrapper {
          border: none;
        }
      }
    }
  }

  .form-item__imgs {
    padding: 32px;

    .form-item__title {
      display: flex;
      align-items: center;
      margin-bottom: 34px;

      h2 {
        color: #333333;
        font-weight: normal;
        font-size: 32px;
      }

      i {
        color: #999999;
        font-size: 28px;
        font-style: normal;
      }
    }

    textarea {
      width: 100%;
    }
  }

  .form-type {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 112px;
    padding: 0 32px;

    h2 {
      font-weight: normal;
      color: #333333;
      font-size: 32px;
    }

    span {
      color: #999999;
      font-size: 28px;
    }
  }

  .btn {
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 11;
    width: 100%;
    height: 112px;
    line-height: 112px;
    margin: 0;
    text-align: center;
    color: #FFFFFF;
    font-size: 32px;
    background: #3192F4;
  }
}
</style>
