<template>
  <el-select v-model="mValue" v-bind="$attrs" style="width: 100%;" v-on="$listeners">
    <el-option v-for="item in mOptions" :key="item.id" :label="item.name" :value="item.id" />
  </el-select>
</template>

<script>
import { mapGetters } from 'vuex'
import {
  courseInfoList
} from '@/api/videoLive'
export default {
  name: 'CourseSelect',
  props: {
    value: {
      type: [String, Array],
      default: ''
    },
    deptId: {
      type: [String, Number],
      default: undefined
    },
    advisorId: {
      type: [String, Number],
      default: undefined
    }
  },
  data() {
    return {
      options: []
    }
  },
  computed: {
    ...mapGetters(['user']),
    mValue: {
      get() {
        return this.value
      },
      set(val) {
        this.$emit('update:value', val)
      }
    },
    mOptions() {
      if (this.advisorId) {
        return this.options.filter(item => item.advisorId === this.advisorId)
      }
      return this.options
    }
  },
  methods: {
    getList(){
      courseInfoList({
        current: 1,
        size: 9999,
        status: 3,
        userType: this.user.user.userType,
        deptId: this.deptId
        }).then(res => {
          this.options = res.data.list
        })
    }
  },
mounted() {
  this.getList()
  // courseInfoList({
  //       current: 1,
  //       size: 9999,
  //       status: 3,
  //       userType: this.user.user.userType,
  //       deptId: this.deptId
  //   }).then(res => {
  //     this.options = res.data.list
  //   })
  }
}
</script>
