<el-container class="train-plan-index">
<el-form :inline="true" :model="form" :rules="rules" class="demo-form-inline" ref="form">
<el-form-item label="统计类型" prop="timeSpan">
<el-select v-model="form.timeSpan">
<el-option v-for="item in timeSpanList" :key="item.value" :label="item.label" :value="item.value">el-option>
<span v-if="form.timeSpan == 'year'" class="year-span">
<el-form-item label="时间" prop="yearStart" style="width:50px">
<el-date-picker v-model="form.yearStart" type="year" placeholder="选择年" value-format="yyyy" :clearable="false"> el-date-picker>
<span style="margin-right: 10px">-span>
<el-form-item prop="yearEnd">
<el-date-picker v-model="form.yearEnd" type="year" placeholder="选择年" value-format="yyyy" :clearable="false"> el-date-picker>
<el-form-item label="时间" prop="time" v-if="form.timeSpan == 'month'">
<el-date-picker v-model="form.time" type="monthrange" range-separator="—" start-placeholder="开始时间" end-placeholder="结束时间" value-format="yyyy-MM" :clearable="false">
<el-button type="primary" @click="onQuery">查询el-button>
<el-button @click="resetForm">重置el-button>
<el-main class="stat-main">
<div class="stat-text-div">
<el-form label-width="125px" class="demo-form">
<el-form-item label="总培训次数">
<el-input v-model="sumTrainCount" :disabled="true">el-input>
<el-col :span="8" :disable="true">
<el-form-item label="总培训时长">
<el-input v-model="sumTrainTime" :disabled="true">el-input>
<div id="trainStatCharts" class="stat-chart-div">div>
<el-table :data="tableData" border style="width: 100%" stripe height="calc(100% - 40px)" :default-sort="{ prop: 'saveTime', order: 'descending' }">
<el-table-column type="index" label="序号" align="center" width="60" :index="(index) => this.$common.pageIndexMethod(index, form.pageIndex, form.pageSize)"> el-table-column>
<el-table-column prop="trainId" label="培训编号" align="center" width="150"> el-table-column>
<el-table-column prop="project" label="培训项目" align="center" width="150"> el-table-column>
<el-table-column prop="applyCompany" label="申请单位" align="center" width="100"> el-table-column>
<el-table-column prop="trainNumber" label="培训人数" align="center" width="80"> el-table-column>
<el-table-column prop="startTime" label="培训开始时间" align="center" :formatter="onRenderTime"> el-table-column>
<el-table-column prop="endTime" label="培训结束时间" align="center" :formatter="onRenderTime"> el-table-column>
<el-table-column prop="isCert" label="是否为机构取证类" align="center" width="50"> el-table-column>
<Pagination :total="total" :page.sync="form.pageIndex" :limit.sync="form.pageSize" @pagination="onQuery" />
import Pagination from '@/components/Pagination';
import { pageTrainProjByTime, listTrainCountAndTimesByTime } from '@/api/eams/trainStat.js';
components: { Pagination },
yearStart: this.$common.parseTime(new Date(), '{y}'),
yearEnd: this.$common.parseTime(new Date(), '{y}'),
startTime: [{ required: true, message: '请选择时间', trigger: 'change' }],
endTime: [{ required: true, message: '请选择时间', trigger: 'change' }],
yearStart: [{ required: true, message: '请选择开始年份', trigger: 'change' }],
yearEnd: [{ required: true, message: '请选择结束年份', trigger: 'change' }],
var startDefault = new Date().getFullYear() + '-' + '01';
var endDefault = this.$common.parseTime(new Date(), '{y}-{m}');
this.form.time = [startDefault, endDefault];
this.myChart = this.$echarts.init(document.getElementById('trainStatCharts'));
this.myChart.on('click', function (params) {
let param = self.getQueryCondition();
param.startTime = params.name;
param.endTime = params.name;
self.pageTrainPlan(param);
this.$refs.form.validate((valid) => {
const param = this.getQueryCondition();
this.pageTrainPlan(param);
listTrainCountAndTimesByTime(param).then((res) => {
var resData = res.data.data;
this.xData = resData.map((item) => {
this.trainNumChart = resData.map((item) => {
this.trainNumChart.map((item) => (this.sumTrainCount = this.sumTrainCount + item));
this.trainTimeChart = resData.map((item) => {
this.trainTimeChart.map((item) => (this.sumTrainTime = this.sumTrainTime + item));
pageTrainProjByTime(param).then((res) => {
this.tableData = res.data.data ? res.data.data.data : [];
this.total = res.data.data.total;
var param = { ...this.form };
if (param.timeSpan == 'year') {
param.startTime = param.yearStart;
param.endTime = param.yearEnd;
param.startTime = param.time[0];
param.endTime = param.time[1];
this.$refs.form.resetFields();
var order = column.order;
this.form.sortField = column.prop;
this.form.sortOrder = order
onRenderTime(row, column, cellValue) {
return this.$common.parseTime(cellValue, '{y}-{m}-{d}');
this.dialogFormVisible = true;
dataView: { show: false, readOnly: false },
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: false },
saveAsImage: { show: false },
color: ['#59CE98', '#40B3C4', '#5E98EF', '#5640C4', '#BAB25E'],
data: this.trainNumChart,
data: this.trainTimeChart,
this.myChart.setOption(option);
.train-plan-index .el-header {
height: calc(100% - 50px);
.year-span >>> .el-date-editor.el-input {