166 lines
4.5 KiB
JavaScript
166 lines
4.5 KiB
JavaScript
/**
|
||
* 仪表板相关 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 认证
|
||
}
|
||
});
|
||
};
|
||
|
||
/**
|
||
* 获取公告详情
|
||
* @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
|
||
}
|
||
});
|
||
};
|
||
|