35a00c34
wuxw
支持车辆改业主功能
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
<template>
<el-dialog
:title="$t('listOwnerCar.changeOwner')"
:visible.sync="visible"
width="800px"
:close-on-click-modal="false"
@close="handleClose"
>
<div>
<el-form inline>
<el-form-item :label="$t('listOwnerCar.ownerName')">
<el-input
v-model.trim="searchForm.ownerName"
:placeholder="$t('listOwnerCar.inputOwnerName')"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">
{{ $t('listOwnerCar.query') }}
</el-button>
</el-form-item>
</el-form>
<el-table
class="mt-10"
:data="ownerList"
border
v-loading="loading"
height="400px"
>
<el-table-column :label="$t('listOwnerCar.select')" width="80" align="center">
<template slot-scope="scope">
<el-radio v-model="selectedOwnerId" :label="scope.row.ownerId">
</el-radio>
</template>
</el-table-column>
<el-table-column prop="name" :label="$t('listOwnerCar.ownerName')" align="center" />
<el-table-column prop="link" :label="$t('listOwnerCar.phoneNumber')" align="center" />
</el-table>
<el-pagination
class="mt-10"
:current-page="currentPage"
:page-size="pageSize"
:page-sizes="[10, 20, 30, 50]"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
/>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="visible = false">{{ $t('listOwnerCar.cancel') }}</el-button>
<el-button type="primary" @click="handleConfirm">{{ $t('listOwnerCar.confirm') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { queryOwners, changeCarOwner } from '@/api/owner/ownerApi'
export default {
name: 'ChangeOwnerDialog',
data() {
return {
visible: false,
currentCar: null,
searchForm: {
ownerName: ''
},
ownerList: [],
loading: false,
selectedOwnerId: '',
currentPage: 1,
pageSize: 10,
total: 0
}
},
methods: {
open(car) {
this.currentCar = car
this.visible = true
this.selectedOwnerId = ''
this.searchForm.ownerName = ''
this.ownerList = []
this.currentPage = 1
this.total = 0
this.handleQuery()
},
async handleQuery() {
this.loading = true
try {
const params = {
name: this.searchForm.ownerName || '',
page: this.currentPage,
row: this.pageSize,
personRole: '', // 如需只查业主,可传 '1'
roomName: '',
link: '',
idCard: '',
personType: ''
}
const res = await queryOwners(params)
// res.data 为后端返回的业主列表
this.ownerList = res.data || []
this.total = res.total || 0
} catch (error) {
console.error('查询业主列表失败:', error)
this.$message.error(this.$t('listOwnerCar.changeOwnerQueryFailed'))
} finally {
this.loading = false
}
},
handleSizeChange(val) {
this.pageSize = val
this.currentPage = 1
this.handleQuery()
},
handleCurrentChange(val) {
this.currentPage = val
this.handleQuery()
},
async handleConfirm() {
if (!this.selectedOwnerId) {
this.$message.warning(this.$t('listOwnerCar.changeOwnerSelectTip'))
return
}
try {
const payload = {
memberId: this.currentCar.memberId,
newOwnerId: this.selectedOwnerId
}
await changeCarOwner(payload)
this.$message.success(this.$t('common.operationSuccess'))
this.visible = false
this.$emit('success')
} catch (error) {
console.error('修改业主失败:', error)
this.$message.error(this.$t('listOwnerCar.changeOwnerFailed'))
}
},
handleClose() {
this.currentCar = null
this.selectedOwnerId = ''
this.searchForm.ownerName = ''
this.ownerList = []
this.currentPage = 1
this.total = 0
}
}
}
</script>
|