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

56 lines
1.0 KiB
Vue
Raw Normal View History

2024-09-12 18:29:04 +08:00
<template>
2024-09-13 18:31:13 +08:00
<el-select v-model="userSelected" clearable filterable >
<el-option v-for="user in userList" :key="user.id" :label="user.cusName" :value="user.id" />
2024-09-12 18:29:04 +08:00
</el-select>
</template>
<script>
2024-09-13 18:31:13 +08:00
2024-09-19 19:46:32 +08:00
import {getCustomerMainPage} from "@/api/base/customer";
2024-09-13 18:31:13 +08:00
2024-09-12 18:29:04 +08:00
export default {
name: "UserChoose",
2024-09-19 19:46:32 +08:00
props:{
value:{
type: Object,
}
},
2024-09-12 18:29:04 +08:00
data() {
return {
userList: [],
2024-09-13 18:31:13 +08:00
userSelected: undefined,
2024-09-19 19:46:32 +08:00
queryParams:{
pageNo: 1,
pageSize: 10
},
total: 0
2024-09-13 18:31:13 +08:00
}
},
watch:{
userSelected(val){
2024-09-21 20:42:56 +08:00
if (val){
const user = this.userList.find(item => item.id === val)
this.$emit("input", user)
}
2024-09-19 19:46:32 +08:00
},
value(val){
this.userSelected = val ? val.id : null
2024-09-12 18:29:04 +08:00
}
},
2024-09-13 18:31:13 +08:00
mounted() {
this.listCustomer()
},
methods: {
async listCustomer(){
2024-09-19 19:46:32 +08:00
const res = await getCustomerMainPage(this.queryParams)
this.userList = res.data.records
this.total = res.data.total
2024-09-13 18:31:13 +08:00
}
}
2024-09-12 18:29:04 +08:00
}
</script>
<style scoped lang="scss">
</style>