<template>
  <div>
    
    <div style="margin-top:6px">
    <el-transfer
      v-model="depts"
      :data="deptOptions"
      :titles="['单位列表', '选择的单位']"
      :props="{ key : 'id' , label: 'name' }"
    >
    <span slot-scope="{ option }">{{ option.sort }} - {{ option.name }}</span>
    </el-transfer>
    </div>
    <div style="text-align: right">
      <el-button type="primary" @click="confirm()">确认</el-button>
    </div>
  </div>
</template>
<style lang="scss">
.el-transfer-panel {
  width: 470px;
}
.el-transfer__buttons {
  padding: 0 2px;
  .el-button {
    display: block;
  }
}

</style>
<script>
import { getOrgList } from "@/api/org";
export default {
  name: "leaderinit",
  data() {
    return {
      depts: [],
      deptOptions: [],
    };
  },
  created() {
    this.getOrgList();
  },
  methods: {
    getOrgList() {
      getOrgList({can_supervision:true}).then((res) => {
        this.deptOptions = res.data;
      });
    },
    confirm(){
        if( this.depts.length>0){
            var data = {
            depts:this.depts
        }
        this.$emit('handleChose', data)
        }else{
            this.$message.error('请选择单位!')
        }
        
    }
  },
};
</script>