rentease-app/api/rental.js

84 lines
1.9 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 租房管理模块 API
*/
import { get, post, put, del } from '../utils/request.js'
export default {
/**
* 获取租房记录列表
* @param {Object} params - 查询参数
* @param {number} params.page - 页码
* @param {number} params.pageSize - 每页数量
* @param {number} params.apartmentId - 公寓ID
* @param {number} params.roomId - 房间ID
* @param {string} params.renterName - 租客姓名
* @param {string} params.status - 状态
* @param {string} params.paymentType - 付租方式
* @returns {Promise}
*/
getList(params = {}) {
return get('/rentals', params)
},
/**
* 获取租房记录详情
* @param {number} id - 记录ID
* @returns {Promise}
*/
getDetail(id) {
return get(`/rentals/${id}`)
},
/**
* 创建租房记录
* @param {Object} data - 租房数据
* @returns {Promise}
*/
create(data) {
return post('/rentals', data)
},
/**
* 创建租房记录(同时创建租客)
* @param {Object} data - 租房数据包含renter信息
* @returns {Promise}
*/
createWithRenter(data) {
return post('/rentals/with-renter', data)
},
/**
* 更新租房记录
* @param {number} id - 记录ID
* @param {Object} data - 租房数据
* @returns {Promise}
*/
update(id, data) {
return put(`/rentals/${id}`, data)
},
/**
* 删除租房记录
* @param {number} id - 记录ID
* @returns {Promise}
*/
delete(id) {
return del(`/rentals/${id}`)
},
/**
* 办理退租
* @param {number} id - 租赁记录ID
* @param {Object} data - 退租数据
* @param {number} data.waterMeterEnd - 水表最终读数
* @param {number} data.electricityMeterEnd - 电表最终读数
* @param {number} data.refundDeposit - 退还押金
* @param {string} data.remark - 退租备注
* @returns {Promise}
*/
terminate(id, data) {
return post(`/rentals/${id}/terminate`, data)
}
}