<template>
  <div class="app-container">
    <van-sticky style="position:relative;">
      <div class="bannerBg">
        <van-nav-bar
          style="background:transparent;border-bottom-width:0;margin-bottom:.5rem;"
          @click-left="goBack()"
        >
          <template #left>
            <van-icon name="arrow-left" size="18" color="#fff" />
          </template>
          <template #title>
            <p style="color:#fff">入户调查</p>
          </template>
        </van-nav-bar>
      </div>
      <div style="width:95%;left:2.5%;position:absolute;background:#fff;border-radius:15px;box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.16);padding: .3rem;top:1.2rem">
        <van-row>
          <van-col span="4" :offset="1" style="text-align:center;" @click="$router.push({path:'/homesteadSurvey/add'})">
              <van-icon :name="require('../../assets/images/housesteadSurvey/zjd'+(active==1?'A':'D')+'.png')" size="1rem" style="margin-top:0px;"/>
              <p :style="{color:(active==1?'rgb(34, 183, 242)':'#000')}">宅基地</p>
          </van-col>
          <van-col span="2">
            <div style="border-top: 2px dashed #b5b4b4;margin-top: 20px;"></div>
          </van-col>
          <van-col span="4"  style="text-align:center;" @click="$router.push({path:'/homesteadSurvey/add2'})" >
            <van-icon :name="require('../../assets/images/housesteadSurvey/nhxx'+(active==2?'A':'D')+'.png')" size="1rem" style="margin-top:0px;"/>
            <p :style="{color:(active==2?'rgb(34, 183, 242)':'#000')}">农户</p>
          </van-col>
          <van-col span="2">
            <div style="border-top: 2px dashed #b5b4b4;margin-top: 20px;"></div>
          </van-col>
          <van-col span="4" style="text-align:center;" @click="$router.push({path:'/homesteadSurvey/add3'})" >
            <van-icon :name="require('../../assets/images/housesteadSurvey/fwxx'+(active==3?'A':'D')+'.png')" size="1rem" style="margin-top:0px;"/>
            <p  :style="{color:(active==3?'rgb(34, 183, 242)':'#000')}">房屋</p>
          </van-col>
          <van-col span="2">
            <div style="border-top: 2px dashed #b5b4b4;margin-top: 20px;"></div>
          </van-col>
          <van-col span="4" style="text-align:center;" @click="$router.push({path:'/homesteadSurvey/add4'})">
            <van-icon :name="require('../../assets/images/housesteadSurvey/fsss'+(active==4?'A':'D')+'.png')" size="1rem" style="margin-top:0px;"/>
            <p :style="{color:(active==4?'rgb(34, 183, 242)':'#000')}">附属物</p>
          </van-col>
        </van-row>
      </div>
    </van-sticky>
    <van-form ref = "form" label-width="auto">
      <div style="margin:1.6rem auto;background: #ffffff;width: 95%;box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.16);border-radius:15px;padding-top: 20px;">
        <p class="title" style="position:relative;padding-left:10px;line-height:20px;font-size: 16px;margin-left: 3%;margin-bottom: 5px;">农民房屋信息</p>
        <!--<van-field
          v-model="form.deptId"
          name="行政区划名称"
          label="行政区划名称"
          placeholder="行政区划名称"
          :rules="[{ required: true, message: '' }]"
        />-->
        <p class="title" style="position:relative;padding-left:10px;line-height:20px;font-size: 16px;margin-left: 3%;margin-bottom: 5px;">基本信息</p>
        <van-field
          input-align="right"
          v-model="form.nmfwzh"
          name="房屋幢号"
          label="房屋幢号"
          placeholder="房屋幢号"
          maxlength="50"
          autocomplete="off"
          :rules="[{ required: true }]"
          required
        />
        <van-field
          readonly
          clickable
          :rules="[{ required: true }]"
          required
          label="农户代码"
          placeholder="请选择"
          v-model="form.nhdm"
          @click="shownhdm = true"
          input-align="right"
          right-icon="arrow-down"
        />
        <van-popup v-model="shownhdm" position="bottom">
          <van-search v-model="nhdmSearch" placeholder="请输入搜索关键词" @input="onSearch"/>
          <van-picker
            show-toolbar
            :columns="newList"
            value-key="shyqrdbxm"
            @confirm="shyqrdmxmChange"
            @cancel="shownhdm = false"
          />
        </van-popup>
        <van-field
          input-align="right"
          v-model="form.sjcs"
          name="实际层数"
          label="实际层数"
          placeholder="实际层数"
          maxlength="50"
          autocomplete="off"
          type="number"
        />
        <van-field
          input-align="right"
          v-model="form.hh"
          name="户号"
          label="户号"
          placeholder="户号"
          maxlength="50"
          autocomplete="off"
        />
        <field-select
          v-model="form.hx"
          label="户型"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择户型"
          remote-url="/open/zdzh/list/nmfwhx"
          :on-remote-response="'data'"
        />
        <field-select
          v-model="form.hxjg"
          label="户型结构"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择户型结构"
          remote-url="/open/zdzh/list/nmfwhxjg"
          :on-remote-response="'data'"
        />
        <van-field
          v-model="form.nmfwmj"
          label="房屋面积(m²)"
          placeholder="请输入房屋面积"
          input-align="right"
          label-width="auto"
          :rules="[{ required: true }]"
          required
          type="number"/>

        <van-field
          v-model="form.fjzdmj"
          label="房基占地面积(m²)"
          placeholder="请输入房基占地面积"
          input-align="right"
          label-width="auto"
          type="number"/>

        <van-field
          v-model="form.jzmj"
          label="建筑面积(m²)"
          placeholder="请输入建筑面积"
          input-align="right"
          label-width="auto"
          type="number"/>
        <field-select
          v-model="form.fwlx"
          label="房屋类型"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择房屋类型"
          remote-url="/open/zdzh/list/fwlx"
          :on-remote-response="'data'"
        />
        <field-select
          v-model="form.fwxz"
          label="房屋性质"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择房屋性质"
          remote-url="/open/zdzh/list/fwxz"
          :on-remote-response="'data'"
        />
        <field-select
          v-model="form.fwjg"
          label="房屋结构"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择房屋结构"
          remote-url="/open/zdzh/list/housing_structure"
          :on-remote-response="'data'"
        />
        <van-field
          input-align="right"
          v-model="form.zl"
          name="坐落"
          label="坐落"
          placeholder="坐落"
          maxlength="50"
          autocomplete="off"
          :rules="[{ required: true }]"
          required
        />
        <field-select
          v-model="form.sjly"
          label="数据来源"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择数据来源"
          remote-url="/open/zdzh/list/sjly"
          :on-remote-response="'data'"
        />
        <van-field
          input-align="right"
          v-model="form.bz"
          name="备注"
          label="备注"
          placeholder="备注"
          maxlength="50"
          autocomplete="off"
        />
        <p class="title" style="position:relative;padding-left:10px;line-height:20px;font-size: 16px;margin-left: 3%;margin-bottom: 5px;">不动产信息</p>
        <van-field
          input-align="right"
          v-model="form.bdcdyh"
          name="不动产单元号"
          label="不动产单元号"
          placeholder="不动产单元号"
          maxlength="50"
          autocomplete="off"
        />
        <van-field
          input-align="right"
          v-model="form.fwbm"
          name="房屋编码"
          label="房屋编码"
          placeholder="房屋编码"
          maxlength="50"
          autocomplete="off"
        />
        <van-field
          input-align="right"
          v-model="form.zrzh"
          name="自然幢号"
          label="自然幢号"
          placeholder="自然幢号"
          maxlength="50"
          autocomplete="off"
        />
        <van-field
          input-align="right"
          v-model="form.ch"
          name="层号"
          label="层号"
          placeholder="层号"
          maxlength="50"
          autocomplete="off"
        />
        <van-field
          input-align="right"
          v-model="form.sjc"
          name="实际层"
          label="实际层"
          placeholder="实际层"
          maxlength="50"
          autocomplete="off"
          type="number"
        />
        <van-field
          input-align="right"
          v-model="form.myc"
          name="名义层"
          label="名义层"
          placeholder="名义层"
          maxlength="50"
          autocomplete="off"
          type="number"
        />
        <p class="title" style="position:relative;padding-left:10px;line-height:20px;font-size: 16px;margin-left: 3%;margin-bottom: 5px;">证书信息</p>
        <FieldRadio
          v-model="form.sffz"
          label="是否发证"
          value-key="dictLabel"
          data-key="dictValue"
          remote-url="/open/zdzh/list/house_yes_no"
          @change="onSffzChanged"
          :on-remote-response="'data'"
        />
        <van-field
          v-if="showFzxx"
          input-align="right"
          v-model="form.zsh"
          name="证书号"
          label="证书号"
          placeholder="证书号"
          maxlength="150"
          required
          :rules="[{ required: true, message: '' }]"
        />
        <van-field
          v-if="showFzxx"
          input-align="right"
          v-model="form.djjg"
          name="登记机构"
          label="登记机构"
          placeholder="登记机构"
          maxlength="50"
          autocomplete="off"
          required
          :rules="[{ required: true, message: '' }]"
        />
        <van-field
          v-if="showFzxx"
          autocomplete="off"
          input-align="right"
          v-model="form.djsj"
          name="登记时间"
          label="登记时间"
          placeholder="登记时间"
          required
          :rules="[{ required: true, message: '' }]"
          readonly
          @click="showDjsj = true"
        />
        <van-popup v-model:show="showDjsj" position="bottom">
          <van-datetime-picker
            :value="new Date"
            type="date"
            title="选择年月日"
            @confirm="onConfirmDjsj"
            @cancel="showDjsj = false"
          />
        </van-popup>
        <FieldRadio
          v-model="form.sfjf"
          label="是否纠纷"
          value-key="dictLabel"
          data-key="dictValue"
          remote-url="/open/zdzh/list/house_yes_no"
          :on-remote-response="'data'"
        />
        <FieldRadio
          v-model="form.sfcf"
          label="是否查封"
          value-key="dictLabel"
          data-key="dictValue"
          remote-url="/open/zdzh/list/house_yes_no"
          :on-remote-response="'data'"
          @change="onSfcfChanged"
        />
        <van-field
          v-if="showCfxx"
          autocomplete="off"
          input-align="right"
          v-model="form.cfqssj"
          name="查封起始时间"
          label="查封起始时间"
          placeholder="查封起始时间"
          required
          :rules="[{ required: true, message: '' }]"
          readonly
          @click="showCfqssj = true"
        />
        <van-popup v-model:show="showCfqssj" position="bottom">
          <van-datetime-picker
            :value="new Date"
            type="date"
            title="选择年月日"
            @confirm="onConfirmCfqssj"
            @cancel="showCfqssj = false"
          />
        </van-popup>
        <van-field
          v-if="showCfxx"
          autocomplete="off"
          input-align="right"
          v-model="form.cfjssj"
          name="查封结束时间"
          label="查封结束时间"
          placeholder="查封结束时间"
          required
          :rules="[{ required: true, message: '' }]"
          readonly
          @click="showCfjssj = true"
        />
        <van-popup v-model:show="showCfjssj" position="bottom">
          <van-datetime-picker
            :value="new Date"
            type="date"
            title="选择年月日"
            @confirm="onConfirmCfjssj"
            @cancel="showCfjssj = false"
          />
        </van-popup>
        <p class="title" style="position:relative;padding-left:10px;line-height:20px;font-size: 16px;margin-left: 3%;margin-bottom: 5px;">利用情况</p>
        <field-select
          v-model="form.lyzk"
          label="房屋利用状况"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择房屋利用状况"
          remote-url="/open/zdzh/list/nmfwlyzk"
          @change="onFwlyzkChanged"
          :on-remote-response="'data'"
        />
        <field-select
          v-if="showPhxx"
          v-model="form.phlyms"
          label="盘活利用模式"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择盘活利用模式"
          remote-url="/open/zdzh/list/phlyms"
          :on-remote-response="'data'"
          required
          :rules="[{ required: true, message: '' }]"
        />
        <van-field
          v-if="showPhxx"
          input-align="right"
          v-model="form.nsy"
          name="年收益(元)"
          label="年收益(元)"
          placeholder="年收益"
          maxlength="50"
          autocomplete="off"
          type="number"
          required
          :rules="[{ required: true, message: '' }]"
        />
        <van-field
          v-if="showXzxx"
          input-align="right"
          v-model="form.fwxzyy"
          name="房屋闲置原因"
          label="房屋闲置原因"
          placeholder="房屋闲置原因"
          maxlength="50"
          autocomplete="off"
          required
          :rules="[{ required: true, message: '' }]"
        />
        <van-field
          v-if="showXzxx"
          autocomplete="off"
          input-align="right"
          v-model="form.fwxzkqsj"
          name="房屋闲置起始时间"
          label="房屋闲置起始时间"
          placeholder="房屋闲置起始时间"
          required
          :rules="[{ required: true, message: '' }]"
          readonly
          @click="showFwxzqssj = true"
        />
        <van-popup v-model:show="showFwxzqssj" position="bottom">
          <van-datetime-picker
            :value="new Date"
            type="date"
            title="选择年月日"
            @confirm="onConfirmFwxzqssj"
            @cancel="showFwxzqssj = false"
          />
        </van-popup>
        <p class="title" style="position:relative;padding-left:10px;line-height:20px;font-size: 16px;margin-left: 3%;margin-bottom: 5px;">抵押情况</p>
        <FieldRadio
          v-model="form.sfdy"
          label="是否抵押"
          value-key="dictLabel"
          data-key="dictValue"
          remote-url="/open/zdzh/list/house_yes_no"
          :on-remote-response="'data'"
          @change="onSfdyChanged"
        />
        <van-field
          v-if="showDyxx"
          input-align="right"
          v-model="form.dyqlr"
          name="抵押权利人"
          label="抵押权利人"
          placeholder="抵押权利人"
          maxlength="50"
          autocomplete="off"
          required
          :rules="[{ required: true, message: '' }]"
        />
        <van-field
          v-if="showDyxx"
          input-align="right"
          v-model="form.dyje"
          name="抵押金额"
          label="抵押金额"
          placeholder="抵押金额"
          maxlength="50"
          autocomplete="off"
          type="number"
          required
          :rules="[{ required: true, message: '' }]"
        />
        <van-field
          v-if="showDyxx"
          autocomplete="off"
          input-align="right"
          v-model="form.zwlxsjStart"
          name="债务履行开始时间"
          label="债务履行开始时间"
          placeholder="债务履行开始时间"
          required
          :rules="[{ required: true, message: '' }]"
          readonly
          @click="showZwlvqssj = true"
        />
        <van-popup v-model:show="showZwlvqssj" position="bottom">
          <van-datetime-picker
            :value="new Date"
            type="date"
            title="选择年月日"
            @confirm="onConfirmZwlvqssj"
            @cancel="showZwlvqssj = false"
          />
        </van-popup>
        <van-field
          v-if="showDyxx"
          autocomplete="off"
          input-align="right"
          v-model="form.zwlxsjEnd"
          name="债务履行结束时间"
          label="债务履行结束时间"
          placeholder="债务履行结束时间"
          required
          :rules="[{ required: true, message: '' }]"
          readonly
          @click="showZwlvjssj = true"
        />
        <van-popup v-model:show="showZwlvjssj" position="bottom">
          <van-datetime-picker
            :value="new Date"
            type="date"
            title="选择年月日"
            @confirm="onConfirmZwlvjssj"
            @cancel="showZwlvjssj = false"
          />
        </van-popup>
        <p class="title" style="position:relative;padding-left:10px;line-height:20px;font-size: 16px;margin-left: 3%;margin-bottom: 5px;">其他信息</p>
        <van-field
          input-align="right"
          v-model="form.jznd"
          name="建筑年代"
          label="建筑年代"
          placeholder="建筑年代"
          maxlength="50"
          autocomplete="off"
        />
        <field-select
          v-model="form.fwaqxjddj"
          label="房屋安全性鉴定等级"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择房屋安全性鉴定等级"
          remote-url="/open/zdzh/list/fwaqxjddj"
          :on-remote-response="'data'"
        />
        <field-select
          v-model="form.fwzt"
          label="房屋状态"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择房房屋状态"
          remote-url="/open/zdzh/list/fwzt"
          :on-remote-response="'data'"
        />
        <field-select
          v-model="form.fwyt"
          label="房屋用途"
          value-key="dictLabel"
          data-key="dictValue"
          placeholder="请选择房房屋状态"
          remote-url="/open/zdzh/list/fwyt"
          :on-remote-response="'data'"
        />
        <FieldRadio
          v-model="form.sfytrgy"
          label="与其他人共有"
          value-key="dictLabel"
          data-key="dictValue"
          remote-url="/open/zdzh/list/house_yes_no"
          :on-remote-response="'data'"
        />
      </div>
      <div style="margin: 16px;display: flex;justify-content: space-around;">
        <van-button v-if="permission == 'true'" round color="#22B7F2" style="width:45%" @click="submitzjd">保存</van-button>
        <van-button plain color="#22B7F2" style="width:45%" round type="info" @click="cancel">取消</van-button>
      </div>
      <div style="height: 50px;"></div>
    </van-form>
  </div>
