<template>
    <div class="app-container">
      <van-nav-bar
        left-arrow
        fixed
        placeholder
        @click-left="$router.back(-1)"
      >
        <template #title>
          <p style="font-weight: bold;">农民房屋利用情况调查</p>
        </template>
      </van-nav-bar>
        <div class="main_box">
          <van-field
            readonly
            clickable
            name="picker"
            v-model="circulation.nmfwdm"
            label="农民房屋代码"
            placeholder="请选择"
            @click="showzjddm = true"
            input-align="right"
            right-icon="arrow-down"
          />
          <van-popup v-model="showzjddm" position="bottom">
            <van-picker
              show-toolbar
              :columns="zjdDictionaries"
              @confirm="onConfirmZjddm"
              @cancel="showzjddm = false"
            />
          </van-popup>
          <van-field
            readonly
            clickable
            name="picker"
            v-model="fwzt"
            label="房屋状态"
            placeholder="请选择"
            @click="showfwzt = true"
            input-align="right"
            right-icon="arrow-down"
            label-width="auto"
          />
          <van-popup v-model="showfwzt" position="bottom">
            <van-picker
              show-toolbar
              :columns="fwztDictionaries"
              @confirm="onConfirmFwzt"
              @cancel="showfwzt = false"
            />
          </van-popup>
          <van-field
            readonly
            clickable
            name="picker"
            v-model="fwaqxjddj"
            label="房屋安全性鉴定等级"
            placeholder="请选择"
            @click="showfwaqxjddj = true"
            input-align="right"
            right-icon="arrow-down"
            label-width="auto"
          />
          <van-popup v-model="showfwaqxjddj" position="bottom">
            <van-picker
              show-toolbar
              :columns="fwaqxjddjDictionaries"
              @confirm="onConfirmFwaqxjddj"
              @cancel="showfwaqxjddj = false"
            />
          </van-popup>
          <van-field
            readonly
            clickable
            name="picker"
            v-model="lyzk"
            label="利用状况"
            placeholder="请选择"
            @click="showlyzk = true"
            input-align="right"
            right-icon="arrow-down"
            label-width="auto"
          />
          <van-popup v-model="showlyzk" position="bottom">
            <van-picker
              show-toolbar
              :columns="lyzkDictionaries"
              @confirm="onConfirmLyzk"
              @cancel="showlyzk = false"
            />
          </van-popup>
          <van-field
            readonly
            clickable
            name="picker"
            v-model="fwsfxz"
            label="房屋是否闲置"
            placeholder="请选择"
            @click="showfwsfxz = true"
            input-align="right"
            right-icon="arrow-down"
            label-width="auto"
          />
          <van-popup v-model="showfwsfxz" position="bottom">
            <van-picker
              show-toolbar
              :columns="fwsfxzDictionaries"
              @confirm="onConfirmFwsfxz"
              @cancel="showfwsfxz = false"
            />
          </van-popup>
          <van-field v-model="circulation.fwxzyy" label="闲置原因" placeholder="闲置原因" input-align="right" label-width="auto"/>
          <van-field
            readonly
            clickable
            name="picker"
            v-model="circulation.fwxzqssj"
            label="房屋闲置起始时间"
            placeholder="房屋闲置起始时间"
            @click="showfwxzqssj = true"
            input-align="right"
            right-icon="arrow-down"
            label-width="auto"
          />
          <van-popup v-model="showfwxzqssj" position="bottom">
            <van-datetime-picker
              v-model="currentDate"
              type="date"
              title="选择年月日"
              :min-date="minDate"
              :max-date="maxDate"
              @confirm="onConfirmFwxzqssj"
            />
          </van-popup>
          <van-field
            readonly
            clickable
            name="picker"
            v-model="phlyms"
            label="盘活利用模式"
            placeholder="请选择"
            @click="showphlyms = true"
            input-align="right"
            right-icon="arrow-down"
            label-width="auto"
          />
          <van-popup v-model="showphlyms" position="bottom">
            <van-picker
              show-toolbar
              :columns="phlymsDictionaries"
              @confirm="onConfirmPhlyms"
              @cancel="showphlyms = false"
            />
          </van-popup>
          <van-field
            readonly
            clickable
            name="picker"
            v-model="circulation.dcsj"
            label="调查时间"
            placeholder="选择调查时间"
            @click="showdcsj = true"
            input-align="right"
            right-icon="arrow-down"
          />
          <van-popup v-model="showdcsj" position="bottom">
            <van-datetime-picker
              v-model="currentDate"
              type="date"
              title="选择年月日"
              :min-date="minDate"
              :max-date="maxDate"
              @confirm="onConfirmDcsj"
            />
          </van-popup>
          <van-field v-model="circulation.nsy" label="年收益" placeholder="年收益" input-align="right" label-width="auto"/>
        </div>

        <p class="main_title">照片信息</p>
        <div class="main_box" style="padding: 5%;">
          <van-row>
            <van-col span="12">
              <p style="margin-bottom: 5%;color: #333333;font-size: 14px;">现场照片东</p>
              <van-uploader v-model="findList" multiple />
            </van-col>
            <van-col span="12">
              <p style="margin-bottom: 5%;color: #333333;font-size: 14px;">现场照片南</p>
              <van-uploader v-model="findList" multiple />
            </van-col>
          </van-row>
          <van-row>
            <van-col span="12">
              <p style="margin-bottom: 5%;color: #333333;font-size: 14px;">现场照片西</p>
              <van-uploader v-model="findList" multiple />
            </van-col>
            <van-col span="12">
              <p style="margin-bottom: 5%;color: #333333;font-size: 14px;">现场照片北</p>
              <van-uploader v-model="findList" multiple />
            </van-col>
          </van-row>
        </div>

        <p class="main_title">补偿信息</p>
        <div class="main_box">
          <van-field v-model="circulation.bz" label="备注" type="textarea" placeholder="请输入内容" input-align="right" label-width="auto"/>
        </div>

        <div style="padding: 16px 0;">
          <van-row>
            <van-col span="12" align="center">
              <van-button type="info" color="#B4B0B0" native-type="submit" class="submitButton">关闭</van-button>
            </van-col>
            <van-col span="12" align="center">
              <van-button type="info" native-type="submit" class="submitButton" @click="goSubmit">保存</van-button>
            </van-col>
          </van-row>
          <div class="clear"></div>
        </div>
    </div>
