<template>
  <div style="display:inline;margin-left:10px">
    <el-popconfirm
      :title="`确定${data.status === '启用'?'停用':'启用'}吗？`"
      @confirm="startAgent">
      <el-button size="small" :type="type" :icon="icon?icon:data.status==='启用'?'el-icon-circle-close':'el-icon-circle-check'" slot="reference">{{data.status==='启用'?'停用':'启用'}}</el-button>
    </el-popconfirm>
  </div>
</template>

<script>
export default {
  props:['data','type','icon'],
  methods:{
    startAgent () {
      console.log(this.data)
      this.$api.requested({
        "classname": "webmanage.sale.agents.agents",
        "method": "changeStatus",
        "content": {
          "sa_agentsids": [this.data.sa_agentsid],
          "status":this.data.status==='启用'?'停用':'启用'
        }
      }).then(res=>{
        this.tool.showMessage(res)
        this.$emit('onSuccess')
      })
    },
  }
}

</script>
<style>
</style>