OfficeSystem/api/dashboard.js

136 lines
3.6 KiB
JavaScript
Raw Permalink Normal View History

2025-11-07 11:18:43 +08:00
/**
* 仪表板相关 API
*/
2025-11-27 10:14:55 +08:00
import { buildUrl } from '@/utils/url'
2025-11-07 11:18:43 +08:00
/**
* 获取仪表板简要信息
* @param {Object} params 请求参数
* @param {string} params.joinUserId 用户ID
* @param {string[]} params.keys 需要获取的数据键名数组
* @returns {Promise} 返回仪表板简要信息
*/
export const getDashboardBrief = ({ joinUserId, keys }) => {
2025-11-27 10:14:55 +08:00
const params = {};
if (joinUserId) {
2025-11-27 10:14:55 +08:00
params.joinUserId = joinUserId;
}
2025-11-07 11:18:43 +08:00
if (keys && Array.isArray(keys)) {
2025-11-27 10:14:55 +08:00
params.keys = keys;
2025-11-07 11:18:43 +08:00
}
2025-11-27 10:14:55 +08:00
const url = buildUrl('dashboard/brief', params);
return uni.$uv.http.get(url, {
2025-11-07 11:18:43 +08:00
custom: {
auth: true // 启用 token 认证
}
});
};
2025-11-13 10:21:17 +08:00
/**
* 获取客户统计排行榜
* @returns {Promise} 返回排行榜数据包含 todayweekmonth 三个时间段的数据
*/
2025-11-13 18:00:07 +08:00
export const getCustomerStatistics = (params = {}) => {
// 期望传入为数组: [start, end] 或 [day, day]
const dateRange = Array.isArray(params) ? params : [];
2025-11-27 10:14:55 +08:00
const queryParams = dateRange.length > 0 ? { queryDateRange: dateRange } : {};
const url = buildUrl('/dashboard/customer/statistics', queryParams);
2025-11-13 18:00:07 +08:00
2025-11-27 10:14:55 +08:00
return uni.$uv.http.get(url, {
2025-11-13 10:21:17 +08:00
custom: {
auth: true // 启用 token 认证
}
});
};
2025-11-19 10:34:14 +08:00
/**
* 获取公告列表
* @param {Object} params 请求参数
* @param {number} params.pageNum 页码
* @param {number} params.pageSize 每页数量
2025-11-19 10:47:28 +08:00
* @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
2025-11-19 10:34:14 +08:00
* @returns {Promise} 返回公告列表
*/
export const getNoticeList = (params = {}) => {
2025-11-27 10:14:55 +08:00
const url = buildUrl('bst/notice/list', params);
2025-11-19 10:34:14 +08:00
2025-11-27 10:14:55 +08:00
return uni.$uv.http.get(url, {
2025-11-19 10:34:14 +08:00
custom: {
auth: true // 启用 token 认证
}
});
};
2025-11-19 11:06:04 +08:00
/**
* 获取公告详情
* @param {string} id 公告ID
* @returns {Promise} 返回公告详情
*/
export const getNoticeDetail = (id) => {
return uni.$uv.http.get(`bst/notice/${id}`, {
custom: {
auth: true // 启用 token 认证
}
});
};
2025-11-19 15:09:27 +08:00
/**
* 新增公告
* @param {Object} payload 公告数据
* @param {string} payload.title 标题
* @param {string} payload.content 内容
* @param {string} payload.level 重要程度1-一般 2-重要 3-紧急
* @param {boolean} payload.top 是否置顶
* @param {string} payload.type 类型1-通知 2-公告
* @param {Array<string>} payload.receiveUserIds 接收用户ID集合
* @param {Array<string>} payload.receiveDeptIds 接收部门ID集合
* @param {string|Array} payload.attaches 附件可为字符串或数组
* @returns {Promise}
*/
export const createNotice = (payload) => {
return uni.$uv.http.post('bst/notice', payload, {
custom: {
auth: true
}
});
};
2025-11-19 16:13:12 +08:00
/**
* 修改公告
* 对应接口PUT bst/notice
* @param {Object} payload 公告数据必须包含 id
* @returns {Promise}
*/
export const updateNotice = (payload) => {
return uni.$uv.http.put('bst/notice', payload, {
custom: {
auth: true
}
});
};
/**
* 删除公告
* 对应接口DELETE bst/notice/{id}
* 支持单个 ID 或多个 ID数组逗号分隔
* @param {string|string[]} ids 公告ID或ID数组
* @returns {Promise}
*/
export const deleteNotice = (ids) => {
const idParam = Array.isArray(ids) ? ids.join(',') : ids;
return uni.$uv.http.delete(`bst/notice/${idParam}`, {},{
custom: {
auth: true
}
});
};