123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 |
- <template>
- <div>
- <div class="fnBox statisticsBox">
- <h3>统计</h3>
- <el-card class="statisticsItem" @click.native="jump('SysUser')">
- <div class="l">
- <img src="@/assets/dash/xyzs.png" />
- </div>
- <div class="r">
- <span class="statisticsTitle">学员总数</span>
- <span class="statisticsNum">{{ usernum }}</span>
- </div>
- </el-card>
- <el-card class="statisticsItem" @click.native="jump('ExamTmpl')">
- <div class="l">
- <img src="@/assets/dash/sjzs.png" />
- </div>
- <div class="r">
- <span class="statisticsTitle">试卷总数</span>
- <span class="statisticsNum">{{ tmplnum }}</span>
- </div>
- </el-card>
- <el-card class="statisticsItem" @click.native="jump('QuList')">
- <div class="l">
- <img src="@/assets/dash/stzs.png" />
- </div>
- <div class="r">
- <span class="statisticsTitle">试题总数</span>
- <span class="statisticsNum">{{ titlenum }}</span>
- </div>
- </el-card>
- <el-card class="statisticsItem" @click.native="jump('ListCourse')">
- <div class="l">
- <img src="@/assets/dash/stzs.png" />
- </div>
- <div class="r">
- <span class="statisticsTitle">课程总数</span>
- <span class="statisticsNum">{{ coursenum }}</span>
- </div>
- </el-card>
- </div>
- <div class="fnBox contentBox">
- <div class="contentItem">
- <h3>快捷入口</h3>
- <div class="quickBox">
- <el-scrollbar style="width: 100%; height: 100%">
- <el-card
- class="quickItem"
- @click.native="jump('AddExam', { tmplId: '0' })"
- >
- <div class="l">
- <img src="@/assets/dash/a1.png" />
- </div>
- <div class="r">
- <span class="quickItemTitle">创建考试</span>
- <span class="quickItemDesc"
- >快速创建一场考试,支持多种选题方式</span
- >
- </div>
- </el-card>
- <el-card class="quickItem" @click.native="jump('AddCourse')">
- <div class="l">
- <img src="@/assets/dash/a2.png" />
- </div>
- <div class="r">
- <span class="quickItemTitle">添加课程</span>
- <span class="quickItemDesc"
- >添加课程课件,支持Office/PDF/视频</span
- >
- </div>
- </el-card>
- <el-card class="quickItem" @click.native="jump('ListRepo')">
- <div class="l">
- <img src="@/assets/dash/a3.png" />
- </div>
- <div class="r">
- <span class="quickItemTitle">题库管理</span>
- <span class="quickItemDesc"
- >批量导入导出、设定章节、题目难易程度</span
- >
- </div>
- </el-card>
- <el-card class="quickItem" @click.native="jump('SysNotice')">
- <div class="l">
- <img src="@/assets/dash/a4.png" />
- </div>
- <div class="r">
- <span class="quickItemTitle">公告管理</span>
- <span class="quickItemDesc">发布日常公告、新闻及提醒事项</span>
- </div>
- </el-card>
- </el-scrollbar>
- </div>
- </div>
- <div class="contentItem">
- <h3>当前考试({{ ksList.length }})</h3>
- <div class="evaluateBox">
- <el-scrollbar style="width: 100%; height: 100%">
- <el-card
- v-for="item in ksList"
- :key="item.id"
- class="evaluateItem"
- @click.native="jump('ExamTmplPreview', { id: item.tmplId })"
- >
- <div slot="header" class="evaluateItemHeader">
- <div>{{ item.title }}</div>
- </div>
- <el-form label-width="90px">
- <el-form-item label="考试时间:">
- <el-tooltip
- class="item"
- effect="dark"
- :content="`${item.startTime} - ${item.endTime}`"
- placement="top"
- >
- <span class="ovf"
- >{{ item.startTime }} - {{ item.endTime }}</span
- >
- </el-tooltip>
- </el-form-item>
- <el-form-item label="考试时长:">
- <span>{{ item.totalTime }}</span>
- </el-form-item>
- <el-form-item label="考试总分:">
- <span>{{ item.totalScore }}</span>
- </el-form-item>
- </el-form>
- </el-card>
- </el-scrollbar>
- </div>
- </div>
- </div>
- <div class="fnBox chartBox">
- <div class="radioBox">
- <el-radio-group v-model="radioValue" size="mini" @change="initChart">
- <el-radio-button label="1">本周</el-radio-button>
- <el-radio-button label="2">本月</el-radio-button>
- <el-radio-button label="3">本年</el-radio-button>
- </el-radio-group>
- </div>
- <el-tabs v-model="tabActive" @tab-click="reLayoutTable">
- <el-tab-pane class="chartItem" label="部门" name="bm">
- <div id="bmPxChartDom" style="width: 48%; height: 280px"></div>
- <div id="bmKsChartDom" style="width: 48%; height: 280px"></div>
- </el-tab-pane>
- <el-tab-pane class="chartItem" label="职工" name="zg">
- <div id="zgPxChartDom" style="width: 48%; height: 280px"></div>
- <div id="zgKsChartDom" style="width: 48%; height: 280px"></div>
- </el-tab-pane>
- </el-tabs>
- </div>
- </div>
- </template>
- <script>
- import * as echarts from "echarts";
- import {
- getCttTotal,
- getCurrentExam,
- getDepartRank,
- getPassedRate,
- getUserRank,
- getUserRate,
- } from "@/api/dashboard/index";
- export default {
- components: {},
- data() {
- return {
- usernum: 0,
- tmplnum: 0,
- titlenum: 0,
- coursenum: 0,
- tabActive: "bm",
- radioValue: "2",
- ksList: [],
- getDepartRank,
- getPassedRate,
- getUserRank,
- getUserRate,
- };
- },
- mounted() {
- this.initChart();
- this.getCttTotal();
- this.getCurrentExam();
- },
- methods: {
- // 获取统计数值
- getCttTotal() {
- getCttTotal().then(({ data }) => {
- this.usernum = data.usernum;
- this.tmplnum = data.tmplnum;
- this.titlenum = data.titlenum;
- this.coursenum = data.coursenum;
- });
- },
- // 页面跳转
- jump(name, params = {}) {
- this.$router.push({ name, params });
- },
- // 重置表格布局
- reLayoutTable() {
- this.$nextTick(() => {
- this.initChart();
- });
- },
- // 初始化图表
- initChart() {
- this.$nextTick(() => {
- this.tabActive === "bm"
- ? this.callFn("getDepartRank", "getPassedRate")
- : this.callFn("getUserRank", "getUserRate");
- });
- },
- // 调用函数
- callFn(fn1, fn2) {
- const tabActive = this.tabActive;
- let pxChartDom = document.getElementById(`${tabActive}PxChartDom`);
- let ksChartDom = document.getElementById(`${tabActive}KsChartDom`);
- pxChartDom && pxChartDom.removeAttribute("_echarts_instance_");
- ksChartDom && ksChartDom.removeAttribute("_echarts_instance_");
- const nowDate = new Date()
- let startDate = null
- let endDate = null
- let monthDays = null // 当前月共多少天
- const weekDay = nowDate.getDay() // 获取当前为周几
- const month = nowDate.getMonth() + 1 // 获取当前为几月
- if (this.radioValue === '1') {
- nowDate.setDate(nowDate.getDate() - weekDay)
- startDate = nowDate.formatDate("yyyy-MM-dd 00:00:00")
- nowDate.setDate(nowDate.getDate() + 6)
- endDate = nowDate.formatDate("yyyy-MM-dd 23:59:59")
- } else if (this.radioValue === '2') {
- nowDate.setMonth(month)
- nowDate.setDate(0)
- monthDays = nowDate.getDate()
- nowDate.setMonth(month - 1)
- startDate = nowDate.formatDate("yyyy-MM-01 00:00:00")
- endDate = nowDate.formatDate(`yyyy-MM-${monthDays} 23:59:59`)
- } else {
- startDate = nowDate.formatDate("yyyy-01-01 00:00:00")
- endDate = nowDate.formatDate('yyyy-12-31 23:59:59')
- }
- this[fn1]({
- statDateL: startDate,
- statDateR: endDate
- }).then((res) => {
- let myChart = echarts.init(pxChartDom);
- let option;
- let xAxisData = [];
- let pxSeriesData = [];
- res.data.forEach((ele) => {
- xAxisData.push(tabActive === "bm" ? ele.deptName : ele.realName);
- pxSeriesData.push(ele.total);
- });
- option = {
- title: {
- showTitle: true,
- text: `${
- tabActive === "bm" ? "部门培训课程排行" : "职工培训时长排行top20"
- }`,
- subtext: "可滚轮缩放、左右拖动查看",
- x: "center",
- y: "top",
- },
- xAxis: {
- type: "category",
- data: xAxisData,
- axisLabel: {
- rotate: -40,
- },
- },
- yAxis: {
- type: "value",
- minInterval: 1,
- },
- tooltip: {
- show: true,
- trigger: "axis",
- formatter(data) {
- let str = "";
- data.forEach((ele) => {
- let circle = `<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:${ele.color}"></span>`;
- str += circle + `${ele.name} : ${ele.value}${tabActive === 'bm' ? '' : '分钟'} <br />`;
- });
- return str;
- },
- },
- dataZoom: [
- {
- id: "dataZoomX",
- type: "inside",
- xAxisIndex: [0],
- filterMode: "none",
- start: 0,
- end: tabActive === "bm" ? 50 : 20,
- },
- ],
- series: [
- {
- data: pxSeriesData,
- type: "line",
- smooth: true,
- itemStyle: {
- color: "#1890ff",
- },
- },
- ],
- };
- option && myChart.setOption(option);
- });
- this[fn2]({
- statDateL: startDate,
- statDateR: endDate,
- }).then((res) => {
- let myChart = echarts.init(ksChartDom);
- let option;
- let xAxisData = [];
- let pxSeriesData = [];
- res.data.forEach((ele) => {
- xAxisData.push(tabActive === "bm" ? ele.deptName : ele.realName);
- pxSeriesData.push(ele.total > 0 ? (ele.passed / ele.total) * 100 : 0);
- });
- option = {
- title: {
- showTitle: true,
- text: `${
- tabActive === "bm"
- ? "部门考试及格率排行"
- : "职工考试及格率排行top20"
- }`,
- subtext: "可滚轮缩放、左右拖动查看",
- x: "center",
- y: "top",
- },
- xAxis: {
- type: "category",
- data: xAxisData,
- },
- yAxis: {
- type: "value",
- },
- tooltip: {
- show: true,
- trigger: "axis",
- formatter(data) {
- let str = "";
- data.forEach((ele) => {
- let circle = `<span style="display:inline-block;margin-right:5px;border-radius:50%;width:10px;height:10px;left:5px;background-color:${ele.color}"></span>`;
- str += circle + `${ele.name} : ${ele.value}% <br />`;
- });
- return str;
- },
- },
- dataZoom: [
- {
- id: "dataZoomX",
- type: "inside",
- xAxisIndex: [0],
- filterMode: "none",
- start: 0,
- end: tabActive === "bm" ? 50 : 20,
- },
- ],
- series: [
- {
- data: pxSeriesData,
- type: "line",
- smooth: true,
- itemStyle: {
- color: "#1890ff",
- },
- },
- ],
- };
- option && myChart.setOption(option);
- });
- },
- // 获取当前考试
- getCurrentExam() {
- getCurrentExam().then((res) => {
- this.ksList = res.data || [];
- });
- },
- },
- };
- </script>
- <style lang="scss" >
- .fnBox {
- width: 100%;
- h3 {
- width: 100%;
- }
- }
- .statisticsBox {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- flex-wrap: wrap;
- .statisticsItem {
- margin-left: 20px;
- background: #1890ff;
- padding: 5px;
- cursor: pointer;
- .el-card__body {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- user-select: none;
- .l {
- width: 50px;
- height: 50px;
- margin-right: 40px;
- img {
- width: 100%;
- height: 100%;
- background-size: 100% 100%;
- }
- }
- .r {
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- align-items: center;
- font-weight: 700;
- color: #fff;
- .statisticsTitle {
- font-size: 16px;
- margin-bottom: 10px;
- }
- .statisticsNum {
- font-size: 18px;
- }
- }
- }
- &:nth-child(2) {
- margin-left: 0;
- }
- }
- }
- .contentBox {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: flex-start;
- .contentItem {
- width: 48%;
- height: 225px;
- .quickBox {
- width: 100%;
- height: 100%;
- .el-scrollbar__view {
- display: flex;
- justify-content: space-between;
- align-items: center;
- flex-wrap: wrap;
- }
- .quickItem {
- width: 48%;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- user-select: none;
- cursor: pointer;
- margin-bottom: 18px;
- .el-card__body {
- display: flex;
- justify-content: space-between;
- align-items: center;
- user-select: none;
- .l {
- width: 50px;
- height: 50px;
- margin-right: 20px;
- img {
- width: 100%;
- height: 100%;
- background-size: 100% 100%;
- }
- }
- .r {
- display: flex;
- flex-direction: column;
- justify-content: flex-start;
- align-items: flex-start;
- font-weight: 700;
- color: #000;
- .quickItemTitle {
- font-size: 16px;
- margin-bottom: 10px;
- }
- .quickItemDesc {
- font-size: 12px;
- color: #666;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- }
- }
- }
- .evaluateBox {
- width: 100%;
- height: 100%;
- .el-scrollbar__view {
- display: flex;
- justify-content: space-between;
- align-items: center;
- flex-wrap: wrap;
- }
- .evaluateItem {
- width: 48%;
- margin-bottom: 18px;
- cursor: pointer;
- .evaluateItemHeader {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .iconBox {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- i {
- margin-left: 8px;
- cursor: pointer;
- }
- }
- }
- }
- .el-card__body {
- padding: 20px;
- }
- .el-form-item {
- margin-bottom: 0;
- height: 36px;
- .ovf {
- display: inline-block;
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- }
- }
- }
- .chartBox {
- width: 100%;
- margin-top: 50px;
- position: relative;
- .radioBox {
- position: absolute;
- right: 0;
- top: 45px;
- z-index: 100;
- }
- .chartItem {
- width: 100%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- }
- </style>
|