保存进度!

This commit is contained in:
2023-06-07 17:19:47 +08:00
parent 2f3e22fb3e
commit 664c2335ca
5 changed files with 136 additions and 10 deletions

View File

@@ -32,4 +32,81 @@ interface RankingListResponse
renewalRankintList: RankingListItem[];
};
export { type RankingListRequest, type RankingListResponse };
/**
* 请求坐席排行榜。
* @param reqParam 请求参数
* @param rander 保存请求结果的回调函数
* @returns 返回RankingListResponse对象里面包含请求状态和数据。
*/
function requestRankingList( reqParam: RankingListRequest, rander: any ): void // eslint-disable-line
{
// let attachingRankingList: RankingListItem[];
// let renewalRankintList: RankingListItem[];
const rankingListResponse: RankingListResponse = {
success: false,
message: "",
departmentCode: reqParam.departmentCode,
year: reqParam.year,
month: reqParam.month,
attachingRankingList: [],
renewalRankintList: [],
};
instance.request(
{
method: "post",
url: API_URL.URL_RANKINGLIST,
data: reqParam,
})
.then(( response ) =>
{
const data: RankingListResponse = response.data as RankingListResponse;
rankingListResponse.success = data.success ?? false;
rankingListResponse.message = data.message ?? "";
rankingListResponse.departmentCode = data.departmentCode ?? "";
rankingListResponse.year = data.year ?? "";
rankingListResponse.month = data.month ?? "";
// 遍历排行榜元素
for ( const item of ( data.attachingRankingList ?? [] )) // eslint-disable-line
{
const index: number = item.index ?? -1;
if ( index === -1 )
{
continue;
}
rankingListResponse.attachingRankingList.push( item );
}
for ( const item of ( data.renewalRankintList ?? [] )) // eslint-disable-line
{
const index: number = item.index ?? -1;
if ( index === -1 )
{
continue;
}
rankingListResponse.renewalRankintList.push( item );
}
// 调用回调函数保存数据
rander( rankingListResponse );
console.log( data );
})
.catch(( error ) =>
{
console.log( error );
});
}
export {
type RankingListRequest,
type RankingListResponse,
requestRankingList
};