Commit 35a00c34068f415659b4a8af6924890e7a512a9f
1 parent
83338dbe
支持车辆改业主功能
Showing
4 changed files
with
211 additions
and
3 deletions
src/api/owner/ownerApi.js
| ... | ... | @@ -85,6 +85,27 @@ export function deleteOwner(data) { |
| 85 | 85 | }) |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | +// 修改车辆所属业主 | |
| 89 | +export function changeCarOwner(data) { | |
| 90 | + return new Promise((resolve, reject) => { | |
| 91 | + data.communityId = getCommunityId() | |
| 92 | + request({ | |
| 93 | + url: '/owner.changeCarOwner', | |
| 94 | + method: 'post', | |
| 95 | + data | |
| 96 | + }).then(response => { | |
| 97 | + const res = response.data | |
| 98 | + if (res.code == 0) { | |
| 99 | + resolve(res) | |
| 100 | + } else { | |
| 101 | + reject(new Error(res.msg || '修改车辆业主失败')) | |
| 102 | + } | |
| 103 | + }).catch(error => { | |
| 104 | + reject(error) | |
| 105 | + }) | |
| 106 | + }) | |
| 107 | +} | |
| 108 | + | |
| 88 | 109 | // 上传图片 |
| 89 | 110 | export function uploadImage(data) { |
| 90 | 111 | return new Promise((resolve, reject) => { | ... | ... |
src/components/car/changeOwnerDialog.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + :title="$t('listOwnerCar.changeOwner')" | |
| 4 | + :visible.sync="visible" | |
| 5 | + width="800px" | |
| 6 | + :close-on-click-modal="false" | |
| 7 | + @close="handleClose" | |
| 8 | + > | |
| 9 | + <div> | |
| 10 | + <el-form inline> | |
| 11 | + <el-form-item :label="$t('listOwnerCar.ownerName')"> | |
| 12 | + <el-input | |
| 13 | + v-model.trim="searchForm.ownerName" | |
| 14 | + :placeholder="$t('listOwnerCar.inputOwnerName')" | |
| 15 | + clearable | |
| 16 | + style="width: 220px" | |
| 17 | + /> | |
| 18 | + </el-form-item> | |
| 19 | + <el-form-item> | |
| 20 | + <el-button type="primary" @click="handleQuery"> | |
| 21 | + {{ $t('listOwnerCar.query') }} | |
| 22 | + </el-button> | |
| 23 | + </el-form-item> | |
| 24 | + </el-form> | |
| 25 | + | |
| 26 | + <el-table | |
| 27 | + class="mt-10" | |
| 28 | + :data="ownerList" | |
| 29 | + border | |
| 30 | + v-loading="loading" | |
| 31 | + height="400px" | |
| 32 | + > | |
| 33 | + <el-table-column :label="$t('listOwnerCar.select')" width="80" align="center"> | |
| 34 | + <template slot-scope="scope"> | |
| 35 | + <el-radio v-model="selectedOwnerId" :label="scope.row.ownerId"> | |
| 36 | + | |
| 37 | + </el-radio> | |
| 38 | + </template> | |
| 39 | + </el-table-column> | |
| 40 | + <el-table-column prop="name" :label="$t('listOwnerCar.ownerName')" align="center" /> | |
| 41 | + <el-table-column prop="link" :label="$t('listOwnerCar.phoneNumber')" align="center" /> | |
| 42 | + </el-table> | |
| 43 | + | |
| 44 | + <el-pagination | |
| 45 | + class="mt-10" | |
| 46 | + :current-page="currentPage" | |
| 47 | + :page-size="pageSize" | |
| 48 | + :page-sizes="[10, 20, 30, 50]" | |
| 49 | + layout="total, sizes, prev, pager, next, jumper" | |
| 50 | + :total="total" | |
| 51 | + @size-change="handleSizeChange" | |
| 52 | + @current-change="handleCurrentChange" | |
| 53 | + /> | |
| 54 | + </div> | |
| 55 | + | |
| 56 | + <span slot="footer" class="dialog-footer"> | |
| 57 | + <el-button @click="visible = false">{{ $t('listOwnerCar.cancel') }}</el-button> | |
| 58 | + <el-button type="primary" @click="handleConfirm">{{ $t('listOwnerCar.confirm') }}</el-button> | |
| 59 | + </span> | |
| 60 | + </el-dialog> | |
| 61 | +</template> | |
| 62 | + | |
| 63 | +<script> | |
| 64 | +import { queryOwners, changeCarOwner } from '@/api/owner/ownerApi' | |
| 65 | + | |
| 66 | +export default { | |
| 67 | + name: 'ChangeOwnerDialog', | |
| 68 | + data() { | |
| 69 | + return { | |
| 70 | + visible: false, | |
| 71 | + currentCar: null, | |
| 72 | + searchForm: { | |
| 73 | + ownerName: '' | |
| 74 | + }, | |
| 75 | + ownerList: [], | |
| 76 | + loading: false, | |
| 77 | + selectedOwnerId: '', | |
| 78 | + currentPage: 1, | |
| 79 | + pageSize: 10, | |
| 80 | + total: 0 | |
| 81 | + } | |
| 82 | + }, | |
| 83 | + methods: { | |
| 84 | + open(car) { | |
| 85 | + this.currentCar = car | |
| 86 | + this.visible = true | |
| 87 | + this.selectedOwnerId = '' | |
| 88 | + this.searchForm.ownerName = '' | |
| 89 | + this.ownerList = [] | |
| 90 | + this.currentPage = 1 | |
| 91 | + this.total = 0 | |
| 92 | + this.handleQuery() | |
| 93 | + }, | |
| 94 | + | |
| 95 | + async handleQuery() { | |
| 96 | + this.loading = true | |
| 97 | + try { | |
| 98 | + const params = { | |
| 99 | + name: this.searchForm.ownerName || '', | |
| 100 | + page: this.currentPage, | |
| 101 | + row: this.pageSize, | |
| 102 | + personRole: '', // 如需只查业主,可传 '1' | |
| 103 | + roomName: '', | |
| 104 | + link: '', | |
| 105 | + idCard: '', | |
| 106 | + personType: '' | |
| 107 | + } | |
| 108 | + const res = await queryOwners(params) | |
| 109 | + // res.data 为后端返回的业主列表 | |
| 110 | + this.ownerList = res.data || [] | |
| 111 | + this.total = res.total || 0 | |
| 112 | + } catch (error) { | |
| 113 | + console.error('查询业主列表失败:', error) | |
| 114 | + this.$message.error(this.$t('listOwnerCar.changeOwnerQueryFailed')) | |
| 115 | + } finally { | |
| 116 | + this.loading = false | |
| 117 | + } | |
| 118 | + }, | |
| 119 | + | |
| 120 | + handleSizeChange(val) { | |
| 121 | + this.pageSize = val | |
| 122 | + this.currentPage = 1 | |
| 123 | + this.handleQuery() | |
| 124 | + }, | |
| 125 | + | |
| 126 | + handleCurrentChange(val) { | |
| 127 | + this.currentPage = val | |
| 128 | + this.handleQuery() | |
| 129 | + }, | |
| 130 | + | |
| 131 | + async handleConfirm() { | |
| 132 | + if (!this.selectedOwnerId) { | |
| 133 | + this.$message.warning(this.$t('listOwnerCar.changeOwnerSelectTip')) | |
| 134 | + return | |
| 135 | + } | |
| 136 | + try { | |
| 137 | + const payload = { | |
| 138 | + memberId: this.currentCar.memberId, | |
| 139 | + newOwnerId: this.selectedOwnerId | |
| 140 | + } | |
| 141 | + await changeCarOwner(payload) | |
| 142 | + this.$message.success(this.$t('common.operationSuccess')) | |
| 143 | + this.visible = false | |
| 144 | + this.$emit('success') | |
| 145 | + } catch (error) { | |
| 146 | + console.error('修改业主失败:', error) | |
| 147 | + this.$message.error(this.$t('listOwnerCar.changeOwnerFailed')) | |
| 148 | + } | |
| 149 | + }, | |
| 150 | + | |
| 151 | + handleClose() { | |
| 152 | + this.currentCar = null | |
| 153 | + this.selectedOwnerId = '' | |
| 154 | + this.searchForm.ownerName = '' | |
| 155 | + this.ownerList = [] | |
| 156 | + this.currentPage = 1 | |
| 157 | + this.total = 0 | |
| 158 | + } | |
| 159 | + } | |
| 160 | +} | |
| 161 | +</script> | |
| 162 | + | ... | ... |
src/views/car/listOwnerCarLang.js
| ... | ... | @@ -88,6 +88,14 @@ export const messages = { |
| 88 | 88 | iotSyncDetail: 'IoT sync details', |
| 89 | 89 | confirmRelease: 'Are you sure to release the car?', |
| 90 | 90 | parkingLot: 'Parking Lot', |
| 91 | + changeOwner: 'Change Owner', | |
| 92 | + ownerName: 'Owner Name', | |
| 93 | + phoneNumber: 'Phone Number', | |
| 94 | + select: 'Select', | |
| 95 | + changeOwnerQueryFailed: 'Failed to query owner list, please try again later', | |
| 96 | + changeOwnerSelectTip: 'Please select an owner first', | |
| 97 | + changeOwnerTodoTip: 'The change owner operation will be completed after backend API is ready', | |
| 98 | + changeOwnerFailed: 'Failed to change owner, please try again later', | |
| 91 | 99 | } |
| 92 | 100 | }, |
| 93 | 101 | zh: { |
| ... | ... | @@ -179,6 +187,14 @@ export const messages = { |
| 179 | 187 | iotSyncDetail: '同步物联网详情', |
| 180 | 188 | confirmRelease: '确认释放车辆?', |
| 181 | 189 | parkingLot: '车场', |
| 190 | + changeOwner: '修改业主', | |
| 191 | + ownerName: '业主名称', | |
| 192 | + phoneNumber: '手机号', | |
| 193 | + select: '选择', | |
| 194 | + changeOwnerQueryFailed: '查询业主列表失败,请稍后重试', | |
| 195 | + changeOwnerSelectTip: '请先选择业主', | |
| 196 | + changeOwnerTodoTip: '后端接口开发完成后,将在此完成修改业主操作', | |
| 197 | + changeOwnerFailed: '修改业主失败,请稍后重试', | |
| 182 | 198 | } |
| 183 | 199 | } |
| 184 | 200 | } |
| 185 | 201 | \ No newline at end of file | ... | ... |
src/views/car/listOwnerCarList.vue
| 1 | -<template> | |
| 1 | +<template> | |
| 2 | 2 | <div class="list-owner-car-container"> |
| 3 | 3 | <el-row :gutter="20"> |
| 4 | 4 | <el-col :span="3"> |
| ... | ... | @@ -131,7 +131,7 @@ |
| 131 | 131 | </template> |
| 132 | 132 | </el-table-column> |
| 133 | 133 | <el-table-column prop="remark" :label="$t('listOwnerCar.remark')" align="center" /> |
| 134 | - <el-table-column :label="$t('listOwnerCar.operation')" align="center" width="280"> | |
| 134 | + <el-table-column :label="$t('listOwnerCar.operation')" align="center" width="360"> | |
| 135 | 135 | <template slot-scope="scope"> |
| 136 | 136 | <el-button v-if="scope.row.state !== '3003' && hasPrivilege('502023032855861676')" size="mini" |
| 137 | 137 | @click="deleteCarParkingSpace(scope.row)"> |
| ... | ... | @@ -148,6 +148,9 @@ |
| 148 | 148 | @click="openEditOwnerCar(scope.row)"> |
| 149 | 149 | {{ $t('listOwnerCar.modify') }} |
| 150 | 150 | </el-button> |
| 151 | + <el-button size="mini" type="primary" @click="openChangeOwnerDialog(scope.row)"> | |
| 152 | + {{ $t('listOwnerCar.changeOwner') }} | |
| 153 | + </el-button> | |
| 151 | 154 | <el-button v-if="hasPrivilege('502023032822121680')" size="mini" type="danger" |
| 152 | 155 | @click="openDelOwnerCarModel(scope.row)"> |
| 153 | 156 | {{ $t('listOwnerCar.delete') }} |
| ... | ... | @@ -166,6 +169,7 @@ |
| 166 | 169 | <import-owner-car ref="importOwnerCar" @success="listOwnerCarData" /> |
| 167 | 170 | <edit-car ref="editCar" @success="listOwnerCarData" /> |
| 168 | 171 | <delete-owner-car ref="deleteOwnerCar" @success="listOwnerCarData" /> |
| 172 | + <change-owner-dialog ref="changeOwnerDialog" @success="listOwnerCarData" /> | |
| 169 | 173 | </div> |
| 170 | 174 | </template> |
| 171 | 175 | |
| ... | ... | @@ -174,13 +178,14 @@ import { queryOwnerCars, exportData, deleteCarParkingSpace } from '@/api/car/lis |
| 174 | 178 | import ImportOwnerCar from '@/components/car/importOwnerCar' |
| 175 | 179 | import EditCar from '@/components/car/editCar' |
| 176 | 180 | import DeleteOwnerCar from '@/components/car/deleteOwnerCar' |
| 181 | +import ChangeOwnerDialog from '@/components/car/changeOwnerDialog' | |
| 177 | 182 | import { getDict } from '@/api/community/communityApi' |
| 178 | 183 | import { getCommunityId } from '@/api/community/communityApi' |
| 179 | 184 | |
| 180 | 185 | |
| 181 | 186 | export default { |
| 182 | 187 | name: 'ListOwnerCar', |
| 183 | - components: { ImportOwnerCar, EditCar, DeleteOwnerCar }, | |
| 188 | + components: { ImportOwnerCar, EditCar, DeleteOwnerCar, ChangeOwnerDialog }, | |
| 184 | 189 | data() { |
| 185 | 190 | return { |
| 186 | 191 | loading: false, |
| ... | ... | @@ -319,6 +324,10 @@ export default { |
| 319 | 324 | this.$router.push(`/views/car/carDetail?memberId=${car.carId}&tab=carDetailMember`) |
| 320 | 325 | }, |
| 321 | 326 | |
| 327 | + openChangeOwnerDialog(car) { | |
| 328 | + this.$refs.changeOwnerDialog.open(car) | |
| 329 | + }, | |
| 330 | + | |
| 322 | 331 | getCarState(car) { |
| 323 | 332 | if (car.state === '3003') { |
| 324 | 333 | return this.$t('listOwnerCar.expired') | ... | ... |