diff --git a/src/views/repair/Components/UserChoose.vue b/src/views/repair/Components/UserChoose.vue index 9223c73..7abb4e8 100644 --- a/src/views/repair/Components/UserChoose.vue +++ b/src/views/repair/Components/UserChoose.vue @@ -1,6 +1,6 @@ @@ -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() } } }