保存进度!
This commit is contained in:
		@@ -49,31 +49,32 @@ interface MenusalArchievementItem // 每月业绩清单的项目
 | 
			
		||||
 */
 | 
			
		||||
function queryDepartmentArchievement( departmentInfo: Department, render: any ): void
 | 
			
		||||
{
 | 
			
		||||
    // 默认的部门业绩对象
 | 
			
		||||
    const archievement: DepartmentArchievement = {
 | 
			
		||||
        success: false,
 | 
			
		||||
        message: "",
 | 
			
		||||
        total_archievement: 0,
 | 
			
		||||
        mensual_archievement_list: [],
 | 
			
		||||
        insurance_renewal_rate: "",
 | 
			
		||||
        attaching_rate: "",
 | 
			
		||||
        leading_reward_gainers: [],
 | 
			
		||||
        advance_reward_gainers: [],
 | 
			
		||||
        backward_list: [],
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    instance.request({
 | 
			
		||||
        method: "post",
 | 
			
		||||
        url: API_URL.URL_DEPARTMENT_ARCHIEVEMENT,
 | 
			
		||||
        data: departmentInfo,
 | 
			
		||||
    })
 | 
			
		||||
        // 请求结束,将请求的结果写入业绩对象,然后调用功能渲染函数。
 | 
			
		||||
        .then(( response ) =>
 | 
			
		||||
        {
 | 
			
		||||
            const archievement: DepartmentArchievement = {
 | 
			
		||||
                success: false,
 | 
			
		||||
                message: "",
 | 
			
		||||
                total_archievement: 0,
 | 
			
		||||
                mensual_archievement_list: [],
 | 
			
		||||
                insurance_renewal_rate: "",
 | 
			
		||||
                attaching_rate: "",
 | 
			
		||||
                leading_reward_gainers: [],
 | 
			
		||||
                advance_reward_gainers: [],
 | 
			
		||||
                backward_list: [],
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            const data = response.data ?? {};
 | 
			
		||||
 | 
			
		||||
            archievement.success = data.success ?? false;
 | 
			
		||||
            archievement.message = data.message ?? "";
 | 
			
		||||
            archievement.message = data.message ?? "服务器没有返回调用结果消息,请检查日志!";
 | 
			
		||||
            archievement.total_archievement = data.total_archievement;
 | 
			
		||||
            // archievement.mensual_archievement_list = data.mensual_archievement_list ?? [];
 | 
			
		||||
            archievement.mensual_archievement_list = [];
 | 
			
		||||
            archievement.insurance_renewal_rate = data.insurance_renewal_rate ?? "0.0";
 | 
			
		||||
            archievement.attaching_rate = data.attaching_rate ?? "0.0";
 | 
			
		||||
@@ -90,12 +91,25 @@ function queryDepartmentArchievement( departmentInfo: Department, render: any ):
 | 
			
		||||
 | 
			
		||||
            console.log( "每月业绩", archievement );
 | 
			
		||||
 | 
			
		||||
            // 渲染数据
 | 
			
		||||
            render( archievement );
 | 
			
		||||
            // 调用渲染函数
 | 
			
		||||
            if ( render !== undefined )
 | 
			
		||||
            {
 | 
			
		||||
                render( archievement );
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
        // 请求失败,将失败原因写入业绩对象,调用渲染函数
 | 
			
		||||
        .catch(( error ) =>
 | 
			
		||||
        {
 | 
			
		||||
            console.log( error );
 | 
			
		||||
            archievement.success = false;
 | 
			
		||||
            archievement.message = String( error );
 | 
			
		||||
 | 
			
		||||
            // 调用渲染函数
 | 
			
		||||
            if ( render !== undefined )
 | 
			
		||||
            {
 | 
			
		||||
                render( archievement );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.log( `queryDepartmentArchievement:查询部门${departmentInfo.departmentCode}业绩失败,原因${error}` );
 | 
			
		||||
        });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -103,7 +117,8 @@ function queryDepartmentArchievement( departmentInfo: Department, render: any ):
 | 
			
		||||
 * 查询坐席的业绩,并调用渲染函数.
 | 
			
		||||
 * 1、请求坐席业绩的数据
 | 
			
		||||
 * 2、对每月业绩清单进行检查,如果有缺少则用0代替,检查的结果是12个月的清单,让调用者自己截断;
 | 
			
		||||
 * 3、将检查后的清单,写入到业绩对象中,只写金额
 | 
			
		||||
 * 3、将检查后的清单,写入到业绩对象中,只写金额;
 | 
			
		||||
 * 4、即使请求失败,也将失败的message写入业绩对象,调用渲染函数;
 | 
			
		||||
 * @param callerInfo 坐席的信息参数,用于请求业绩;
 | 
			
		||||
 * @param render 渲染函数,用业绩对象CallerArchievement作为参数;
 | 
			
		||||
 */
 | 
			
		||||
@@ -114,6 +129,16 @@ function queryCallerArchievement( callerInfo: TelSaler, render: any ): void
 | 
			
		||||
        callName: callerInfo.telSalerName,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // 默认的业绩对象
 | 
			
		||||
    const callArchievement: CallerArchievement = {
 | 
			
		||||
        success: false,
 | 
			
		||||
        message: "",
 | 
			
		||||
        total_archievement: 0,
 | 
			
		||||
        mensual_archievement_list: [],
 | 
			
		||||
        insurance_renewal_rate: "0.0",
 | 
			
		||||
        attaching_rate: "0.0",
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // 发送请求
 | 
			
		||||
    instance.request({
 | 
			
		||||
        method: "post",
 | 
			
		||||
@@ -125,14 +150,12 @@ function queryCallerArchievement( callerInfo: TelSaler, render: any ): void
 | 
			
		||||
        {
 | 
			
		||||
            const data = response.data ?? {};
 | 
			
		||||
 | 
			
		||||
            const callArchievement: CallerArchievement = {
 | 
			
		||||
                success: data.success ?? false,
 | 
			
		||||
                message: data.message ?? "",
 | 
			
		||||
                total_archievement: data.total_archievement ?? 0,
 | 
			
		||||
                mensual_archievement_list: [],
 | 
			
		||||
                insurance_renewal_rate: data.insurance_renewal_rate ?? "0.0",
 | 
			
		||||
                attaching_rate: data.attaching_rate ?? "0.0",
 | 
			
		||||
            };
 | 
			
		||||
            callArchievement.success = data.success ?? false;
 | 
			
		||||
            callArchievement.message = data.message ?? "服务器没有返回调用结果消息,请检查日志!";
 | 
			
		||||
            callArchievement.total_archievement = data.total_archievement ?? 0;
 | 
			
		||||
            callArchievement.mensual_archievement_list = [];
 | 
			
		||||
            callArchievement.insurance_renewal_rate = data.insurance_renewal_rate ?? "0.0";
 | 
			
		||||
            callArchievement.attaching_rate = data.attaching_rate ?? "0.0";
 | 
			
		||||
 | 
			
		||||
            // 检查业绩清单有没有缺漏,缺漏的用0补上
 | 
			
		||||
            const checkedList = checkMensualArchievement( data.mensual_archievement_list );
 | 
			
		||||
@@ -159,9 +182,18 @@ function queryCallerArchievement( callerInfo: TelSaler, render: any ): void
 | 
			
		||||
 | 
			
		||||
            console.log( `queryCallerArchievement查询结果${data}` );
 | 
			
		||||
        })
 | 
			
		||||
        // 请求失败
 | 
			
		||||
        // 请求失败,将失败的原因保存到message属性,调用渲染函数
 | 
			
		||||
        .catch(( error: any ) =>
 | 
			
		||||
        {
 | 
			
		||||
            callArchievement.success = false;
 | 
			
		||||
            callArchievement.message = String( error );
 | 
			
		||||
 | 
			
		||||
            // 调用渲染函数
 | 
			
		||||
            if ( render !== undefined )
 | 
			
		||||
            {
 | 
			
		||||
                render( callArchievement );
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            console.log( `queryCallerArchievement:查询坐席${callerInfo.telSalerCode}业绩失败,原因${error}` );
 | 
			
		||||
        });
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -32,6 +32,9 @@ interface RankingListResponse
 | 
			
		||||
    renewalRateRankingList: RankingListItem[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 判断用的正则表达式
 | 
			
		||||
const regexMonth = "(0[1-9])|(1[0-2])";
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 请求坐席排行榜。
 | 
			
		||||
 * @param reqParam 请求参数
 | 
			
		||||
@@ -53,6 +56,9 @@ function requestRankingList( reqParam: RankingListRequest, rander: any ): void /
 | 
			
		||||
        renewalRateRankingList: [],
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    // 检查请求参数
 | 
			
		||||
    // TODO: 这里要加一个对month的正则表达式验证。
 | 
			
		||||
 | 
			
		||||
    instance.request(
 | 
			
		||||
        {
 | 
			
		||||
            method: "post",
 | 
			
		||||
 
 | 
			
		||||
@@ -89,6 +89,7 @@ import { ElMessage } from "element-plus";
 | 
			
		||||
import
 | 
			
		||||
{
 | 
			
		||||
    type DepartmentArchievement,
 | 
			
		||||
    type CallerArchievement,
 | 
			
		||||
    queryDepartmentArchievement,
 | 
			
		||||
    queryCallerArchievement
 | 
			
		||||
} from "@/utils/archievement.js";
 | 
			
		||||
@@ -135,6 +136,10 @@ export default {
 | 
			
		||||
    setup()
 | 
			
		||||
    {
 | 
			
		||||
        const monthIndex = new Date();
 | 
			
		||||
        const thisMonth: number = monthIndex.getMonth();
 | 
			
		||||
        const thisMonthString = thisMonth > 10 ? String( thisMonth ): "0" + String( thisMonth );
 | 
			
		||||
        const thisYear: number = monthIndex.getFullYear();
 | 
			
		||||
        const thisYearString: string = String( thisYear );
 | 
			
		||||
        const numInChinese = [
 | 
			
		||||
            "一",
 | 
			
		||||
            "二",
 | 
			
		||||
@@ -166,7 +171,7 @@ export default {
 | 
			
		||||
        });
 | 
			
		||||
        let timerHandler = 0;
 | 
			
		||||
 | 
			
		||||
        const getTotalArchievement = computed(() =>
 | 
			
		||||
        const getTotalArchievement = computed(():string =>
 | 
			
		||||
        {
 | 
			
		||||
            const cnyFormat = new Intl.NumberFormat( "zh-cn", {
 | 
			
		||||
                style: "currency",
 | 
			
		||||
@@ -178,13 +183,28 @@ export default {
 | 
			
		||||
            return archievement;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        // 保存业绩数据
 | 
			
		||||
        const applyDepartmentArchievementData = ( data: DepartmentArchievement ) =>
 | 
			
		||||
        /**
 | 
			
		||||
         * 将请求函数获取的部门业绩数据,渲染到页面上。
 | 
			
		||||
         * @param data DepartmentArchievementl类型的部门业绩数据对象
 | 
			
		||||
         */
 | 
			
		||||
        const applyDepartmentArchievementData = ( data: DepartmentArchievement ): void =>
 | 
			
		||||
        {
 | 
			
		||||
            console.log( "部门业绩数据", data );
 | 
			
		||||
            // console.log( "部门业绩数据", data );
 | 
			
		||||
 | 
			
		||||
            ui.chartData = data.mensual_archievement_list;
 | 
			
		||||
            ui.totalArchievement = data.total_archievement;
 | 
			
		||||
            // 检查请求是否成功
 | 
			
		||||
            if ( data.success !== true )
 | 
			
		||||
            {
 | 
			
		||||
                // 失败就提示消息,然后退出
 | 
			
		||||
                ElMessage({
 | 
			
		||||
                    message: data.message,
 | 
			
		||||
                    type: "error",
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // ui.chartData = data.mensual_archievement_list;
 | 
			
		||||
            // ui.totalArchievement = data.total_archievement;
 | 
			
		||||
            ui.attaching_rate = data.attaching_rate;
 | 
			
		||||
            ui.insurance_renewal_rate = data.insurance_renewal_rate;
 | 
			
		||||
            ui.leading_reward_gainers = data.leading_reward_gainers;
 | 
			
		||||
@@ -201,6 +221,32 @@ export default {
 | 
			
		||||
            }, 0 );
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        const applyCallerArchievementData = ( data: CallerArchievement ): void =>
 | 
			
		||||
        {
 | 
			
		||||
            // 检查请求是否成功
 | 
			
		||||
            if ( data.success !== true )
 | 
			
		||||
            {
 | 
			
		||||
                // 失败就提示消息,然后退出
 | 
			
		||||
                ElMessage({
 | 
			
		||||
                    message: data.message,
 | 
			
		||||
                    type: "error",
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            ui.chartData = data.mensual_archievement_list.slice( 0, thisMonth-1 );
 | 
			
		||||
            ui.totalArchievement = data.total_archievement;
 | 
			
		||||
 | 
			
		||||
            console.log( "业绩清单", ui.chartData );
 | 
			
		||||
 | 
			
		||||
            ui.showUI = false;
 | 
			
		||||
            setTimeout(() =>
 | 
			
		||||
            {
 | 
			
		||||
                ui.showUI = true;
 | 
			
		||||
            }, 0 );
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        const applyRankingListData = ( data: RankingListResponse ): void =>
 | 
			
		||||
        {
 | 
			
		||||
            ui.attachingRankingList = data.attachingRateRankingList;
 | 
			
		||||
@@ -240,7 +286,7 @@ export default {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /**
 | 
			
		||||
         * 刷新页面
 | 
			
		||||
         * 用于定时对页面进行刷新,其中会请求最新的业绩数据。
 | 
			
		||||
         */
 | 
			
		||||
        const refresh = () =>
 | 
			
		||||
        {
 | 
			
		||||
@@ -251,11 +297,12 @@ export default {
 | 
			
		||||
 | 
			
		||||
            const rankinglistRequest: RankingListRequest = {
 | 
			
		||||
                departmentCode: callerInfo.departmentCode,
 | 
			
		||||
                year: "2023",
 | 
			
		||||
                month: "06",
 | 
			
		||||
                year: thisYearString,
 | 
			
		||||
                month: thisMonthString,
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            queryDepartmentArchievement( deparmentInfo, applyDepartmentArchievementData );
 | 
			
		||||
            queryCallerArchievement( callerInfo, applyCallerArchievementData );
 | 
			
		||||
            requestRankingList( rankinglistRequest, applyRankingListData );
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user