修改维修工单选择客户时的搜索功能

This commit is contained in:
xiaofajia 2024-10-31 14:06:03 +08:00
parent 2197c2a78e
commit af2c3f27ea

View File

@ -1,6 +1,6 @@
<template>
<el-select v-model="userSelected" clearable filterable >
<el-option v-for="user in userList" :key="user.id" :label="user.cusName + ' ' + user.phoneNumber" :value="user.id" />
<el-select v-model="userSelected" clearable filterable :filter-method="handleQuery">
<el-option v-for="user in userList" :key="user.id" :label="user.cusName + ' ' + user.phoneNumber" :value="user.id"/>
</el-select>
</template>
@ -10,11 +10,11 @@ import {getCustomerMainPage} from "@/api/base/customer";
export default {
name: "UserChoose",
props:{
value:{
props: {
value: {
type: Object,
},
inList:{
inList: {
type: Object,
default: null,
required: false
@ -24,28 +24,30 @@ export default {
return {
userList: [],
userSelected: undefined,
queryParams:{
queryParams: {
pageNo: 1,
pageSize: 10
pageSize: 10,
cusName: null,
phoneNumber: null,
},
total: 0
}
},
watch:{
userSelected(val){
if (val){
watch: {
userSelected(val) {
if (val) {
const user = this.userList.find(item => item.id === val)
this.$emit("input", user)
}
},
value(val){
value(val) {
this.userSelected = val ? val.id : null
},
inList(val){
if (val){
inList(val) {
if (val) {
//
const flag = this.userList.findIndex(item => item.id === val.id)
if (flag > 0){
if (flag > 0) {
this.userList.splice(flag, 1)
}
this.userList.unshift(val)
@ -57,10 +59,18 @@ export default {
this.listCustomer()
},
methods: {
async listCustomer(){
async listCustomer() {
const res = await getCustomerMainPage(this.queryParams)
this.userList = res.data.records
this.total = res.data.total
},
handleQuery(data) {
if (/^\d+$/.test(data)) {
this.queryParams.phoneNumber = data
} else {
this.queryParams.cusName = data
}
this.listCustomer()
}
}
}