</template>

<script>
import { nmfwlyAdd } from "@/api/onlineHome/homestead/utilization";
import { zjdzd } from "@/api/onlineHome/homestead/circulation";
export default {
    name: "circulationAdd",
  data() {
    return {
      minDate: new Date(2020, 0, 1),
      maxDate: new Date(2025, 10, 1),
      currentDate: new Date(2021, 0, 17),
      findList:[],

      phlyms : '',
      fwsfxz : '',
      lyzk : '',
      fwaqxjddj : '',
      fwzt: '',

      showzjddm:false,
      showphlyms:false,
      showfwsfxz:false,
      showlyzk:false,
      showfwaqxjddj:false,
      showfwzt:false,
      showdcsj: false,
      showfwxzqssj: false,

      phlymsDictionaries: [],
      fwsfxzDictionaries: [],
      lyzkDictionaries: [],
      fwaqxjddjDictionaries: [],
      fwztDictionaries: [],
      zjdDictionaries: [],

      circulation: {}
    };
  },
  created() {
    this.getDetail()
  },
  methods: {
    getDetail(){
      //退出权利类型
      this.houseGetDicts("fwzt").then((res) => {
        for(var i = 0 ; i < res.data.length ; i++){
          this.fwztDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
        }
      });
      this.houseGetDicts("fwaqxjddj").then((res) => {
        for(var i = 0 ; i < res.data.length ; i++){
          this.fwaqxjddjDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
        }
      });
      this.houseGetDicts("nmfwlyzk").then((res) => {
        for(var i = 0 ; i < res.data.length ; i++){
          this.lyzkDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
        }
      });
      this.houseGetDicts("sys_yes_no").then((res) => {
        for(var i = 0 ; i < res.data.length ; i++){
          this.fwsfxzDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
        }
      });
      this.houseGetDicts("phlyms").then((res) => {
        for(var i = 0 ; i < res.data.length ; i++){
          this.phlymsDictionaries.push({text:res.data[i].dictLabel,value:res.data[i].dictValue});
        }
      });
      //宅基地代码
      zjdzd().then(zjdRes => {
        for( let i = 0 ; i < zjdRes.rows.length ; i++){
          this.zjdDictionaries.push(zjdRes.rows[i].zjddm);
        }
      });
    },
    onConfirmZjddm(data){
      console.log(data)
      this.circulation.nmfwdm = data;
      this.showzjddm = false;
    },
    onConfirmPhlyms(data){
      this.phlyms = data.text;
      this.circulation.phlyms = data.value;
      this.showphlyms = false;
    },
    onConfirmFwsfxz(data){
      this.fwsfxz = data.text;
      this.circulation.fwsfxz = data.value;
      this.showfwsfxz = false;
    },
    onConfirmLyzk(data){
      this.lyzk = data.text;
      this.circulation.lyzk = data.value;
      this.showlyzk = false;
    },
    onConfirmFwaqxjddj(data){
      this.fwaqxjddj = data.text;
      this.circulation.fwaqxjddj = data.value;
      this.showfwaqxjddj = false;
    },
    onConfirmFwzt(data){
      this.fwzt = data.text;
      this.circulation.fwzt = data.value;
      this.showfwzt = false;
    },
    onConfirmFwxzqssj(data){
      this.circulation.fwxzqssj = this.getNowFormatDate(data).substr(0,10);;
      this.showfwxzqssj = false;
    },
    onConfirmFwxzqssj(data){
      this.circulation.fwxzqssj = this.getNowFormatDate(data).substr(0,10);;
      this.showfwxzqssj = false;
    },
    onConfirmDcsj(data){
      this.circulation.dcsj = this.getNowFormatDate(data).substr(0,10);;
      this.showdcsj = false;
    },
    goSubmit(){
      console.log(this.circulation)
      nmfwlyAdd(this.circulation).then(response => {
        if(response.code = 200){
          this.$toast.success('保存成功');
        }
      });
    }

  },
}
</script>

<style scoped lang="scss">
  .app-container {
    padding: 2% 0;
  }
  .main_title{
    font-size: 0.4rem;
    color: #1D6FE9;
    margin: 0.2rem 6%;
    position: relative;
  }
  .main_box{
    width: 96%;
    margin: 0 auto;
    border-radius: 6px;
    box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
    overflow: hidden;
    background-color: #FFF;
  }
  .submitButton{
    width: 80%;
    margin: 0 auto;
    background-color: #1D6FE9;

  }
</style>
