<template>
  <div id='checkbookEntry' class="flex-row binary">
    <div class="binary-left">
      <tabset v-ref:tabs :close="false" class="nav-tabss">
        <tab header="用户查询">
          <check-book-search-user @childre="childre" v-ref:mbpeople_list></check-book-search-user>
        </tab>
<!--        <tab header="小区查询">-->
<!--          <check-book-search-area @book-list="setBookList" @book-all="setBookAll" @book-condition="setCondition"></check-book-search-area>-->
<!--        </tab>-->
<!--        <tab header="单位查询">-->
<!--          <check-book-search-unit @book-list="setBookList" @book-all="setBookAll" @book-condition="setCondition"></check-book-search-unit>-->
<!--        </tab>-->
      </tabset>
    </div>
    <div class="binary-right">
      <add-to-check-book v-ref:selectbok :usernum="rowsdata.length" v-if="AddTobookShow"></add-to-check-book>
    </div>
  </div>
</template>

<script>

  export default {
    name: 'checkBookEntry',
    title: '添加用户到片区',
    data () {
      return {
        AddTobookShow: true,
        rowsdata: null,
        condition: ''
      }
    },
    props: {
      showtype:{
        type: String
      }
    },
    created () {
    },
    ready () {
    },
    methods: {
      childre(val){
        this.$refs.selectbok.selectbook(val)
      },
      refresh () {

      }
    },
    events: {
      'add-tobook-refresh' () {
        this.refresh()
      },
      'add-tobook-confirm' (model) {
        this.rowsdata = this.$refs.mbpeople_list.$refs.paged.$refs.grid.getRowData()
        let msg = '确认将选中的用户全部移入表册？'
        if (this.rowsdata === null || this.rowsdata.length == 0) {
          this.$showAlert('请勾选用户！！', 'warning', 3000)
        } else {
          let userfilesids = []
          this.rowsdata.forEach((row) => {
            userfilesids.push(row.f_userinfo_id + '')
          })
          // 变成可以直接使用的格式
          this.$showMessage(msg, ['confirm', 'cancel']).then((res) => {
            if (res === 'confirm') {
              this.$resetpost('rs/logic/updateCheckBook', {f_check_book_id: model.f_check_book_num,rowsdata: userfilesids}, {
                resolveMsg: '保存成功',
                rejectMsg: '保存失败！'
              }).then(() => {
                // 刷新查询
                this.$refs.mbpeople_list.rowsdata = []
                this.$refs.mbpeople_list.getmeterbook()
                this.rowsdata = []
                this.$parent.meterbookEntryShow = false
                this.$refs.mbpeople_list.unnullrowdata = []
                this.$refs.mbpeople_list.radio = []
                this.refresh()
                this.$refs.mbpeople_list.$refs.paged.$refs.cri.search()
              })
            }
          })
        }
      }
    }
  }
</script>

<style lang="less">
  #checkbookEntry {
    height: 700px;
  }
</style>
