修改维修工单选择客户时的搜索功能
This commit is contained in:
parent
2197c2a78e
commit
af2c3f27ea
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-select v-model="userSelected" clearable filterable >
|
<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-option v-for="user in userList" :key="user.id" :label="user.cusName + ' ' + user.phoneNumber" :value="user.id"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -10,11 +10,11 @@ import {getCustomerMainPage} from "@/api/base/customer";
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "UserChoose",
|
name: "UserChoose",
|
||||||
props:{
|
props: {
|
||||||
value:{
|
value: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
inList:{
|
inList: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: null,
|
default: null,
|
||||||
required: false
|
required: false
|
||||||
@ -24,28 +24,30 @@ export default {
|
|||||||
return {
|
return {
|
||||||
userList: [],
|
userList: [],
|
||||||
userSelected: undefined,
|
userSelected: undefined,
|
||||||
queryParams:{
|
queryParams: {
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
pageSize: 10
|
pageSize: 10,
|
||||||
|
cusName: null,
|
||||||
|
phoneNumber: null,
|
||||||
},
|
},
|
||||||
total: 0
|
total: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
watch: {
|
||||||
userSelected(val){
|
userSelected(val) {
|
||||||
if (val){
|
if (val) {
|
||||||
const user = this.userList.find(item => item.id === val)
|
const user = this.userList.find(item => item.id === val)
|
||||||
this.$emit("input", user)
|
this.$emit("input", user)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
value(val){
|
value(val) {
|
||||||
this.userSelected = val ? val.id : null
|
this.userSelected = val ? val.id : null
|
||||||
},
|
},
|
||||||
inList(val){
|
inList(val) {
|
||||||
if (val){
|
if (val) {
|
||||||
// 不存在才添加
|
// 不存在才添加
|
||||||
const flag = this.userList.findIndex(item => item.id === val.id)
|
const flag = this.userList.findIndex(item => item.id === val.id)
|
||||||
if (flag > 0){
|
if (flag > 0) {
|
||||||
this.userList.splice(flag, 1)
|
this.userList.splice(flag, 1)
|
||||||
}
|
}
|
||||||
this.userList.unshift(val)
|
this.userList.unshift(val)
|
||||||
@ -57,10 +59,18 @@ export default {
|
|||||||
this.listCustomer()
|
this.listCustomer()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async listCustomer(){
|
async listCustomer() {
|
||||||
const res = await getCustomerMainPage(this.queryParams)
|
const res = await getCustomerMainPage(this.queryParams)
|
||||||
this.userList = res.data.records
|
this.userList = res.data.records
|
||||||
this.total = res.data.total
|
this.total = res.data.total
|
||||||
|
},
|
||||||
|
handleQuery(data) {
|
||||||
|
if (/^\d+$/.test(data)) {
|
||||||
|
this.queryParams.phoneNumber = data
|
||||||
|
} else {
|
||||||
|
this.queryParams.cusName = data
|
||||||
|
}
|
||||||
|
this.listCustomer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user