lanan-system-vue/src/views/repair/Components/StaffChoose.vue

55 lines
1009 B
Vue
Raw Normal View History

2024-09-11 18:49:43 +08:00
<template>
2024-09-20 16:21:46 +08:00
<el-select v-model="staffSelected" clearable filterable @blur="$emit('input-blur', $event)">
2024-09-11 18:49:43 +08:00
<el-option v-for="staff in staffList" :key="staff.id" :label="staff.name" :value="staff.id"/>
</el-select>
</template>
<script>
import {getStaffList} from "@/api/company/staff";
export default {
name: "StaffChoose",
2024-09-14 18:27:01 +08:00
props:{
value: {
type: Object,
}
},
2024-09-11 18:49:43 +08:00
data() {
return {
staffList: [],
staffSelected: undefined,
}
},
watch:{
staffSelected(val) {
const staff = this.staffList.find(item => item.id === val);
2024-09-14 18:27:01 +08:00
this.$emit("input", staff);
},
value(newVal){
if (newVal){
this.staffSelected = newVal.id
}else {
this.staffSelected = null
}
2024-09-11 18:49:43 +08:00
}
},
mounted() {
this.listStaff()
},
methods: {
async listStaff() {
try {
const res = await getStaffList()
this.staffList = res.data
} catch {
}
}
}
}
</script>
<style scoped lang="scss">
</style>