</template>

<script>
import {listZjdzd,getZjdzd,updateZjdzd,addZjdzd,uploadFile,getQueryLand,submitOnly} from "@/api/homesteadSurvey/zjdzd";
import FieldSelect from "@/components/form/FieldSelect";
import FieldRadio from "@/components/form/FieldRadio";
import CommonMap from "@/components/house/CommonMap";
import {getShyqrs} from "@/api/homesteadSurvey/shyqr";
import {addNh, delNh, exportNh, getNh, listNh, updateNh,setNhInfo} from "@/api/homesteadSurvey/nh";
import {listNmfw,addNmfw,updateNmfw,delNmfw} from "@/api/homesteadSurvey/nmfw";

import { Notify, Dialog, Toast } from 'vant';
import axios from "axios";
export default {
  components: {FieldSelect, FieldRadio,CommonMap},
  name: "zrzAdd",
  data() {
    return {
      active:3,
      // 使用权人列表
      permission:false,
      shownhdm:false,
      showDjsj:false,
      syqrlist:[
        {
          shyqrdbxm :'测试测试',
          shyqrdbzjhm :'12324648564',
          nhdm :'777888999',
        }
      ],
      showDyxx:false,
      showFzxx:false,
      showCfxx:false,
      showCfqssj:false,
      showCfjssj:false,
      showZwlvqssj:false,
      showZwlvjssj:false,
      showXzxx:false,
      showPhxx:false,
      zjdzdxxItem:{},
      // 地图绘制
      drawInsert: null,
      nhdmSearch:null,
      showDropList:false,
      showFwxzqssj:false,
      nhdmDictionaries:[],
      newList:[],
      // 当前位置信息
      tGeoOrganizationLat: null,
      tGeoOrganizationLng: null,
      minDate: new Date(),
      maxDate: new Date(2025, 10, 1),
      showZgqrzrq:false,
      form:{}
    };
  },
  created(){
    let data = this.$route.query;
    this.form = data;
    this.permission = localStorage.getItem("executePermission");
    this.zjdzdxxItem = JSON.parse(localStorage.getItem("zjdzdxxItem"));
    if(this.form.id == null){
      this.$set(this.form, 'hx', "03");
      this.$set(this.form, 'hxjg', "01");
      this.$set(this.form, 'fwlx', "01");
      this.$set(this.form, 'fwxz', "10");
      this.$set(this.form, 'fwjg', "02");
      this.$set(this.form, 'sjly', "04");
      this.$set(this.form, 'sffz', "0");
      this.$set(this.form, 'sfjf', "0");
      this.$set(this.form, 'sfcf', "0");
      this.$set(this.form, 'lyzk', "11");
      this.$set(this.form, 'sfdy', "0");
      this.$set(this.form, 'fwaqxjddj', "01");
      this.$set(this.form, 'fwzt', "01");
      this.$set(this.form, 'fwyt', "10");
      this.$set(this.form, 'sfytrgy', "0");
      this.$set(this.form, 'sjcs', 1);
    }else{
      if(this.form.sffz === "1"){
        this.showFzxx = true;
      }else{
        this.showWbzyy = true;
      }
      if(this.form.sfcf === "1"){
        this.showCfxx = true;
      }
      if(this.form.sfdy === "1"){
        this.showDyxx = true;
      }
      if(this.form.jznd != null){
        this.form.jznd = this.form.jznd.substr(0,10);
      }
      if(this.form.lyzk === "30"){
        this.showXzxx = true;
        this.showPhxx = false;
      }else if(this.form.lyzk === "11"){
        this.showXzxx = false;
        this.showPhxx = false;
      }else{
        this.showPhxx = true;
        this.showXzxx = false;
      }
    }

    this.getList();
  },
  mounted(){

  },
  methods: {
    getList(){
       getShyqrs({zjddm:this.form.zjddm}).then(response => {
        this.nhdmDictionaries = response.rows.map(function(item){
          item.shyqrdbxm = item.shyqrdbxm + item.nhdm;
          return {
            shyqrdbxm:item.shyqrdbxm,
            nhdm:item.nhdm,
          };
        });
        this.newList = this.nhdmDictionaries;
      });
    },
    submitzjd(){
      this.$refs.form.validate().then(() => {
      if(this.form.id == null){
        addNmfw(this.form).then(response => {
            let _this =this
            this.$toast({
              icon: 'success', // 找到自己需要的图标
              message: '保存成功',
              duration:"1000",
              onClose:function(){
                _this.$router.push({path:'/homesteadSurvey/nmfwList',query: {nmfwzh:_this.form.nmfwzh}});
              }
            })
        })
      }else{
        updateNmfw(this.form).then(response => {
          let _this =this
          this.$toast({
            icon: 'success', // 找到自己需要的图标
            message: '保存成功',
            duration:"1000",
            onClose:function(){
              _this.$router.push({path:'/homesteadSurvey/nmfwList',query: {nmfwzh:_this.form.nmfwzh}});
            }
          })
        });
      }
      }).catch((e) => {
        Dialog({ type: 'danger', message: '请填写完整的表单项' });
      });
    },
    /**是否发证*/
    onSffzChanged(val){
      if(val === '1'){
        this.showFzxx = true;
        this.$set(this.form, 'zsh', this.zjdzdxxItem.zsh);
      }else{
        this.showFzxx = false;
        this.$set(this.form, 'zsh', null);
        this.$set(this.form, 'djjg', null);
        this.$set(this.form, 'djsj', null);
      }
    },
    /**是否查封*/
    onSfcfChanged(val){
      if(val === '1'){
        this.showCfxx = true;
      }else{
        this.showCfxx = false;
        this.$set(this.form, 'cfqssj', null);
        this.$set(this.form, 'cfjssj', null);
      }
    },
    /**是否抵押*/
    onSfdyChanged(val){
      if(val === '1'){
        this.showDyxx = true;
      }else{
        this.showDyxx = false;
        this.$set(this.form, 'dyqlr', null);
        this.$set(this.form, 'dyje', null);
        this.$set(this.form, 'zwlxsjStart', null);
        this.$set(this.form, 'zwlxsjEnd', null);
      }
    },
    onConfirmDjsj(data){
      this.form.djsj = this.getNowFormatDate(data).substr(0,10);
      this.showDjsj = false;
    },
    onConfirmCfqssj(data){
      this.form.cfqssj = this.getNowFormatDate(data).substr(0,10);
      this.showCfqssj = false;
    },
    onConfirmCfjssj(data){
      this.form.cfjssj = this.getNowFormatDate(data).substr(0,10);
      this.showCfjssj = false;
    },
    onConfirmZwlvqssj(data){
      this.form.zwlxsjStart = this.getNowFormatDate(data).substr(0,10);
      this.showZwlvqssj = false;
    },
    onConfirmZwlvjssj(data){
      this.form.zwlxsjEnd = this.getNowFormatDate(data).substr(0,10);
      this.showZwlvjssj = false;
    },
    onSearch(val) {
      console.info(val);
      if(this.nhdmDictionaries.length>0){
        this.newList = []
        for(let j = 0 ;j<this.nhdmDictionaries.length;j++){
          if(this.nhdmDictionaries[j].shyqrdbxm.indexOf(val)>-1){
            this.newList.push(this.nhdmDictionaries[j]);
          }
        }
      }
      if(val==""){
        this.getList()
      }
    },
    onFwlyzkChanged(val){
      console.info(val.dictValue);
      if(val.dictValue === "30"){
        this.showXzxx = true;
        this.showPhxx = false;
      }else if(val.dictValue === "11"){
        this.showXzxx = false;
        this.showPhxx = false;
      }else{
        if(val.dictValue !== undefined)
        this.showPhxx = true;
        this.showXzxx = false;
      }
    },
    onConfirmFwxzqssj(data){
      this.form.fwxzkqsj = this.getNowFormatDate(data).substr(0,10);
      this.showFwxzqssj = false;
    },
    /** 模糊查询人员信息 */
    remoteTransfereeMethod(query) {
      if (query !== "") {
        console.info(this.form.zjddm);
        getShyqrs({zjddm:this.form.zjddm,shyqrdbxm:query,}).then((response) => {
          if (response.code == 200) {
            if(response.rows.length === 0){
              this.form.nhdm = null;
            }
            this.nhdmDictionaries = response.rows.map(function (item) {
              return {
                shyqrdbxm:item.shyqrdbxm,
                nhdm:item.nhdm
              }
            })
            //设置模糊查询的下拉框和滚动条
            if (this.nhdmDictionaries.length > 0) {
              this.showDropList = true;   // div显示会阻挡下边的选择框和输入框，showDropList控制下拉框是否显示
              //设置模糊查询的和滚动条
              this.$nextTick(() => {
                if (this.nhdmDictionaries.length > 4) {
                  let height = document.getElementById("vanCell").offsetHeight * 4;
                  document.getElementById("dropList").style.height = height + "px";
                  document.getElementById("dropList").style.overflow = "scroll";
                } else {
                  document.getElementById("dropList").style.height = "";
                  document.getElementById("dropList").style.overflow = "visible";
                }
              });
            } else {
              this.showDropList = false;
            }
          }
        });
      } else {
        this.nhdmDictionaries = [];
        this.showDropList = false;
      }
    },
    shyqrdmxmChange(val){
      this.$set(this.form, "nhdm", val.nhdm);
      this.shownhdm = false;
    },
    // 绘制申请地图
    pointDarw(data) {
      this.$nextTick(() => {
        let map = this.$refs.pointDarwMap;
        if(data === null)
            data = this.form.theGeomJson;
            this.setMapData(map, data);

      });
    },
    // 通用设置地图数据函数
    setMapData(map, data) {
      //console.log(map, data ? true : false);
      if(!map) return;
      if(data)
      {
        map.setLayer('pointDarwLayer', data);
      }
      else {
        this.getLandCoord((lng, lat) => {
          map.setCoord(this.tGeoOrganizationLng, this.tGeoOrganizationLat);
        });
      }
    },
    // 当地图绘制完成时
    onMapDrawFinished(data) {
      console.info(data);
     this.drawInsert = data;
      this.form.theGeomJson = JSON.stringify(this.drawInsert);
    },
    // 当申请地图被重置时
    onMapDrawReseted() {
      this.drawInsert = null;
      if(this.form.theGeomJson)
      {
        let lastData = JSON.parse(this.form.theGeomJson);
        if(lastData.hasOwnProperty('coordinates')) // 从后台获取的
          this.drawInsert = lastData.coordinates;
      }
    },
    cancel(){
      this.$router.push({path:'/homesteadSurvey/nmfwList',query: {nmfwzh:this.form.nmfwzh}});
    },
    // 获取登录人位置坐标
    getLandCoord(func) {
      if (func
        && this.tGeoOrganizationLng !== null && this.tGeoOrganizationLng !== ''
        && this.tGeoOrganizationLat !== null && this.tGeoOrganizationLat !== '') {
        this.$nextTick(() => {
          func(this.tGeoOrganizationLng, this.tGeoOrganizationLat);
        })
      }
      else {
        console.info(this.deptId);
        getQueryLand(this.deptId).then((response) => {
          if (response.code == 200) {
            let InsertCode = response.data;
            this.form.orgCode = InsertCode.orgCode;
            this.tGeoOrganizationLat = InsertCode.lat;
            this.tGeoOrganizationLng = InsertCode.lng;
            if(func)
            {
              func(this.tGeoOrganizationLng, this.tGeoOrganizationLat);
            }
          }
        });
      }
    },
    guidProduct(){
      return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0,
          v = c == 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
      });
    },
    /** 查找地图中定位点 */
    MapTag: function (data) {
      this.$refs[this.zjdProductResh].drawingPaceCountryDarw();
    },
    onConfirmZgqrzrq(data){
      this.form.jgrq = this.getNowFormatDate(data).substr(0,10);
      this.showZgqrzrq = false;
    },
    goBack(){
      if(this.ztMap && this.enterMap ==1){
        if(this.form.id == null){
          this.backMap.backMapZjdAData.theGeom= "";
        }else{
          this.backMap.backMapZjdAData = this.form;
        }
        this.$cookies.set("search",this.backMap);
      } else {
        this.$cookies.set("search","");
      }
      this.$router.push({name: this.$router.back(-1)});
      // }
    },
  }
}
</script>

<style scoped>
>>> .bannerBg{
  width: 100%;
  color:#fff;
  padding:10px;
  background: linear-gradient(134deg,#7ac943 1%, #22b7f2);
}
>>> .van-hairline--bottom::after {
  border-bottom-width: 0;
}
>>> .title:before
{
  content:"";
  width: 6px;
  height: 20PX;
  background: #7ac943;
  border-radius: 3px;
  position:absolute;
  left:0;
  bottom:0;
}
>>> .delete-button {
  height: 100%;
}
>>> .van-swipe-cell__wrapper{
  margin-right:-3px;
}
>>> .label-class .van-collapse-item__title--expanded{
  font-weight: bold;
}
</style>
