/** * 投递记录 API 服务 * 封装投递记录相关的API调用 */ import apiClient from '../utils/api.js'; class ApplyRecordsAPI { /** * 获取投递记录列表 * @param {Object} params - 查询参数 * @param {Object} params.seachOption - 搜索条件 * @param {Object} params.pageOption - 分页选项 * @returns {Promise} */ async getList(params = {}) { try { const result = await apiClient.post('/apply/list', params); return result; } catch (error) { console.error('获取投递记录列表失败:', error); throw error; } } /** * 获取投递统计 * @param {String} snCode - 设备SN码(可选) * @returns {Promise} */ async getStatistics(snCode = null) { try { const params = snCode ? { sn_code: snCode } : {}; const result = await apiClient.get('/apply/statistics', params); return result; } catch (error) { console.error('获取投递统计失败:', error); throw error; } } /** * 获取近7天投递趋势数据 * @param {String} snCode - 设备SN码(可选) * @returns {Promise} */ async getTrendData(snCode = null) { try { const params = snCode ? { sn_code: snCode } : {}; const result = await apiClient.get('/apply/trend', params); return result; } catch (error) { console.error('获取投递趋势数据失败:', error); throw error; } } /** * 获取投递记录详情 * @param {String|Number} recordId - 投递记录ID(可以是 id 或 applyId) * @returns {Promise} */ async getDetail(recordId) { try { // 使用 id 参数名(数据库主键字段) const result = await apiClient.get('/apply/detail', { id: recordId }); return result; } catch (error) { console.error('获取投递记录详情失败:', error); throw error; } } } export default new ApplyRecordsAPI();