OfficeSystem/api/dashboard.js
2025-11-27 10:14:55 +08:00

136 lines
3.6 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 { buildUrl } from '@/utils/url'
/**
* 获取仪表板简要信息
* @param {Object} params 请求参数
* @param {string} params.joinUserId 用户ID
* @param {string[]} params.keys 需要获取的数据键名数组
* @returns {Promise} 返回仪表板简要信息
*/
export const getDashboardBrief = ({ joinUserId, keys }) => {
const params = {};
if (joinUserId) {
params.joinUserId = joinUserId;
}
if (keys && Array.isArray(keys)) {
params.keys = keys;
}
const url = buildUrl('dashboard/brief', params);
return uni.$uv.http.get(url, {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 获取客户统计排行榜
* @returns {Promise} 返回排行榜数据,包含 today、week、month 三个时间段的数据
*/
export const getCustomerStatistics = (params = {}) => {
// 期望传入为数组: [start, end] 或 [day, day]
const dateRange = Array.isArray(params) ? params : [];
const queryParams = dateRange.length > 0 ? { queryDateRange: dateRange } : {};
const url = buildUrl('/dashboard/customer/statistics', queryParams);
return uni.$uv.http.get(url, {
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 url = buildUrl('bst/notice/list', params);
return uni.$uv.http.get(url, {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 获取公告详情
* @param {string} id 公告ID
* @returns {Promise} 返回公告详情
*/
export const getNoticeDetail = (id) => {
return uni.$uv.http.get(`bst/notice/${id}`, {
custom: {
auth: true // 启用 token 认证
}
});
};
/**
* 新增公告
* @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
}
});
};
/**
* 修改公告
* 对应接口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
}
});
};