<template>
    <div class="auto">
      <div v-if="isBatch" class="auto">
        <div class="form-group"><span>楼号</span><input v-model="name_l"  /></div>
        <div class="form-group">备注：例如1-5,10-18</div>
        <div class="form-group"><span>单元</span><input  v-model="name_d"/></div>
        <div class="form-group">备注：例如1-4</div>
        <div class="form-group"><span>楼层</span><input v-model="name_c" /></div>
        <div class="form-group">备注：例如1-5,8-10</div>
        <div class="form-group"><span>门牌号</span><input v-model="name_m" /></div>
        <div class="form-group">备注：例如103-334,503-510</div>
      </div>
      <div class="form-group">
        <button type="button" class="btn btn-success" @click="addChild" >保存</button>
        <button type="button" class="btn btn-default" @click="this.$emit('signout')" >取消</button>
      </div>
    </div>
</template>

<script>
  export default {
    name: "basch",
    props: {
      // 是否批量
      isBatch: {
        default: true,
      },
      id: {
        type: String
      }
    },
    data() {
      return {
        // 楼号
        name_l: '',
        // 单元
        name_d: '',
        // 楼层
        name_c: '',
        // 门牌号
        name_m: '',

      }
    },
    methods: {
      async addChild() {
        if(this.isBatch) {
          let batchs = new Array()
          if(this.name_l != '') {
            batchs.push({type: '楼号', names: this.name_l})
          }
          if(this.name_d != '') {
            batchs.push({type: '单元', names: this.name_d})
          }
          if(this.name_c != '') {
            batchs.push({type: '楼层', names: this.name_c})
          }
          if(this.name_m != '') {
            batchs.push({type: '门牌号', names: this.name_m})
          }
          console.log(batchs)
          await this.$resetpost(`rs/logic/address_batch`, {id: this.id, json: batchs})
          this.$emit('addChild')
        }
      }
    },
  }
</script>

<style scoped>

</style>
