This commit is contained in:
wangxiaoxian 2026-03-04 15:41:35 +08:00
parent 70ef728405
commit 0a839183bc
12 changed files with 46 additions and 51 deletions

View File

@ -4,6 +4,7 @@ import { get, post, put, del } from './request';
// 区域管理API // 区域管理API
export const regionApi = { export const regionApi = {
getAll: () => get('/regions'), getAll: () => get('/regions'),
list: (params = {}) => get('/regions/list', params),
getById: (id) => get(`/regions/${id}`), getById: (id) => get(`/regions/${id}`),
create: (data) => post('/regions', data), create: (data) => post('/regions', data),
update: (id, data) => put(`/regions/${id}`, data), update: (id, data) => put(`/regions/${id}`, data),
@ -13,6 +14,7 @@ export const regionApi = {
// 公寓管理API // 公寓管理API
export const apartmentApi = { export const apartmentApi = {
getAll: (params = {}) => get('/apartments', params), getAll: (params = {}) => get('/apartments', params),
list: (params = {}) => get('/apartments/list', params),
getById: (id) => get(`/apartments/${id}`), getById: (id) => get(`/apartments/${id}`),
create: (data) => post('/apartments', data), create: (data) => post('/apartments', data),
update: (id, data) => put(`/apartments/${id}`, data), update: (id, data) => put(`/apartments/${id}`, data),
@ -22,6 +24,7 @@ export const apartmentApi = {
// 房间管理API // 房间管理API
export const roomApi = { export const roomApi = {
getAll: (params = {}) => get('/rooms', params), getAll: (params = {}) => get('/rooms', params),
list: (params = {}) => get('/rooms/list', params),
getById: (id) => get(`/rooms/${id}`), getById: (id) => get(`/rooms/${id}`),
create: (data) => post('/rooms', data), create: (data) => post('/rooms', data),
update: (id, data) => put(`/rooms/${id}`, data), update: (id, data) => put(`/rooms/${id}`, data),
@ -31,6 +34,7 @@ export const roomApi = {
// 租客管理API // 租客管理API
export const tenantApi = { export const tenantApi = {
getAll: () => get('/tenants'), getAll: () => get('/tenants'),
list: (params = {}) => get('/tenants/list', params),
getById: (id) => get(`/tenants/${id}`), getById: (id) => get(`/tenants/${id}`),
create: (data) => post('/tenants', data), create: (data) => post('/tenants', data),
update: (id, data) => put(`/tenants/${id}`, data), update: (id, data) => put(`/tenants/${id}`, data),
@ -49,6 +53,7 @@ export const contractApi = {
// 租房管理API // 租房管理API
export const rentalApi = { export const rentalApi = {
getAll: (params = {}) => get('/rentals', params), getAll: (params = {}) => get('/rentals', params),
list: (params = {}) => get('/rentals/list', params),
getById: (id) => get(`/rentals/${id}`), getById: (id) => get(`/rentals/${id}`),
create: (data) => post('/rentals', data), create: (data) => post('/rentals', data),
update: (id, data) => put(`/rentals/${id}`, data), update: (id, data) => put(`/rentals/${id}`, data),
@ -67,6 +72,7 @@ export const statisticsApi = {
// 水费管理API // 水费管理API
export const waterBillApi = { export const waterBillApi = {
getAll: (params = {}) => get('/water-bills', params), getAll: (params = {}) => get('/water-bills', params),
list: (params = {}) => get('/water-bills/list', params),
getById: (id) => get(`/water-bills/${id}`), getById: (id) => get(`/water-bills/${id}`),
create: (data) => post('/water-bills', data), create: (data) => post('/water-bills', data),
update: (id, data) => put(`/water-bills/${id}`, data), update: (id, data) => put(`/water-bills/${id}`, data),

View File

@ -62,7 +62,7 @@ export default {
methods: { methods: {
async loadRegions() { async loadRegions() {
try { try {
const response = await regionApi.getAll() const response = await regionApi.list()
this.regions = response this.regions = response
} catch (error) { } catch (error) {
this.$message.error('加载区域数据失败') this.$message.error('加载区域数据失败')

View File

@ -64,7 +64,7 @@ export default {
methods: { methods: {
async loadRegions() { async loadRegions() {
try { try {
const response = await regionApi.getAll() const response = await regionApi.list()
this.regions = response this.regions = response
} catch (error) { } catch (error) {
this.$message.error('加载区域数据失败') this.$message.error('加载区域数据失败')

View File

@ -87,7 +87,7 @@ export default {
methods: { methods: {
async loadTenants() { async loadTenants() {
try { try {
const response = await tenantApi.getAll() const response = await tenantApi.list()
this.tenants = response this.tenants = response
} catch (error) { } catch (error) {
this.$message.error('加载租客数据失败') this.$message.error('加载租客数据失败')
@ -95,7 +95,7 @@ export default {
}, },
async loadRooms() { async loadRooms() {
try { try {
const response = await roomApi.getAll() const response = await roomApi.list()
this.rooms = response this.rooms = response
} catch (error) { } catch (error) {
this.$message.error('加载房间数据失败') this.$message.error('加载房间数据失败')

View File

@ -89,7 +89,7 @@ export default {
methods: { methods: {
async loadTenants() { async loadTenants() {
try { try {
const response = await tenantApi.getAll() const response = await tenantApi.list()
this.tenants = response this.tenants = response
} catch (error) { } catch (error) {
this.$message.error('加载租客数据失败') this.$message.error('加载租客数据失败')
@ -97,7 +97,7 @@ export default {
}, },
async loadRooms() { async loadRooms() {
try { try {
const response = await roomApi.getAll() const response = await roomApi.list()
this.rooms = response this.rooms = response
} catch (error) { } catch (error) {
this.$message.error('加载房间数据失败') this.$message.error('加载房间数据失败')

View File

@ -81,7 +81,7 @@ export default {
methods: { methods: {
async loadRegions() { async loadRegions() {
try { try {
const response = await regionApi.getAll() const response = await regionApi.list()
this.regions = response this.regions = response
} catch (error) { } catch (error) {
this.$message.error('加载区域数据失败') this.$message.error('加载区域数据失败')

View File

@ -83,7 +83,7 @@ export default {
methods: { methods: {
async loadRegions() { async loadRegions() {
try { try {
const response = await regionApi.getAll() const response = await regionApi.list()
this.regions = response this.regions = response
} catch (error) { } catch (error) {
this.$message.error('加载区域数据失败') this.$message.error('加载区域数据失败')

View File

@ -140,14 +140,14 @@ export default {
methods: { methods: {
async loadData() { async loadData() {
try { try {
// // 使list
const [roomsResponse, apartmentsResponse] = await Promise.all([ const [roomsResponse, apartmentsResponse] = await Promise.all([
roomApi.getAll(), roomApi.list(),
apartmentApi.getAll() apartmentApi.list()
]) ])
this.rooms = roomsResponse.data || roomsResponse this.rooms = roomsResponse
this.apartments = apartmentsResponse.data || apartmentsResponse this.apartments = apartmentsResponse
// URLroomId // URLroomId
const roomId = this.$route.query.roomId ? Number(this.$route.query.roomId) : null const roomId = this.$route.query.roomId ? Number(this.$route.query.roomId) : null

View File

@ -16,7 +16,7 @@
</div> </div>
</template> </template>
<div v-loading="isLoading" class="room-info-section"> <div v-loading="isLoading" class="room-info-section">
<h2>{{ room.apartmentName }} - {{ room.roomNumber }}</h2> <h2>{{ room.Apartment.name }} - {{ room.roomNumber }}</h2>
<div class="room-basic-info"> <div class="room-basic-info">
<div class="info-item"> <div class="info-item">
<span class="label">面积:</span> <span class="label">面积:</span>
@ -199,7 +199,7 @@
</template> </template>
<script> <script>
import { roomApi, rentalApi, apartmentApi, waterBillApi } from '../../api/api' import { roomApi, rentalApi, waterBillApi } from '../../api/api'
export default { export default {
name: 'RentalDetail', name: 'RentalDetail',
@ -207,7 +207,6 @@ export default {
return { return {
room: {}, room: {},
rentals: [], rentals: [],
apartments: [],
rentalHistory: [], rentalHistory: [],
waterBills: [], waterBills: [],
isLoading: false, isLoading: false,
@ -289,16 +288,6 @@ export default {
const roomResponse = await roomApi.getById(roomId) const roomResponse = await roomApi.getById(roomId)
this.room = roomResponse this.room = roomResponse
//
const apartmentsResponse = await apartmentApi.getAll()
this.apartments = apartmentsResponse.data || apartmentsResponse
//
if (this.room.apartmentId) {
const apartment = this.apartments.find(a => a.id == this.room.apartmentId)
this.room.apartmentName = apartment ? apartment.name : ''
}
// //
await this.loadRentalHistory() await this.loadRentalHistory()

View File

@ -108,10 +108,10 @@ export default {
methods: { methods: {
async loadData() { async loadData() {
try { try {
// // 使list
const [roomsResponse, apartmentsResponse] = await Promise.all([ const [roomsResponse, apartmentsResponse] = await Promise.all([
roomApi.getAll(), roomApi.list(),
apartmentApi.getAll() apartmentApi.list()
]) ])
this.rooms = roomsResponse this.rooms = roomsResponse

View File

@ -127,8 +127,8 @@ export default {
methods: { methods: {
async loadApartments() { async loadApartments() {
try { try {
const response = await apartmentApi.getAll() const response = await apartmentApi.list()
this.apartments = response.data || response this.apartments = response
} catch (error) { } catch (error) {
this.$message.error('加载公寓数据失败') this.$message.error('加载公寓数据失败')
} }

View File

@ -133,8 +133,8 @@ export default {
methods: { methods: {
async loadApartments() { async loadApartments() {
try { try {
const response = await apartmentApi.getAll() const response = await apartmentApi.list()
this.apartments = response.data || response this.apartments = response
} catch (error) { } catch (error) {
this.$message.error('加载公寓数据失败') this.$message.error('加载公寓数据失败')
} }