This commit is contained in:
parent
70ef728405
commit
0a839183bc
|
|
@ -4,6 +4,7 @@ import { get, post, put, del } from './request';
|
|||
// 区域管理API
|
||||
export const regionApi = {
|
||||
getAll: () => get('/regions'),
|
||||
list: (params = {}) => get('/regions/list', params),
|
||||
getById: (id) => get(`/regions/${id}`),
|
||||
create: (data) => post('/regions', data),
|
||||
update: (id, data) => put(`/regions/${id}`, data),
|
||||
|
|
@ -13,6 +14,7 @@ export const regionApi = {
|
|||
// 公寓管理API
|
||||
export const apartmentApi = {
|
||||
getAll: (params = {}) => get('/apartments', params),
|
||||
list: (params = {}) => get('/apartments/list', params),
|
||||
getById: (id) => get(`/apartments/${id}`),
|
||||
create: (data) => post('/apartments', data),
|
||||
update: (id, data) => put(`/apartments/${id}`, data),
|
||||
|
|
@ -22,6 +24,7 @@ export const apartmentApi = {
|
|||
// 房间管理API
|
||||
export const roomApi = {
|
||||
getAll: (params = {}) => get('/rooms', params),
|
||||
list: (params = {}) => get('/rooms/list', params),
|
||||
getById: (id) => get(`/rooms/${id}`),
|
||||
create: (data) => post('/rooms', data),
|
||||
update: (id, data) => put(`/rooms/${id}`, data),
|
||||
|
|
@ -31,6 +34,7 @@ export const roomApi = {
|
|||
// 租客管理API
|
||||
export const tenantApi = {
|
||||
getAll: () => get('/tenants'),
|
||||
list: (params = {}) => get('/tenants/list', params),
|
||||
getById: (id) => get(`/tenants/${id}`),
|
||||
create: (data) => post('/tenants', data),
|
||||
update: (id, data) => put(`/tenants/${id}`, data),
|
||||
|
|
@ -49,6 +53,7 @@ export const contractApi = {
|
|||
// 租房管理API
|
||||
export const rentalApi = {
|
||||
getAll: (params = {}) => get('/rentals', params),
|
||||
list: (params = {}) => get('/rentals/list', params),
|
||||
getById: (id) => get(`/rentals/${id}`),
|
||||
create: (data) => post('/rentals', data),
|
||||
update: (id, data) => put(`/rentals/${id}`, data),
|
||||
|
|
@ -67,6 +72,7 @@ export const statisticsApi = {
|
|||
// 水费管理API
|
||||
export const waterBillApi = {
|
||||
getAll: (params = {}) => get('/water-bills', params),
|
||||
list: (params = {}) => get('/water-bills/list', params),
|
||||
getById: (id) => get(`/water-bills/${id}`),
|
||||
create: (data) => post('/water-bills', data),
|
||||
update: (id, data) => put(`/water-bills/${id}`, data),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ export default {
|
|||
methods: {
|
||||
async loadRegions() {
|
||||
try {
|
||||
const response = await regionApi.getAll()
|
||||
const response = await regionApi.list()
|
||||
this.regions = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载区域数据失败')
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ export default {
|
|||
methods: {
|
||||
async loadRegions() {
|
||||
try {
|
||||
const response = await regionApi.getAll()
|
||||
const response = await regionApi.list()
|
||||
this.regions = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载区域数据失败')
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ export default {
|
|||
methods: {
|
||||
async loadTenants() {
|
||||
try {
|
||||
const response = await tenantApi.getAll()
|
||||
const response = await tenantApi.list()
|
||||
this.tenants = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载租客数据失败')
|
||||
|
|
@ -95,7 +95,7 @@ export default {
|
|||
},
|
||||
async loadRooms() {
|
||||
try {
|
||||
const response = await roomApi.getAll()
|
||||
const response = await roomApi.list()
|
||||
this.rooms = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载房间数据失败')
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export default {
|
|||
methods: {
|
||||
async loadTenants() {
|
||||
try {
|
||||
const response = await tenantApi.getAll()
|
||||
const response = await tenantApi.list()
|
||||
this.tenants = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载租客数据失败')
|
||||
|
|
@ -97,7 +97,7 @@ export default {
|
|||
},
|
||||
async loadRooms() {
|
||||
try {
|
||||
const response = await roomApi.getAll()
|
||||
const response = await roomApi.list()
|
||||
this.rooms = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载房间数据失败')
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ export default {
|
|||
methods: {
|
||||
async loadRegions() {
|
||||
try {
|
||||
const response = await regionApi.getAll()
|
||||
const response = await regionApi.list()
|
||||
this.regions = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载区域数据失败')
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ export default {
|
|||
methods: {
|
||||
async loadRegions() {
|
||||
try {
|
||||
const response = await regionApi.getAll()
|
||||
const response = await regionApi.list()
|
||||
this.regions = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载区域数据失败')
|
||||
|
|
|
|||
|
|
@ -140,14 +140,14 @@ export default {
|
|||
methods: {
|
||||
async loadData() {
|
||||
try {
|
||||
// 并行加载房间和公寓数据
|
||||
// 并行加载房间和公寓数据(使用list接口)
|
||||
const [roomsResponse, apartmentsResponse] = await Promise.all([
|
||||
roomApi.getAll(),
|
||||
apartmentApi.getAll()
|
||||
roomApi.list(),
|
||||
apartmentApi.list()
|
||||
])
|
||||
|
||||
this.rooms = roomsResponse.data || roomsResponse
|
||||
this.apartments = apartmentsResponse.data || apartmentsResponse
|
||||
this.rooms = roomsResponse
|
||||
this.apartments = apartmentsResponse
|
||||
|
||||
// 检查URL参数中是否有roomId
|
||||
const roomId = this.$route.query.roomId ? Number(this.$route.query.roomId) : null
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<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="info-item">
|
||||
<span class="label">面积:</span>
|
||||
|
|
@ -199,7 +199,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { roomApi, rentalApi, apartmentApi, waterBillApi } from '../../api/api'
|
||||
import { roomApi, rentalApi, waterBillApi } from '../../api/api'
|
||||
|
||||
export default {
|
||||
name: 'RentalDetail',
|
||||
|
|
@ -207,7 +207,6 @@ export default {
|
|||
return {
|
||||
room: {},
|
||||
rentals: [],
|
||||
apartments: [],
|
||||
rentalHistory: [],
|
||||
waterBills: [],
|
||||
isLoading: false,
|
||||
|
|
@ -289,16 +288,6 @@ export default {
|
|||
const roomResponse = await roomApi.getById(roomId)
|
||||
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()
|
||||
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ export default {
|
|||
methods: {
|
||||
async loadData() {
|
||||
try {
|
||||
// 并行加载房间和公寓数据
|
||||
// 并行加载房间和公寓数据(使用list接口)
|
||||
const [roomsResponse, apartmentsResponse] = await Promise.all([
|
||||
roomApi.getAll(),
|
||||
apartmentApi.getAll()
|
||||
roomApi.list(),
|
||||
apartmentApi.list()
|
||||
])
|
||||
|
||||
this.rooms = roomsResponse
|
||||
|
|
|
|||
|
|
@ -127,8 +127,8 @@ export default {
|
|||
methods: {
|
||||
async loadApartments() {
|
||||
try {
|
||||
const response = await apartmentApi.getAll()
|
||||
this.apartments = response.data || response
|
||||
const response = await apartmentApi.list()
|
||||
this.apartments = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载公寓数据失败')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,8 +133,8 @@ export default {
|
|||
methods: {
|
||||
async loadApartments() {
|
||||
try {
|
||||
const response = await apartmentApi.getAll()
|
||||
this.apartments = response.data || response
|
||||
const response = await apartmentApi.list()
|
||||
this.apartments = response
|
||||
} catch (error) {
|
||||
this.$message.error('加载公寓数据失败')
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue