<template>
  <div>
    <validator name='v' @valid="$emit('valid')" @invalid="$emit('invalid')">
      <form class="form-horizontal select-overspread ">
        <div class="row">
          <div class="col-sm-4 form-group " :class="[!baseinfo.base.f_user_name ? 'has-error' : '']"
               v-if="getConfigShowItem('f_user_name')">
            <label for="f_user_name" class="font_normal_body">*{{getConfigLabelName('f_user_name','用户姓名')}}</label>
            <input type="text" v-model="baseinfo.base.f_user_name"
                   v-validate:f_user_name='getConfigValidate("f_user_name",true)'
                   class="input_search" style="width:60%" :placeholder="getConfigPlaceholder('f_user_name','用户姓名')" v-next-el="phone">
          </div>
          <div style="" class="col-sm-4 form-group"
               :class="[$v.f_user_phone.minlength || $v.f_user_phone.maxlength ? 'has-error' : '']" v-if="getConfigShowItem('f_user_phone')">
            <label for="f_user_phone" class="font_normal_body">*{{getConfigLabelName('f_user_phone','客户电话')}}</label>
            <input type="text" maxlength="11" v-model="baseinfo.base.f_user_phone"
                   v-validate:f_user_phone="getConfigValidate('f_user_phone')" class="input_search" style="width:60%"
                   :placeholder="getConfigPlaceholder('f_user_phone','客户电话')"
                   v-el:phone v-next-el="area">
          </div>
          <div class="col-sm-4 form-group">
            <label for="f_user_state" class="font_normal_body">&ensp;客户状态</label>
            <v-select :value.sync="baseinfo.base.f_user_state"
                      :disabled="false"
                      :value-single="true"
                      :options='userstates' placeholder='客户状态'
                      close-on-select></v-select>
          </div>
        </div>
        <div class="row">
          <div style="" class="col-sm-4 form-group">
            <label for="f_credentials" class="font_normal_body">&ensp;证件类型</label>
            <v-select id="idCardType"
                      :value.sync="baseinfo.base.f_credentials"
                      v-model="baseinfo.base.f_credentials"
                      :value-single="true"
                      :options='credentials'
                      placeholder='证件类型'
                      style="width: 65%"
                      close-on-select></v-select>
          </div>
          <div style="" class="col-sm-8 form-group"
               key="身份证号码"
               :class="[$v.f_idnumber.identityCardValid ? 'has-error' : '']"
               v-if="baseinfo.base.f_credentials.includes('身份证')">
            <label for="f_idnumber" class="font_normal_body color-red">*证件号码</label>
            <input type="text" maxlength="18" v-model="baseinfo.base.f_idnumber"
                   v-validate:f_idnumber='{identityCardValid: true}' class="input_search" style="width:80%"
                   placeholder="证件号码">
          </div>
          <div style="" class="col-sm-8 form-group"
               key="证件号码"
               v-else>
            <label class="font_normal_body">&ensp;证件号码</label>
            <input type="text" v-model="baseinfo.base.f_idnumber" class="input_search" style="width:80%"
                   placeholder="证件号码">
          </div>
        </div>
        <div class="row">
          <div class="col-sm-12 form-group" :class="[$v.f_address.required ? 'has-error' : '']">
            <label for="f_address" class="font_normal_body">*地址信息</label>
            <input type="text" v-model="addressinfo.f_address" v-validate:f_address="{required: true}"
                   class="input_search" disabled="disabled" style="width:75%;" placeholder="用户地址" >
            <span>
              <button class="button_search button_spacing" type="button" style="width: max-content" v-if="!isedit" @click="selectaddress()">选择地址</button>
              <!--              <button class="button_search button_spacing" type="button" style="width: max-content" v-if="isedit" @click="modifyaddress()">修改地址</button>-->
              <button class="button_search button_spacing" type="button" style="width: max-content" v-if="isedit" @click="selectaddress()">修改地址</button>
            </span>
          </div>
        </div>
        <div class="row">
          <div style=""
               v-show="(formconfig && formconfig.f_used_name && formconfig.f_used_name.required) || !onlyshowmust"
               :class="[$v.f_used_name.required ? 'has-error' : '']"
               class="col-sm-4 form-group" v-if="getConfigShowItem('f_used_name')">
            <label style="letter-spacing: 0.5em;margin-right: -0.5em;margin-left: -0.5em" for="f_used_name" class="font_normal_body w3">&ensp;{{getConfigLabelName('f_used_name','曾用名')}}</label>
            <input type="text" v-model="baseinfo.base.f_used_name" class="input_search" style="width:60%"
                   v-validate:f_used_name="getConfigValidate('f_used_name',false)"
                   :placeholder="getConfigPlaceholder('f_used_name','曾用名')">
          </div>
          <div style="" class="col-sm-4 form-group"
               v-show="(formconfig && formconfig.f_rent_phone && formconfig.f_rent_phone.required) || !onlyshowmust"
               :class="[$v.f_rent_phone.required ? 'has-error' : '']" v-if="getConfigShowItem('f_rent_phone')">
            <label for="f_rent_phone" class="font_normal_body">&ensp;备用电话</label>
            <input type="text" v-model="baseinfo.base.f_rent_phone" class="input_search" style="width:60%"
                   v-validate:f_rent_phone="getConfigValidate('f_rent_phone',false)"
                   placeholder="备用电话">
          </div>
          <div class="col-sm-4 form-group"
               v-show="(formconfig && formconfig.f_people_num && formconfig.f_people_num.required) || !onlyshowmust"
               :class="[$v.f_people_num.dctest ? 'has-error' : '']" v-if="getConfigShowItem('f_people_num')">
            <label for="f_people_num" style="letter-spacing: 0.5em;margin-right: -0.5em" class="font_normal_body w3">{{getConfigLabelName('f_people_num','人口数')}}</label>
            <input type="number" v-model="baseinfo.base.f_people_num" v-show="!peopleMax" v-validate:f_people_num='{dctest: [0, ">=" ]}'
                   :disabled="!jurisdiction.includes('修改人口数')" class="input_search" style="width:60%"
                   placeholder="家庭人口数">
            <v-select id="f_people_num" :value.sync="baseinfo.base.f_people_num"
                      v-if="peopleMax"
                      v-model="baseinfo.base.f_people_num"
                      :value-single="true"
                      :options='peoplenums'
                      :placeholder="getConfigPlaceholder('f_people_num','家庭人口数')"
                      style="width: 65%"
                      close-on-select></v-select>
          </div>
        </div>
        <div class="row">
          <div style=""
               v-show="(formconfig && formconfig.f_balance && formconfig.f_balance.required) || !onlyshowmust"
               :class="[$v.f_balance.required ? 'has-error' : '']"
               class="col-sm-4 form-group" v-if="getConfigShowItem('f_balance')">
            <label for="f_balance" class="font_normal_body">&ensp;{{getConfigLabelName('f_balance','用户余额')}}</label>
            <input type="text" v-model="baseinfo.base.f_balance" class="input_search" style="width:60%"
                   v-validate:f_balance="getConfigValidate('f_balance',false)"
                   :placeholder="getConfigPlaceholder('f_balance','用户余额')"
                   :disabled="!jurisdiction.includes('档案信息查询修改')">
          </div>
          <div style="" class="col-sm-4 form-group" v-if="getConfigShowItem('f_is_mgq')"
               v-show="(formconfig && formconfig.f_is_mgq && formconfig.f_is_mgq.required) || !onlyshowmust"
               :class="[$v.f_is_mgq.required ? 'has-error' : '']">
            <label for="f_is_mgq" style="letter-spacing: 0.5em;margin-right: -0.5em" class="font_normal_body w3">{{getConfigLabelName('f_is_mgq','煤改气')}}</label>
            <input type="text" v-show="false" v-model="baseinfo.base.f_is_mgq"
                   v-validate:f_is_mgq="getConfigValidate('f_is_mgq',false)">
            <v-select id="f_is_mgq" :value.sync="baseinfo.base.f_is_mgq"  v-model="baseinfo.base.f_is_mgq"
                      :placeholder="getConfigPlaceholder('f_is_mgq','是否煤改气')"
                      :options='mgq' style="width: 65%"       close-on-select></v-select>
          </div>
          <div class="col-sm-4 form-group" v-if="getConfigShowItem('f_book_no')"
               v-show="(formconfig && formconfig.f_book_no && formconfig.f_book_no.required) || !onlyshowmust"
               :class="[$v.f_book_no.required ? 'has-error' : '']">
            <label for="f_contract" class="font_normal_body">&ensp;{{getConfigLabelName('f_book_no','燃气本号')}}</label>
            <input type="text"  v-model="baseinfo.base.f_book_no" class="input_search" style="width:60%"
                   v-validate:f_book_no="getConfigValidate('f_book_no',false)"
                   :placeholder="getConfigPlaceholder('f_book_no','用户证号')">
          </div>
        </div>
        <div class="row">
          <div style="" class="col-sm-4 form-group" v-if="getConfigShowItem('f_rent_name')"
               v-show="(formconfig && formconfig.f_rent_name && formconfig.f_rent_name.required) || !onlyshowmust"
               :class="[$v.f_rent_name.required ? 'has-error' : '']">
            <label for="f_rent_name" class="font_normal_body">&ensp;{{getConfigLabelName('f_rent_name','租户姓名')}}</label>
            <input type="text" v-model="baseinfo.base.f_rent_name" class="input_search" style="width:60%"
                   v-validate:f_rent_name="getConfigValidate('f_rent_name',false)"
                   :placeholder="getConfigPlaceholder('f_rent_name','租户姓名')">
          </div>
          <div style="" class="col-sm-4 form-group" v-if="getConfigShowItem('f_zuhu_phone')"
               v-show="(formconfig && formconfig.f_zuhu_phone && formconfig.f_zuhu_phone.required) || !onlyshowmust"
               :class="[$v.f_zuhu_phone.required ? 'has-error' : '']">
            <label for="f_zuhu_phone" class="font_normal_body">{{getConfigLabelName('f_zuhu_phone','租户电话')}}</label>
            <input type="text" v-model="baseinfo.base.f_zuhu_phone" class="input_search" style="width:60%"
                   v-validate:f_zuhu_phone="getConfigValidate('f_zuhu_phone',false)"
                   :placeholder="getConfigPlaceholder('f_zuhu_phone','租户电话')">
          </div>
          <div style="" class="col-sm-4 form-group"
               v-show="(formconfig && formconfig.f_cost_type && formconfig.f_cost_type.required) || !onlyshowmust"
               v-if="getConfigShowItem('f_cost_type')">
            <label for="f_is_mgq" class="font_normal_body ">&ensp;{{getConfigLabelName('f_cost_type','付款类型')}}</label>
            <v-select id="f_is_mgq" :value.sync="baseinfo.base.f_cost_type"  v-model="baseinfo.base.f_cost_type"
                      :options='costtype'
                      :placeholder="getConfigPlaceholder('f_cost_type','付款类型')"  style="width: 65%"       close-on-select></v-select>
          </div>
        </div>
        <div class="row">
          <div class="col-sm-8 form-group" v-if="getConfigShowItem('f_contract_id')"
               v-show="(formconfig && formconfig.f_contract_id && formconfig.f_contract_id.required) || !onlyshowmust"
               :class="[$v.f_contract_id.required ? 'has-error' : '']">
            <label for="f_contract" class="font_normal_body">&ensp;{{getConfigLabelName('f_contract_id','合同编号')}}</label>
            <input type="text" v-model="baseinfo.base.f_contract_id" class="input_search" style="width:80%"
                   v-validate:f_contract_id="getConfigValidate('f_contract_id',false)"
                   :placeholder="getConfigPlaceholder('f_contract_id','合同编号')">
          </div>
          <div class="col-sm-4 form-group"
               v-show="(formconfig && formconfig.f_contract_id && formconfig.f_contract_id.required) || !onlyshowmust"
               :class="[$v.f_contract_id.required ? 'has-error' : '']">
            <label for="f_print_dh" class="font_normal_body ">&ensp;{{getConfigLabelName('f_print_dh','打印类别')}}</label>
            <input type="text" v-show="false" v-model="baseinfo.base.f_print_dh"
                   v-validate:f_print_dh="getConfigValidate('f_print_dh',false)">
            <v-select id="f_print_dh" :value.sync="baseinfo.base.f_print_dh"  v-model="baseinfo.base.f_print_dh"
                      :value-single="true" :disabled="baseinfo.base.f_print_dh_stats" :search="false"
                      :options='printstate' placeholder='流程单 | 点火单' style="width: 65%" close-on-select></v-select>
          </div>


        </div>
        <div class="row">
          <div style="" class="col-sm-12 form-group" v-if="getConfigShowItem('f_comments')"
               v-show="(formconfig && formconfig.f_comments && formconfig.f_comments.required) || !onlyshowmust"
               :class="[$v.f_comments.required ? 'has-error' : '']">
            <label for="f_paper_accoun" style="letter-spacing: 2em;margin-right: -2em;margin-left: -2em" class="font_normal_body w2">&ensp;{{getConfigLabelName('f_comments','备注')}}</label>
            <input class="input_search" style="width:86.5%;height: 40px" v-model="baseinfo.base.f_comments"
                   :placeholder="getConfigPlaceholder('f_comments','请输入备注信息')"
                   v-validate:f_comments="getConfigValidate('f_comments',false)">
          </div>

          <div class="col-sm-4 form-group"
               v-show="((formconfig && formconfig.f_house_type && formconfig.f_house_type.required) || !onlyshowmust) && getConfigShowItem('f_house_type')"
               :class="[$v.f_house_type.required ? 'has-error' : '']">
            <label for="f_user_state" class="font_normal_body">&ensp;{{getConfigLabelName('f_house_type','房屋类型')}}</label>
            <input type="text" v-show="false" v-model="baseinfo.base.f_house_type"
                   v-validate:f_house_type="getConfigValidate('f_house_type')"/>
            <v-select :value.sync="baseinfo.base.f_house_type"
                      v-model="baseinfo.base.f_house_type"
                      :search="false"
                      :value-single="true"
                      :options='housetype' close-on-select
                      :placeholder="getConfigPlaceholder('f_house_type','房屋类型')">
            </v-select>
          </div>
          <div class="col-sm-4 form-group" v-if="getConfigShowItem('f_user_region')"
               v-show="(formconfig && formconfig.f_user_region && formconfig.f_user_region.required) || !onlyshowmust"
               :class="[$v.f_user_nature.required ? 'has-error' : '']">
            <label for="f_user_nature" class="font_normal_body"
                   title="用户性质">&ensp;{{ getConfigLabelName('f_user_region', '用户区域') }}</label>
            <input type="text" v-show="false" v-model="baseinfo.base.f_user_region"
                   v-validate:f_user_nature=getConfigValidate('f_user_region',false)>
            <v-select :value.sync="baseinfo.base.f_user_region"
                      :search="false"
                      :value-single="true"
                      :placeholder="getConfigPlaceholder('f_user_region','用户区域')"
                      @change="userRegionChange"
                      :options='userRegions'
                      close-on-select>
            </v-select>
          </div>
          <div class="col-sm-4 form-group" v-if="getConfigShowItem('f_user_business_hall')"
               v-show="(formconfig && formconfig.f_user_business_hall && formconfig.f_user_business_hall.required) || !onlyshowmust"
               :class="[$v.f_user_business_hall.required ? 'has-error' : '']">
            <label for="f_user_nature" class="font_normal_body"
                   title="用户性质">&ensp;&ensp;{{ getConfigLabelName('f_user_business_hall', '营业厅') }}</label>
            <input type="text" v-show="false" v-model="baseinfo.base.f_user_business_hall"
                   v-validate:f_user_business_hall=getConfigValidate('f_user_nature',false)>
            <v-select :value.sync="baseinfo.base.f_user_business_hall"
                      :search="false"
                      :value-single="true"
                      :placeholder="getConfigPlaceholder('f_user_business_hall','营业厅')"
                      :options='userBusinessHalls'
                      close-on-select>
            </v-select>
          </div>
        </div>
        <div class="row">
          <div style="" class="col-sm-4 form-group" v-if="getConfigShowItem('f_type')"
               v-show="(formconfig && formconfig.f_type && formconfig.f_type.required) || !onlyshowmust"
               :class="[$v.f_type.required ? 'has-error' : '']">
            <label for="f_zuhu_phone" class="font_normal_body">{{getConfigLabelName('f_type','类型')}}</label>
            <v-select id="f_type" :value.sync="baseinfo.base.f_type"  v-model="baseinfo.base.f_type"
                      :value-single="true"
                      :placeholder="getConfigPlaceholder('f_type','类型')"
                      :options='type' style="width: 65%" close-on-select></v-select>
          </div>
        </div>
        <div class="row">
          <a style="text-decoration: none;font-weight: 300;float: left;color: #333;margin-top: 15px;font-weight: 500"
             v-if="baseinfo.base.f_cost_type[0] === '银行代扣'">银行信息</a>
        </div>
        <div v-if="baseinfo.base.f_cost_type[0] === '银行代扣'">
          <div class="row">
            <div class="col-sm-4 form-group"
                 :class="[$v.f_bank_accopen.required ? 'has-error' : '']">
              <label for="f_username" class="font_normal_body">银行户名</label>
              <input type="text" v-model="baseinfo.bank.f_bank_accopen"
                     class="input_search" style="width:60%" id="f_username" placeholder="客户名称"
                     v-validate:f_bank_accopen='{required: true}'
                     v-next-el="bankaccount">
            </div>
            <div class="col-sm-4 form-group" id=userfiles-useEssInf-银行名称>
              <label for="f_username" class="font_normal_body ">银行名称</label>
              <v-select :value.sync="baseinfo.bank.f_bank_name"
                        :options='banknames' placeholder='银行名称'
                        close-on-select></v-select>
            </div>
            <div class="col-sm-4 form-group">
              <label for="f_bank_idnumber" class="font_normal_body">缴费编号</label>
              <input type="text" v-model="baseinfo.bank.f_bank_pay_number"
                     class="input_search" style="width:60%"
                     aria-describedby="helpBlock" placeholder="缴费编号" v-el:bankpaynumber>
            </div>
            <div class="col-sm-12 form-group">
              <label for="f_bank_idnumber" class="font_normal_body">身份证号</label>
              <input type="text" v-model="baseinfo.bank.f_bank_idnumber"
                     class="input_search" style="width:54%"
                     aria-describedby="helpBlock" placeholder="身份证号" v-el:bankidnumber>
            </div>
            <div class="col-sm-12 form-group"
                 :class="[$v.f_bank_account.required ? 'has-error' : '']">
              <label for="f_userid" class="font_normal_body">银行账号</label>
              <input type="text" v-model="baseinfo.bank.f_bank_account" class="input_search" style="width:54%"
                     v-validate:f_bank_account='{required: true}' placeholder="银行账号" v-el:bankaccount
                     v-next-el="bankidnumber">
            </div>
          </div>
        </div>
      </form>
    </validator>
    <modal v-if="showselectaddress" :show.sync="showselectaddress" width="80%" title="地址信息" v-ref:modal large
           backdrop="false">
      <article slot="modal-body" class="modal-body" style="height: 700px;padding: 0!important;">
        <file-address-manage-new :is-select="isSelect" :fileinfo="addressinfo"
                                 @address-valid="doNothing" :showselectaddress.sync="showselectaddress"
                                 :f_filialeid="f_filialeid"
                                 v-ref:fileaddress></file-address-manage-new>
      </article>
      <footer slot="modal-footer" class="modal-footer">
      </footer>
    </modal>
  </div>
