<template>
  <div>
    <setRule v-if="tool.checkAuth($route.name,'update')" ref="setRule">
      <el-button slot="save" type="warning" size="small" @click="onSave">保 存</el-button>
    </setRule>
    <div class="my-tabs" >
      <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
        <el-tab-pane label="经销商目录" name="first"></el-tab-pane>
        <el-tab-pane label="业务员目录" name="second"></el-tab-pane>
      </el-tabs>
    </div>
    <div v-show="activeName === 'first'">
      <setAgent ref="setAgent">
        <el-button v-if="tool.checkAuth($route.name,'agent_insert')" slot="add" type="default" size="small" @click="onShow">添 加</el-button>
        <template v-slot:del="scope">
          <del-agent v-if="tool.checkAuth($route.name,'agent_delete')" :data="scope.data.data" @onSuccess="onSuccess"></del-agent>
        </template>
      </setAgent>
      <selectAgent ref="selectAgent" @onSuccess="onSuccess"></selectAgent>
    </div>
    <div v-show="activeName === 'second'">
      <setSaler ref="setSaler">
        <el-button v-if="tool.checkAuth($route.name,'agent_insert')" slot="add" type="default" size="small" @click="onSalerShow">添 加</el-button>
        <template v-slot:del="scope">
          <del-saler v-if="tool.checkAuth($route.name,'agent_delete')" :data="scope.data.data" @onSuccess="onSalerSuccess"></del-saler>
        </template>
      </setSaler>
      <selectSaler ref="selectSaler" @onSuccess="onSalerSuccess"></selectSaler>
    </div>
  </div>
</template>

<script>
import setRule from './modules/setRule.vue'
import setAgent from './modules/setAgent.vue'
import selectAgent from './modules/select_agent.vue'
import delAgent from './modules/del_agent.vue'

import setSaler from './modules/setSaler.vue'
import selectSaler from './modules/select_saler.vue'
import delSaler from './modules/del_saler.vue'

export default {
  data () {
    return {
      activeName:'first'
    }
  },
  components:{
    setRule,
    setAgent,
    selectAgent,
    delAgent,
    setSaler,
    selectSaler,
    delSaler
  },
  methods:{
    onSave () {
      this.$refs['setRule'].updateOrderclueruleMain()
    },
    onShow () {
      this.$refs['selectAgent'].onShow()
    },
    onSalerShow () {
      this.$refs['selectSaler'].onShow()
    },
    onSuccess () {
      this.$refs['setAgent'].listData()
    },
    onSalerSuccess () {
      this.$refs['setSaler'].listData()
    },
    handleClick () {}
  }
}

</script>
<style>
</style>