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

63 lines
1.2 KiB
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)">
<el-option v-for="staff in staffList" :key="staff.id" :label="staff.name + ' ' + staff.tel" :value="staff.id"/>
2024-09-11 18:49:43 +08:00
</el-select>
</template>
<script>
import {getStaffList} from "@/api/company/staff";
export default {
name: "StaffChoose",
2024-09-20 21:21:39 +08:00
props: {
2024-09-14 18:27:01 +08:00
value: {
type: Object,
2024-09-25 15:42:23 +08:00
},
isGet:{
type: String,
default: '',
required: false
2024-09-14 18:27:01 +08:00
}
},
2024-09-11 18:49:43 +08:00
data() {
return {
staffList: [],
staffSelected: undefined,
2024-09-20 21:21:39 +08:00
hasRequest: false
2024-09-11 18:49:43 +08:00
}
},
2024-09-20 21:21:39 +08:00
watch: {
2024-09-11 18:49:43 +08:00
staffSelected(val) {
const staff = this.staffList.find(item => item.id === val);
2024-09-14 18:27:01 +08:00
this.$emit("input", staff);
},
2024-09-20 21:21:39 +08:00
value(newVal) {
if (newVal) {
2024-09-14 18:27:01 +08:00
this.staffSelected = newVal.id
2024-09-20 21:21:39 +08:00
} else {
2024-09-14 18:27:01 +08:00
this.staffSelected = null
}
2024-09-20 21:21:39 +08:00
},
2024-09-11 18:49:43 +08:00
},
mounted() {
this.listStaff()
},
methods: {
async listStaff() {
try {
2024-09-25 15:42:23 +08:00
if (!this.isGet) return;
2024-09-11 18:49:43 +08:00
const res = await getStaffList()
this.staffList = res.data
2024-09-20 21:21:39 +08:00
this.hasRequest = true
2024-09-11 18:49:43 +08:00
} catch {
}
}
}
}
</script>
<style scoped lang="scss">
</style>