<template>
  <div>
    <add v-if="tool.checkAuth($route.name,'agent_update') && !detail" class="normal-margin" @onSuccess="onSuccess"></add>
    <tableLayout :layout="tablecols" :data="list" :custom="true" height="calc(100vh - 495px)">
      <template v-slot:customcol="scope">
        <p>{{scope.column.data[scope.column.columnname]}}</p>
      </template>
      <template v-slot:opreation="scope">
        <edit v-if="tool.checkAuth($route.name,'agent_update')" :data="scope.data" @onSuccess="onSuccess"></edit>
        <ondel v-if="tool.checkAuth($route.name,'agent_update')" :data="scope.data" @onSuccess="onSuccess"></ondel>
      </template>
    </tableLayout>
  </div>
</template>

<script>
import add from './modules/add.vue'
import ondel from './modules/del.vue'
import edit from './modules/edit.vue'

export default {
  props:['data'],
  data () {
    return {
      list:[]
    }
  },
  components:{
    add,
    ondel,
    edit
  },
  props:['detail'],
  methods:{
    async query_areascope () {
      const res = await this.$api.requested({
        "classname": "webmanage.sale.agentscope.agentscope",
        "method": "query_areascope",
        "content": {
          "sa_agentsid":this.$route.query.id
        }
      })
      this.list = res.data
    },
    onSuccess () {
      this.query_areascope()
    }
  },
  mounted () {
    this.query_areascope()
  },
  created () {
    // 获取角色表结构
    this.tablecols = this.tool.tabelCol(this.$route.name)['saleScopeTable'].tablecols
    if(this.detail) this.tablecols.pop()
  }
}

</script>
<style>
</style>