61 lines
1.2 KiB
Vue
Raw Normal View History

2025-01-26 21:07:26 +08:00
<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 { getCourseList } from '@/api/course.js'
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
}
},
mounted() {
getCourseList({
current: 1,
size: 9999,
status: 3,
userType: this.user.user.userType,
deptId: this.deptId
}).then(res => {
this.options = res.data.list
})
}
}
</script>