<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>
          <roleManagerList ref="tableRoleManagerInfo"></roleManagerList>
        </div>
      </Col>
    </Row>
  </div>
</template>

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

export default {
  name: 'index',
  components: { TreeInfoTwo, roleManagerList },
  data () {
    return {
      severUserInfo: {},
      companyInfo: {},
      choiceInfo: {},
      limitLine: 'limitLine'
    }
  },
  methods: {
    callBackTree (e) { // 左侧树点击社区传给组件的方法
      console.log('e>callBackTree>', e)
      this.choiceInfo = e
      this.$nextTick(() => {
        this.$refs.tableRoleManagerInfo.searchInfo.name = ''
        this.$refs.tableRoleManagerInfo.searchInfo.companyId = e.id
        this.$refs.tableRoleManagerInfo.sysUserId = e.sysUserId
        this.$refs.tableRoleManagerInfo.searchInfo.companyGrade = e.grade
        this.$refs.tableRoleManagerInfo.searchInfo.companyName = e.name
        if (e['sysUserId']) {
          this.$refs.tableRoleManagerInfo.getRoleList(e.sysUserId)
        }

        // this.$refs['tableRoleManagerInfo'].$refs['office'].load()
      })
    },
    async newGetCompanyInfo () {
      let data = {
        id: this.severUserInfo.company_id
      }
      const ret = await newGetCompanyInfo(data)
      if (ret.data.errcode === 0) {
        this.companyInfo = ret.data.data
        if (Object.keys(this.choiceInfo).length === 0) {
          this.choiceInfo = ret.data.data
        }
        this.$refs.tableRoleManagerInfo.searchInfo.name = ''
        /*   this.$refs.tableRoleManagerInfo.searchInfo.companyId = ret.data.data.id
          this.$refs.tableRoleManagerInfo.searchInfo.sysUserId = ret.data.data.sysUserId
          this.$refs.tableRoleManagerInfo.searchInfo.companyGrade = ret.data.data.grade
          this.$refs.tableRoleManagerInfo.searchInfo.companyName = ret.data.data.name */
        setTimeout(() => {
          this.$refs.tableRoleManagerInfo.sysUserId = ret.data.data.sysUserId
        }, 500)
        this.$refs.tableRoleManagerInfo.getRoleList(ret.data.data.sysUserId)
      } else {
        this.$Notice.error({ title: '查询失败', desc: ret.data.errmsg })
      }
    }
  },
  async mounted () {
    this.severUserInfo = this.$store.state.user.severUserInfo
    await this.newGetCompanyInfo()
    this.callBackTree({
      id: this.severUserInfo.company_id,
      grade: this.severUserInfo.company_grade,
      name: this.severUserInfo.company_name
    })
  }
}
</script>
<style scoped>
</style>
