508 lines
14 KiB
Vue
Raw Normal View History

2023-03-03 16:08:27 +08:00
<!--
* @Author: Kane
* @Date: 2023-03-03 14:38:07
* @LastEditors: Kane
* @FilePath: /task_schedule/src/views/DesktopArchievement.vue
2023-03-30 18:29:54 +08:00
* @Description: 桌面霸屏的主组件
2023-03-17 14:40:04 +08:00
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
2023-03-03 16:08:27 +08:00
-->
<template>
2023-03-21 18:01:05 +08:00
<div
2023-05-29 00:15:18 +08:00
v-if="ui.showUI"
class="view-wrapper"
tabindex="0"
@keyup.esc="logoutDesktopArchievement()"
2023-03-21 18:01:05 +08:00
>
2023-05-29 00:15:18 +08:00
<div class="center-wrapper">
<span class="slogan">对标先进&nbsp;比学赶超</span>
<div class="total-archievement-wrapper">
2023-08-25 20:47:36 +08:00
<span>我的车险业绩</span>
2023-05-29 00:15:18 +08:00
<span>{{ getTotalArchievement }}</span>
</div>
<div class="archievement-wrapper">
<div class="total-archievement-rate-wrapper">
<ArchievementCompleteRateComponent
indicator="续保完成率"
:percentage="ui.insurance_renewal_rate"
2023-05-24 19:17:00 +08:00
/>
2023-05-29 00:15:18 +08:00
<ArchievementCompleteRateComponent
indicator="车非渗透率"
:percentage="ui.attaching_rate"
2023-03-17 14:40:04 +08:00
/>
2023-03-04 18:05:47 +08:00
</div>
2023-06-09 16:37:50 +08:00
<div class="total-archievement-charts-wrapper">
<ArchievementChart :chart-data="ui.chartData" />
2023-05-29 00:15:18 +08:00
</div>
</div>
<div class="reward-wrapper">
<HonorListComponent
:month="ui.currentMonth"
:leading-reward="ui.leading_reward_gainers"
:advance-reward="ui.advance_reward_gainers"
/>
<DishonorListComponent
:month="ui.currentMonth"
:dishonor-persons="ui.dishonorPersons"
/>
</div>
2023-03-04 00:09:25 +08:00
</div>
2023-06-06 17:31:16 +08:00
<div class="right-wrapper">
2023-06-09 16:37:50 +08:00
<h1>本大爷</h1>
<div class="carousel-item">
<el-carousel
arrow="never"
indicator-position="none"
2023-06-09 16:57:13 +08:00
:interval="4000"
2023-06-09 16:37:50 +08:00
>
2023-08-25 20:47:36 +08:00
<el-carousel-item :key="1">
2023-06-09 16:37:50 +08:00
<RankingListComponent :ranking-list="ui.attachingRankingList" />
</el-carousel-item>
<el-carousel-item :key="2">
<RankingListComponent :ranking-list="ui.renewalRankingList" />
</el-carousel-item>
</el-carousel>
</div>
<div class="carousel-item">
<el-carousel
arrow="never"
indicator-position="none"
2023-06-09 16:57:13 +08:00
:interval="4000"
2023-06-09 16:37:50 +08:00
>
<el-carousel-item :key="1">
<RankingListComponent :ranking-list="ui.attachingRankingList" />
</el-carousel-item>
<el-carousel-item :key="2">
<RankingListComponent :ranking-list="ui.renewalRankingList" />
</el-carousel-item>
</el-carousel>
</div>
2023-06-06 17:31:16 +08:00
</div>
2023-03-03 17:28:49 +08:00
</div>
2023-03-03 16:08:27 +08:00
</template>
<script lang="ts">
2023-05-24 19:17:00 +08:00
import { computed, reactive, onBeforeMount, onUnmounted } from "vue";
2023-03-03 17:28:49 +08:00
import { useRouter } from "vue-router";
2023-03-24 15:11:47 +08:00
import { getCallerInfo } from "@/utils/api/localStorage.js";
2023-03-03 17:28:49 +08:00
import { ElMessage } from "element-plus";
2023-08-25 20:47:36 +08:00
import
{
2023-08-28 17:41:07 +08:00
type DepartmentArchievement,
2023-08-29 18:57:27 +08:00
type CallerArchievement,
2023-08-29 10:55:30 +08:00
queryDepartmentArchievement,
queryCallerArchievement
2023-08-25 20:47:36 +08:00
} from "@/utils/archievement.js";
2023-06-07 17:19:47 +08:00
import { RankingListItem } from "@/types/cpicxim/RankingListItem.js";
2023-08-25 20:47:36 +08:00
import
{
type RankingListRequest,
type RankingListResponse,
requestRankingList
} from "@/utils/ranking.js";
import { type Department } from "@/types/cpicxim/Department";
2023-03-08 10:29:35 +08:00
import ArchievementChart from "@/components/ArchievementChartComponent.vue";
2023-03-08 00:56:38 +08:00
import ArchievementCompleteRateComponent from "@/components/ArchievementCompleteRateComponent.vue";
2023-03-08 16:35:40 +08:00
import HonorListComponent from "@/components/HonorListComponent.vue";
2023-03-08 20:14:41 +08:00
import DishonorListComponent from "@/components/DishonorListComponent.vue";
2023-06-06 17:31:16 +08:00
import RankingListComponent from "@/components/RankingListComponent.vue";
import { logout } from "@/utils/account.js";
import { type TelSaler } from "@/types/cpicxim/TelSaler";
2023-03-04 18:05:47 +08:00
2023-06-07 17:19:47 +08:00
interface ui
{
currentMonth: string;
chartData: number[];
totalArchievement: number;
attaching_rate: string;
insurance_renewal_rate: string; // 续保率
leading_reward_gainers: string[]; // 领跑奖
advance_reward_gainers: string[]; // 飞跃奖
dishonorPersons: string[];
showUI: boolean; // 用来刷新页面的开关
attachingRankingList: RankingListItem[]; // 坐席车非渗透率榜单
renewalRankingList: RankingListItem[];
2023-07-25 19:11:27 +08:00
}
2023-06-07 17:19:47 +08:00
2023-03-03 16:08:27 +08:00
export default {
name: "DesktopArchievement",
2023-03-08 13:24:12 +08:00
components: {
ArchievementChart,
ArchievementCompleteRateComponent,
2023-03-08 16:35:40 +08:00
HonorListComponent,
2023-03-08 20:14:41 +08:00
DishonorListComponent,
2023-06-06 17:31:16 +08:00
RankingListComponent,
2023-03-08 13:24:12 +08:00
},
2023-03-03 16:08:27 +08:00
setup()
{
const monthIndex = new Date();
2023-08-30 20:15:31 +08:00
const thisMonth: number = monthIndex.getMonth() + 1; // getMonth返回值从0开始。
2023-08-29 18:57:27 +08:00
const thisMonthString = thisMonth > 10 ? String( thisMonth ): "0" + String( thisMonth );
const thisYear: number = monthIndex.getFullYear();
const thisYearString: string = String( thisYear );
2023-08-25 20:47:36 +08:00
const numInChinese = [
"一",
"二",
"三",
"四",
"五",
"六",
"七",
"八",
"九",
"十",
"十一",
"十二",
];
2023-03-03 17:28:49 +08:00
const router = useRouter();
const callerInfo: TelSaler = getCallerInfo();
2023-06-07 17:19:47 +08:00
const ui: ui = reactive({
currentMonth: numInChinese[monthIndex.getMonth() - 1],
2023-03-21 18:01:05 +08:00
chartData: [0,], // 业绩表
totalArchievement: 0, // 总业绩
attaching_rate: "", // 车非渗透率
insurance_renewal_rate: "", // 续保率
leading_reward_gainers: ["",], // 领跑奖
advance_reward_gainers: ["",], // 飞跃奖
dishonorPersons: ["",],
showUI: true, // 用来刷新页面的开关
2023-06-07 17:19:47 +08:00
attachingRankingList: [], // 坐席车非渗透率榜单
renewalRankingList: [], // 坐席续保率榜单
2023-03-17 18:53:13 +08:00
});
2023-06-08 18:08:57 +08:00
let timerHandler = 0;
2023-03-08 13:24:12 +08:00
2023-08-29 18:57:27 +08:00
const getTotalArchievement = computed(():string =>
2023-03-08 13:24:12 +08:00
{
2023-08-25 20:47:36 +08:00
const cnyFormat = new Intl.NumberFormat( "zh-cn", {
style: "currency",
currency: "CNY",
minimumFractionDigits: 0,
});
2023-03-24 15:11:47 +08:00
const archievement = cnyFormat.format( ui.totalArchievement );
2023-03-08 13:24:12 +08:00
return archievement;
2023-03-17 18:53:13 +08:00
});
2023-08-29 18:57:27 +08:00
/**
* 将请求函数获取的部门业绩数据渲染到页面上
* @param data DepartmentArchievementl类型的部门业绩数据对象
*/
const applyDepartmentArchievementData = ( data: DepartmentArchievement ): void =>
2023-03-17 18:53:13 +08:00
{
2023-08-29 18:57:27 +08:00
// console.log( "部门业绩数据", data );
2023-03-21 18:01:05 +08:00
2023-08-29 18:57:27 +08:00
// 检查请求是否成功
if ( data.success !== true )
{
// 失败就提示消息,然后退出
ElMessage({
message: data.message,
type: "error",
});
return;
}
// ui.chartData = data.mensual_archievement_list;
// ui.totalArchievement = data.total_archievement;
2023-03-21 18:01:05 +08:00
ui.attaching_rate = data.attaching_rate;
ui.insurance_renewal_rate = data.insurance_renewal_rate;
2023-03-30 17:35:57 +08:00
ui.leading_reward_gainers = data.leading_reward_gainers;
ui.advance_reward_gainers = data.advance_reward_gainers;
2023-03-30 17:53:38 +08:00
ui.dishonorPersons = data.backward_list;
2023-03-21 18:01:05 +08:00
// 更新UI
2023-03-30 18:29:54 +08:00
// 先不显示界面往队列中加入显示队列的回调让vue刷新组件。
2023-03-21 18:01:05 +08:00
ui.showUI = false;
2023-08-25 20:47:36 +08:00
setTimeout(() =>
{
ui.showUI = true;
}, 0 );
2023-03-17 18:53:13 +08:00
};
2023-03-03 16:08:27 +08:00
2023-08-29 18:57:27 +08:00
const applyCallerArchievementData = ( data: CallerArchievement ): void =>
{
// 检查请求是否成功
if ( data.success !== true )
{
// 失败就提示消息,然后退出
ElMessage({
message: data.message,
type: "error",
});
return;
}
2023-08-30 20:15:31 +08:00
ui.chartData = data.mensual_archievement_list.slice( 0, thisMonth );
2023-08-29 18:57:27 +08:00
ui.totalArchievement = data.total_archievement;
console.log( "业绩清单", ui.chartData );
2023-08-30 20:15:31 +08:00
console.log( "当月", data.mensual_archievement_list );
2023-08-29 18:57:27 +08:00
ui.showUI = false;
setTimeout(() =>
{
ui.showUI = true;
}, 0 );
};
2023-06-07 17:19:47 +08:00
const applyRankingListData = ( data: RankingListResponse ): void =>
{
2023-06-09 16:37:50 +08:00
ui.attachingRankingList = data.attachingRateRankingList;
ui.renewalRankingList = data.renewalRateRankingList;
2023-06-07 17:19:47 +08:00
// 更新UI
// 先不显示界面往队列中加入显示队列的回调让vue刷新组件。
ui.showUI = false;
2023-06-09 16:37:50 +08:00
console.log( "获取排行榜后的ui:", data );
2023-08-25 20:47:36 +08:00
setTimeout(() =>
{
ui.showUI = true;
}, 0 );
2023-06-07 17:19:47 +08:00
};
// 退出桌面霸屏
const logoutDesktopArchievement = () =>
{
2023-03-24 15:11:47 +08:00
console.log( "111" );
logout();
// router.push("/login");
};
2023-03-17 14:40:04 +08:00
// 检查存储的登录信息,不存在则返回登录页面
if ( callerInfo.telSalerCode === "" )
2023-03-03 16:08:27 +08:00
{
2023-03-17 18:53:13 +08:00
ElMessage({
2023-03-03 17:28:49 +08:00
message: "登录信息失效,请重新登录!",
type: "success",
center: true,
2023-03-17 18:53:13 +08:00
});
2023-03-03 17:28:49 +08:00
2023-03-24 15:11:47 +08:00
router.push( "/login" );
2023-03-03 17:28:49 +08:00
}
2023-03-08 13:24:12 +08:00
2023-06-07 17:19:47 +08:00
/**
2023-08-29 18:57:27 +08:00
* 用于定时对页面进行刷新其中会请求最新的业绩数据
2023-06-07 17:19:47 +08:00
*/
2023-05-24 19:17:00 +08:00
const refresh = () =>
2023-03-21 18:01:05 +08:00
{
2023-08-25 20:47:36 +08:00
const deparmentInfo: Department = {
departmentCode: callerInfo.departmentCode,
departmentName: callerInfo.departmentName,
};
2023-08-25 20:47:36 +08:00
const rankinglistRequest: RankingListRequest = {
2023-06-07 17:19:47 +08:00
departmentCode: callerInfo.departmentCode,
2023-08-29 18:57:27 +08:00
year: thisYearString,
month: thisMonthString,
2023-06-07 17:19:47 +08:00
};
2023-08-29 10:55:30 +08:00
queryDepartmentArchievement( deparmentInfo, applyDepartmentArchievementData );
2023-08-29 18:57:27 +08:00
queryCallerArchievement( callerInfo, applyCallerArchievementData );
2023-06-07 17:19:47 +08:00
requestRankingList( rankinglistRequest, applyRankingListData );
2023-05-24 19:17:00 +08:00
};
2023-06-07 17:19:47 +08:00
/**
* 加载前
*/
2023-05-24 19:17:00 +08:00
onBeforeMount(() =>
{
// 设置每10分钟刷新一次
2023-06-09 16:37:50 +08:00
timerHandler = setInterval( refresh, 600 * 1000 );
2023-05-24 19:17:00 +08:00
refresh();
});
2023-06-07 17:19:47 +08:00
/**
* 页面卸载前
*/
2023-06-09 16:37:50 +08:00
onUnmounted((): void =>
2023-05-24 19:17:00 +08:00
{
// 退出页面前关掉定时器
clearInterval( timerHandler );
2023-03-21 18:01:05 +08:00
});
2023-08-25 20:47:36 +08:00
return {
ui,
callerInfo,
timerHandler,
getTotalArchievement,
2023-08-29 10:55:30 +08:00
renderData: applyDepartmentArchievementData,
2023-08-25 20:47:36 +08:00
refresh,
logoutDesktopArchievement,
};
2023-03-03 16:08:27 +08:00
},
};
</script>
<style scoped lang="scss">
2023-03-03 17:28:49 +08:00
.view-wrapper {
2023-03-03 16:08:27 +08:00
box-sizing: border-box;
min-height: 800px;
height: calc(100vh - 10mm);
2023-03-04 00:09:25 +08:00
min-width: 1280px;
2023-03-03 17:28:49 +08:00
width: 100vw;
2023-03-04 00:09:25 +08:00
padding: 5mm;
display: flex;
2023-05-29 00:30:38 +08:00
justify-content: flex-end;
2023-03-04 00:09:25 +08:00
align-items: stretch;
}
2023-03-04 18:05:47 +08:00
.left-wrapper {
width: 10%;
}
.center-wrapper {
//中间部分
width: 50%;
min-width: 780px;
display: flex;
flex-direction: column;
align-items: stretch;
justify-content: start;
2023-03-04 00:09:25 +08:00
.slogan {
//标语
2023-03-04 00:09:25 +08:00
margin: 0px;
padding: 15px 0px;
2023-03-04 00:09:25 +08:00
display: block;
text-align: center;
2023-03-08 13:24:12 +08:00
flex-grow: 0;
2023-03-03 17:28:49 +08:00
2023-03-04 00:09:25 +08:00
font: {
family: "FZ-ZHUOHEI";
weight: 100;
2023-03-04 18:05:47 +08:00
size: 90px;
2023-03-04 00:09:25 +08:00
}
2023-03-04 18:05:47 +08:00
color: $color-bg-04;
2023-03-04 00:09:25 +08:00
text-shadow: #feebb1 0px 0px,
#feebb1 5px 0px,
#feebb1 -5px -0px,
#feebb1 -0px -5px,
#feebb1 -4px -4px,
#feebb1 4px 4px,
#feebb1 4px -4px,
#feebb1 -4px 4px;
2023-03-03 17:28:49 +08:00
}
.total-archievement-wrapper {
2023-03-08 13:24:12 +08:00
height: 80px;
span {
display: block;
width: 100%;
color: #25e6e6;
text-align: center;
font: {
size: 35px;
family: "FZ-ZHUOHEI";
}
flex-grow: 0;
}
}
.archievement-wrapper {
//业绩部分
2023-03-08 13:24:12 +08:00
height: 280px;
display: flex;
justify-content: center;
align-items: stretch;
2023-03-08 16:35:40 +08:00
>*+* {
margin-left: 15px;
}
.total-archievement-rate-wrapper {
//业绩比例
2023-03-08 16:35:40 +08:00
// width: 20%;
width: 140px;
min-width: 140px;
display: flex;
2023-03-08 10:29:35 +08:00
flex-direction: column;
2023-03-08 13:24:12 +08:00
justify-content: center;
2023-03-08 10:29:35 +08:00
align-items: center;
}
.total-archievement-charts-wrapper {
//业绩图表
2023-03-08 16:35:40 +08:00
width: 70%;
display: flex;
justify-content: center;
align-items: center;
}
2023-03-04 00:09:25 +08:00
}
.reward-wrapper {
//奖励部分
2023-03-08 16:35:40 +08:00
// height: 280px;
padding: 15px;
2023-03-08 20:14:41 +08:00
display: flex;
justify-content: center;
align-items: center;
>*+* {
margin-left: 15px;
}
}
2023-03-04 00:09:25 +08:00
}
.right-wrapper {
2023-06-06 17:31:16 +08:00
min-width: 300px;
2023-03-04 00:09:25 +08:00
width: 25%;
2023-06-06 17:31:16 +08:00
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
2023-06-09 16:37:50 +08:00
// >*+* {
// margin-top: 15px;
// }
2023-08-25 20:47:36 +08:00
>h1 {
2023-06-09 16:37:50 +08:00
font: {
family: "FZ-ZHUOHEI";
weight: 100;
size: 30px;
}
2023-08-25 20:47:36 +08:00
2023-06-09 16:37:50 +08:00
color: $color-bg-04;
text-align: center;
width: 300px;
}
2023-08-25 20:47:36 +08:00
>div {
2023-06-09 16:37:50 +08:00
display: block;
height: 260px;
width: 300px;
2023-06-06 17:31:16 +08:00
}
2023-03-03 17:28:49 +08:00
}
2023-03-03 16:08:27 +08:00
</style>
<style lang="scss">
body {
2023-03-03 17:28:49 +08:00
background-image: radial-gradient(farthest-corner at 100% 0%,
$color-bg-01,
$color-bg-02,
$color-bg-03,
$color-bg-04,
$color-bg-05,
2023-08-25 20:47:36 +08:00
$color-bg-05 );
2023-03-03 16:08:27 +08:00
}
2023-03-08 20:14:41 +08:00
div {
// border: 1px solid red;
box-sizing: border-box;
}
2023-03-17 14:40:04 +08:00
</style>