OfficeSystem/api/dashboard.js
2025-11-19 10:47:28 +08:00

102 lines
2.9 KiB
JavaScript
Raw 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
*/
/**
* 获取仪表板简要信息
* @param {Object} params 请求参数
* @param {string} params.joinUserId 用户ID
* @param {string[]} params.keys 需要获取的数据键名数组
* @returns {Promise} 返回仪表板简要信息
*/
export const getDashboardBrief = ({ joinUserId, keys }) => {
// 构建查询参数字符串
let params=[]
if (joinUserId) {
params = [`joinUserId=${joinUserId}`];
}
if (keys && Array.isArray(keys)) {
keys.forEach((key) => {
params.push(`keys=${encodeURIComponent(key)}`);
});
}
const queryString = params.join('&');
return uni.$uv.http.get(`dashboard/brief?${queryString}`, {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 获取客户统计排行榜
* @returns {Promise} 返回排行榜数据,包含 today、week、month 三个时间段的数据
*/
export const getCustomerStatistics = (params = {}) => {
// 期望传入为数组: [start, end] 或 [day, day]
const dateRange = Array.isArray(params) ? params : [];
const query =
dateRange.length > 0
? `?${dateRange.map(d => `queryDateRange=${encodeURIComponent(d)}`).join('&')}`
: '';
return uni.$uv.http.get(`/dashboard/customer/statistics${query}`, {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 获取公告列表
* @param {Object} params 请求参数
* @param {number} params.pageNum 页码
* @param {number} params.pageSize 每页数量
* @param {string} params.title 标题(搜索)
* @param {string} params.userName 创建人(搜索)
* @param {string} params.level 重要程度(筛选)
* @param {boolean} params.top 是否置顶(筛选)
* @param {string} params.orderByColumn 排序字段
* @param {string} params.isAsc 排序方式ascending/descending
* @returns {Promise} 返回公告列表
*/
export const getNoticeList = (params = {}) => {
const queryParams = [];
if (params.pageNum !== undefined) {
queryParams.push(`pageNum=${params.pageNum}`);
}
if (params.pageSize !== undefined) {
queryParams.push(`pageSize=${params.pageSize}`);
}
if (params.title) {
queryParams.push(`title=${encodeURIComponent(params.title)}`);
}
if (params.userName) {
queryParams.push(`userName=${encodeURIComponent(params.userName)}`);
}
if (params.level) {
queryParams.push(`level=${encodeURIComponent(params.level)}`);
}
if (params.top !== undefined && params.top !== null && params.top !== '') {
queryParams.push(`top=${params.top}`);
}
if (params.orderByColumn) {
queryParams.push(`orderByColumn=${encodeURIComponent(params.orderByColumn)}`);
}
if (params.isAsc) {
queryParams.push(`isAsc=${encodeURIComponent(params.isAsc)}`);
}
const queryString = queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
return uni.$uv.http.get(`bst/notice/list${queryString}`, {
custom: {
auth: true // 启用 token 认证
}
});
};