<template>
  <div style="padding: 10px;overflow-y:hidden;height: -webkit-fill-available;">
    <Row style="height: 100%;">
      <Col span="6" style="overflow: auto;height: 100vh">
        <Card style="width: 100%;">
          <tree-info-two maxLevel="7" @callBackTree="callBackTree" style="overflow: auto" :actionType="limitLine"></tree-info-two>
        </Card>
      </Col>
      <Col span="17" style="height: -webkit-fill-available;position: relative;top:10px;overflow-y: auto;padding-right: 2px;padding-bottom: 10px;margin-left: 20px;" >
        <div>
          <user-list :companyInfo="companyInfo" :choiceInfo="choiceInfo" ref="tablePeopleInfo" ></user-list>
        </div>
      </Col>
    </Row>
  </div>
</template>

<script>
import TreeInfoTwo from './tree-info'
import userList from './table-info/userList'
import { newGetCompanyInfo } from '@/api/contradiction.js'

export default {
  name: 'index',
  components: { TreeInfoTwo, userList },
  data () {
    return {
      severUserInfo: {},
      companyInfo: {},
      choiceInfo: {},
      limitLine: 'limitLine'
    }
  },
  methods: {
    callBackTree (e) { // 左侧树点击社区传给组件的方法
      this.choiceInfo = e
      this.$nextTick(() => {
        this.$refs.tablePeopleInfo.load(e)
        // this.$refs['tablePeopleInfo'].$refs['office'].load()
      })
    },
    newGetCompanyInfo () {
      let data = {
        id: this.severUserInfo.company_id
      }
      newGetCompanyInfo(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.companyInfo = ret.data.data
          if (Object.keys(this.choiceInfo).length === 0) {
            this.choiceInfo = ret.data.data
          }
        } else {
          this.$Notice.error({ title: '查询失败', desc: ret.data.errmsg })
        }
      })
    }
  },
  mounted () {
    this.severUserInfo = this.$store.state.user.severUserInfo
    this.newGetCompanyInfo()
    this.callBackTree({
      id: this.severUserInfo.company_id,
      grade: this.severUserInfo.company_grade,
      name: this.severUserInfo.company_name
    })
  }
}
</script>
<style scoped>
</style>
