<template>
  <div class="app-container">
    <div class="header_main">
      有偿使用
      <div class="return_btn" @click="onClickLeft"></div>
    </div>
    <div class="main_box">
      <van-field
        readonly
        v-model="circulation.shyqrdm"
        label="使用权人"
        input-align="right"
      />
      <van-field
        readonly
        v-model="circulation.zjddm"
        label="宅基地代码"
        input-align="right"
      >
        <template #button>
          <van-button size="small" @click="mapLook" type="primary">查看地图</van-button>
        </template>
      </van-field>
      <van-field
        readonly
        v-model="zjlx"
        label="申请人证件类型"
        input-align="right"
        label-width="auto"
      />
      <van-field readonly v-model="circulation.sqrzjhm" label="申请人证件号码" placeholder="申请人证件号码" input-align="right" label-width="auto"/>
      <van-field readonly v-model="circulation.ycsyfs" label="有偿使用方式" placeholder="有偿使用方式" input-align="right" label-width="auto"/>
      <van-cell title="是否一户多宅">
        <template #right-icon>
          {{circulation.sfyhdz == 'Y' ? '是' : '否'}}
        </template>
      </van-cell>

      <van-field
        readonly
        v-model="circulation.ycsykssj"
        label="有偿使用开始时间"
        input-align="right"
        label-width="auto"
      />
      <van-field
        readonly
        v-model="circulation.ycsydqsj"
        label="有偿使用到期时间"
        input-align="right"
        label-width="auto"
      />
      <van-dialog v-model="mapShow" show-cancel-button>
        <MapGisObtainTc ref="zjdProductResh" :shqrxm="circulation.sqrxm" :landStatus="landStatus" :deptId="circulation.deptId" @closeMoule="closeMoule"></MapGisObtainTc>
      </van-dialog>
      <van-field readonly v-model="circulation.ycsymj" label="有偿使用面积(㎡)" placeholder="请输入有偿使用面积㎡" input-align="right" label-width="auto"/>
      <van-field readonly v-model="circulation.ycsymjdj" label="有偿使用面积单价(元)" placeholder="请输入有偿使用面积单价" input-align="right" label-width="auto"/>
      <van-field readonly v-model="circulation.ycsyfy" label="有偿使用费用(元)" placeholder="请输入有偿使用费用" input-align="right" label-width="auto"/>
      <van-field readonly v-model="circulation.fkfs" label="付款方式" placeholder="请输入付款方式" input-align="right" label-width="auto"/>
      <van-field readonly v-model="circulation.bz" label="备注" placeholder="请输入内容" input-align="right" label-width="auto"/>
    </div>
  </div>
</template>

