From af2c3f27eada850cdd9ab09b93cbbecaa73166de Mon Sep 17 00:00:00 2001 From: xiaofajia <1665375861@qq.com> Date: Thu, 31 Oct 2024 14:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=B4=E4=BF=AE=E5=B7=A5?= =?UTF-8?q?=E5=8D=95=E9=80=89=E6=8B=A9=E5=AE=A2=E6=88=B7=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/repair/Components/UserChoose.vue | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) 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() } } }