</template>

<script>
import {HttpResetClass} from 'vue-client'

let getEditUserState = async function (self) {
  try {
    let http = new HttpResetClass()
    let result = await http.load('GET', `rs/vue/EditUserState.json`, {}, {resolveMsg: null, rejectMsg: null})
    console.log('看看结果', result.data.EditUserState)
    self.config.f_print_dh = result.data.f_print_dh
    self.baseinfo.base.f_print_dh = (self.baseinfo.base.f_print_dh && self.baseinfo.base.f_print_dh != '' && self.baseinfo.base.f_print_dh != '否') ? self.baseinfo.base.f_print_dh : result.data.f_print_dh
    self.edituserstate = result.data.EditUserState
    self.config.f_idnumber = result.data.f_idnumber ? result.data.f_idnumber : self.config.f_idnumber
    self.config.f_house_type = result.data.f_house_type ? result.data.f_house_type : self.config.f_house_type
  } catch (e) {
    console.log(e)
  }
}

export default {
  title: '基本信息',
  props: ['baseinfo', 'addressinfo', 'isedit', 'f_filialeid', 'formconfig', 'onlyshowmust'],
  data () {
    return {
      showselectaddress: false,
      site: '',
      areas: [],
      streets: [],
      residentials: [],
      config: {
        f_idnumber: true,
        f_house_type: true
      },
      validateRules: {},
      inputtores: this.$appdata.getParam('抄表员'),
      credentials: this.$appdata.getParam('证件类型'),
      costtypes: this.$appdata.getParam('缴费类型'),
      banknames: this.$appdata.getParam('银行名称'),
      userstates: [{label: '预备', value: '预备'}],
      housetype: this.$appdata.getParam('房屋类型'),
      mgq: this.$appdata.getParam('是否煤改气'),
      type: this.$appdata.getParam('类型'),
      costtype: this.$appdata.getParam('付款类型'),
      printstate: this.$appdata.getParam('建档打印类型') ? [{label: '暂不选择', value: '暂不选择'}, ...this.$appdata.getParam('建档打印类型')] : [{label: '暂不选择', value: '暂不选择'}],
      peopleMax: this.$appdata.getSingleValue('最大人口数'),
      userRegions: this.$appdata.getParam('区域'),
      userBusinessHalls: [],
      jurisdiction: this.$login.r,
      edituserstate: false,
      // highMeterPlugin: {},
      readCardFlag: true,

      isSelect: false
    }
  },
  ready () {
    getEditUserState(this)
    this.$resetValidation()
    this.initValidateRules()
  },
  beforeDestroy () {
  },
  methods: {
    userRegionChange () {
      console.log('看一下用户区域的变化', this.baseinfo.base.f_user_region)
      if (this.baseinfo.base.f_user_region) {
        this.userBusinessHalls = this.$appdata.getParam(this.baseinfo.base.f_user_region + '区域营业厅')
      }
    },
    initValidateRules () {
      const fields = [
        'f_user_name', 'f_user_phone', 'f_idnumber', 'f_address', 'f_used_name',
        'f_rent_phone', 'f_people_num', 'f_balance', 'f_is_mgq', 'f_book_no',
        'f_rent_name', 'f_zuhu_phone', 'f_cost_type', 'f_contract_id', 'f_print_dh',
        'f_comments', 'f_house_type', 'f_bank_accopen', 'f_bank_account'
      ]

      fields.forEach(field => {
        this.validateRules[field] = {}
      })

      this.validateRules['f_user_phone'] = { minlength: 11, maxlength: 11 }

      this.updateValidateRules()
    },

    updateValidateRules () {
      if (!this.formconfig) return

      Object.keys(this.formconfig).forEach(field => {
        const fieldConfig = this.formconfig[field]
        const rules = {}

        if (fieldConfig.required) {
          rules.required = true
        }

        if (fieldConfig.minlength || fieldConfig.minlength === 0) {
          rules.minlength = fieldConfig.minlength
        }

        if (fieldConfig.maxlength) {
          rules.maxlength = fieldConfig.maxlength
        }

        this.validateRules[field] = Object.assign({}, this.validateRules[field], rules)
      })
    },

    getConfigValidate (name, defaultVal) {
      this.$resetValidation()

      if (this.validateRules[name] && Object.keys(this.validateRules[name]).length > 0) {
        return this.validateRules[name]
      } else if (name === 'f_user_phone') {
        return { minlength: 11, maxlength: 11 }
      } else if (defaultVal) {
        return {required: defaultVal}
      }

      return {}
    },
    getConfigShowItem (name, defaultVal = true) {
      if (this.formconfig && this.formconfig[name] && this.formconfig[name].hasOwnProperty('showItem')) {
        return this.formconfig[name].showItem
      } else {
        return defaultVal
      }
    },
    getConfigLabelName (name, defaultVal) {
      if (this.formconfig && this.formconfig[name] && this.formconfig[name].labelName) {
        return this.formconfig[name].labelName
      } else {
        return defaultVal
      }
    },
    getConfigPlaceholder (name, defaultVal) {
      if (this.formconfig && this.formconfig[name] && this.formconfig[name].placeholder) {
        return this.formconfig[name].placeholder
      } else {
        return defaultVal
      }
    },
    selectaddress () {
      this.showselectaddress = true
      this.isSelect = true
    },
    modifyaddress () {
      this.showselectaddress = true
      this.isSelect = false
    },
    onValid (res) {
      this.$dispatch('valid')
    },
    onInvalid (res) {
      this.$dispatch('invalid')
    },
    doNothing () {
      // console.log('啥也不做')
    },
    resetValidation () {
      this.baseinfo = Object.assign({}, this.baseinfo)
      this.$nextTick(() => {
        this.$resetValidation();
      })
    },
    readIDCardCallback (compoent, msg) {
      // console.log('进入高拍仪',msg)
      if (msg.err !== 0) {
        return
      }
      // document.getElementById("idCardType").getElementsByClassName("btn-content")[0].innerHTML="身份证"
      compoent.baseinfo.base.f_idnumber = msg.strID
      compoent.baseinfo.base.f_user_name = msg.strName.trim()
      compoent.baseinfo.base.f_credentials = '身份证'
    }
  },
  watch: {
    'baseinfo.base.f_credentials' () {
      this.$resetValidation();
      this.baseinfo.base.f_print_dh = (this.baseinfo.base.f_print_dh && this.baseinfo.base.f_print_dh != '' && this.baseinfo.base.f_print_dh != '否') ? this.baseinfo.base.f_print_dh : this.config.f_print_dh
    },
    'baseinfo.base.f_cost_type[0]' () {
      this.$resetValidation()
      this.baseinfo.base.f_print_dh = (this.baseinfo.base.f_print_dh && this.baseinfo.base.f_print_dh != '' && this.baseinfo.base.f_print_dh != '否') ? this.baseinfo.base.f_print_dh : this.config.f_print_dh
    },
    'baseinfo.base.f_house_type' () {
      console.log(JSON.stringify(this.$v));
      this.resetValidation()
    },
    'formconfig': {
      handler () {
        this.updateValidateRules()
      },
      deep: true
    }
  },
  computed: {
    peoplenums () {
      let peopleMax = this.$appdata.getSingleValue('最大人口数') ? this.$appdata.getSingleValue('最大人口数') : 0
      let nums = []
      for (let i = 1; i <= peopleMax; i++) {
        let temp = {}
        temp.label = i
        temp.value = i
        nums.push(temp)
      }
      return nums
    }
  },
  events: {
    'confirmaddress' (res) {
      this.showselectaddress = false
      this.addressinfo.f_address = res.f_address
      this.addressinfo.id = res.id
      if (res.f_house_type != null) {
        this.baseinfo.base.f_house_type = res.f_house_type
      }
      this.$dispatch('defaultOtheret', res)
    }
  }
}
</script>