<script>
  import { zjdzd } from "@/api/onlineHome/homestead/circulation";
  import { zyyctcEdit , getYcsy , ycsyEdit } from "@/api/onlineHome/homestead/paidUtilize";
  import MapGisObtainTc from "@/components/Map/MapGisObtainTc";
  import $ from "jquery";
  export default {
    name: "paidUtilizeDteail",
    components: {MapGisObtainTc},
    data() {
      return {
        tcqllxDictionaries:[],//退出权利类型
        tclxDictionaries:[],//退出类型
        tcfsDictionaries:[],//退出方式
        zjlxDictionaries:[],//申请人证件类型
        bcfsDictionaries:[],//补偿方式
        zjdDictionaries:[],//宅基地代码
        shyqrdmDictionaries:[],//使用权人
        landStatus:"1",
        tcqllx:'',
        tclx:'',
        tcfs:'',
        zjlx:'',
        bcfs:'',
        zjddm:'',

        showtcqllx: false,
        showtclx: false,
        showtcfs: false,
        showzjlx: false,
        showbcfs: false,
        showzjddm: false,
        showshyqrdm: false,
        showycsykssj: false,
        showycsydqsj: false,

        circulation:{},
        mapShow: false,
      };
    },
    created() {
      this.getDictionaries();
    },
    methods: {
      getDictionaries(){
        getYcsy(this.$route.query.id).then(response => {
          //退出权利类型
          this.houseGetDicts("tcqllx").then((res) => {
            for (var i = 0; i < res.data.length; i++) {
              this.tcqllxDictionaries.push({text: res.data[i].dictLabel, value: res.data[i].dictValue});
            }
            this.tcqllx = this.selectDictLabel(res.data, response.data.tcqllx);
          });
          //退出类型
          this.houseGetDicts("tclx").then((res) => {
            for (var i = 0; i < res.data.length; i++) {
              this.tclxDictionaries.push({text: res.data[i].dictLabel, value: res.data[i].dictValue});
            }
            this.tclx = this.selectDictLabel(res.data, response.data.tclx);
          });
          //退出方式
          this.houseGetDicts("tcfs").then((res) => {
            for (var i = 0; i < res.data.length; i++) {
              this.tcfsDictionaries.push({text: res.data[i].dictLabel, value: res.data[i].dictValue});
            }
            this.tcfs = this.selectDictLabel(res.data, response.data.tcfs);
          });
          //申请人证件类型
          this.houseGetDicts("zjlx").then((res) => {
            for (var i = 0; i < res.data.length; i++) {
              this.zjlxDictionaries.push({text: res.data[i].dictLabel, value: res.data[i].dictValue});
            }
            this.zjlx = this.selectDictLabel(res.data, response.data.sqrzjlx);
          });
          //补偿方式
          this.houseGetDicts("bcfs").then((res) => {
            for (var i = 0; i < res.data.length; i++) {
              this.bcfsDictionaries.push({text: res.data[i].dictLabel, value: res.data[i].dictValue});
            }
            this.bcfs = this.selectDictLabel(res.data, response.data.bcfs);
          });
          //宅基地代码
          zjdzd().then(zjdRes => {
            for (let i = 0; i < zjdRes.rows.length; i++) {
              this.zjdDictionaries.push(zjdRes.rows[i].zjddm);
            }
          });
          this.circulation = response.data;
        });
      },
      /** 查找地图中定位点 */
      MapTag: function (data) {
        //this.form.theGeom = data;
      },
      onConfirmZjddm(data){
        console.log(data)
        this.circulation.zjddm = data;
        this.showzjddm = false;
      },
      onConfirmZjlx(data){
        this.zjlx = data.text;
        this.circulation.sqrzjlx = data.value;
        this.showzjlx = false;
      },
      onConfirmTcqllx(data){
        this.tcqllx = data.text;
        this.circulation.tcqllx = data.value;
        this.showtcqllx = false;
      },
      onConfirmTclx(data){
        this.tclx = data.text;
        this.circulation.tclx = data.value;
        this.showtclx = false;
      },
      onConfirmTcfs(data){
        this.tcfs = data.text;
        this.circulation.tcfs = data.value;
        this.showtcfs = false;
      },
      onConfirmBcfs(data){
        this.bcfs = data.text;
        this.circulation.bcfs = data.value;
        this.showbcfs = false;
      },
      onConfirmShyqrdm(data){
        this.circulation.shyqrdm = data;
        this.showshyqrdm = false;
      },
      onConfirmYcsykssj(data){
        this.circulation.ycsykssj = this.getNowFormatDate(data).substr(0,10);
        this.showycsykssj = false;
      },
      onConfirmYcsydqsj(data){
        this.circulation.ycsydqsj = this.getNowFormatDate(data).substr(0,10);
        this.showycsydqsj = false;
      },
      goEdit(){
        window.location.replace("paidUtilizeList")
      },
      goSubmit(){
        ycsyEdit(this.circulation).then(response => {
          if(response.code = 200){
            this.$toast.success('修改成功');
            setTimeout(function(){
              window.location.replace("paidUtilizeList")
            },1000)
          }
        });
      },
      mapLook(){
        this.mapShow =true;
        setTimeout(() => {
          this.$refs.zjdProductResh.drawingLyPaceCountryDarw();
        },1000)
      },
    },
  }
</script>

<style scoped lang="scss">
  .app-container {
  .header_main{
    height: 116px;
    background: url('../../../../assets/images/sunVillage_info/list_head.png') no-repeat;
    background-size: 100% 100%;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    font-size: 36px;
    line-height: 116px;
    text-align: center;
    color: #fff;
    position: relative;
  .return_btn{
    width: 24px;
    height: 43.2px;
    background: url('../../../../assets/images/sunVillage_info/list_icon_5.png') center center no-repeat;
    background-size: 20px 36px;
    position: absolute;
    left: 38px;
    top: 36px;
  }
  .add_btn{
    width: 56.4px;
    height: 40.8px;
    background: url('../../../../assets/images/sunVillage_info/list_icon_9.png') center center no-repeat;
    background-size: 47px 34px;
    position: absolute;
    right: 38px;
    top: 36px;
  }
  }
  }
  .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;

  }
  .mapBox{
    position: relative;
  .mapBox_button{
    position: absolute;
    top: 0.2rem;
    right: 2%;
  }
  }
</style>
