<template>
  <el-dialog
    center
    title="客服"
    :visible.sync="show"
    width="30%">
    <div style="width: 100%;min-height: 200px;text-align: center">
      <el-select filterable v-model="service">
        <el-option v-for="(item,index) in customerServiceList" :key="index" :label="item.nickname" :value="item.id"></el-option>
      </el-select>
    </div>
    <span slot="footer" class="dialog-footer">
    <el-button >取 消</el-button>
    <el-button type="primary" @click="submit">确 定</el-button>
  </span>
  </el-dialog>
</template>

<script>
import {listServiceUser} from "@/api/system/user";
import {handOverCustomer} from "@/api/ecw/customer";

export default {
  name: "transferCustomer",
  props:{
    show:{
      type:Boolean ,
      default:false
    },
    customerIds:[Array,String],
    tableName:String
  },
  created() {
    listServiceUser().then(r=>{
      this.customerServiceList = r.data;
    })
  },
  computed:{
    getCustomerIds(){
      if(this.customerIds instanceof Array) return this.customerIds
      else return this.customerIds.split(',')
    }
  },
  data(){
    return {
      customerServiceList:[],
      service:'',
    }
  },
  methods:{
    submit(){
      if(!this.service){
        return this.$message.warning('请选择客户经理！');
      }
      handOverCustomer({
        customerServiceId:this.service,
        customerIdList:this.getCustomerIds
      }).then(r=>{
        if(r.code === 0){
           this.$emit('update:show',false)
           this.$emit('update:customerIds',[])
           this.$message.success('用户批量转移成功！')
        }
      })
    },
  }
}
</script>

<style scoped>

</style>
