| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 |
- <!-- 学时统计 -->
- <template>
- <div class="study-hour-card">
- <div class="card-header">
- <span class="card-title">学时统计</span>
- <p class="export-btn" @click="exportButton()">
- <i class="el-icon-download"></i> 导出数据
- </p>
- </div>
- <!-- 分组柱状图 -->
- <p class="chart-wrap" v-if="!chartData[0]" style="color:#999;font-size:14px;line-height:260px;text-align: center;">暂无数据</p>
- <div class="chart-wrap" v-if="chartData[0]" id="chart-wrap-bar-chart" ref="barChart"></div>
- <!-- 筛选 -->
- <div class="filter-row">
- <el-select v-model="queryParams.personType" placeholder="用户类型" style="width:220px">
- <el-option label="研究生" value="2" />
- <el-option label="本科生" value="3" />
- <el-option label="教职工" value="1" />
- </el-select>
- <!--<el-cascader-->
- <!--v-if="adminType == 1"-->
- <!--style="width: 180px"-->
- <!--v-model="queryParams.deptId"-->
- <!--:options="optionListA"-->
- <!--:props="{-->
- <!--emitPath:false,-->
- <!--checkStrictly: true,-->
- <!--value: 'deptId',-->
- <!--label: 'deptName',-->
- <!--children: 'child',-->
- <!--}"-->
- <!--:show-all-levels="false"-->
- <!--filterable-->
- <!--placeholder="学院"-->
- <!--></el-cascader>-->
- <el-select v-if="adminType == 1" v-model="queryParams.deptId" placeholder="学院" style="width: 180px">
- <el-option
- v-for="dict in optionListA"
- :key="dict.deptId"
- :label="dict.deptName"
- :value="dict.deptId"
- />
- </el-select>
- <el-select v-model="queryParams.gradeNumber" placeholder="学年" style="width: 140px">
- <el-option
- v-for="dict in optionListB"
- :key="dict.gradeNumber"
- :label="dict.gradeNumber"
- :value="dict.gradeNumber"
- />
- </el-select>
- <el-input v-model="queryParams.searchValue" placeholder="学号/姓名" size="small" prefix-icon="el-icon-search" style="width:210px" clearable />
- <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
- <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
- </div>
- <!-- 表格 -->
- <div class="page-content-box">
- <el-table class="table-box" :data="tableData" border>
- <el-table-column prop="userName" label="姓名" width="200" />
- <el-table-column prop="account" label="学工号" width="140" />
- <el-table-column prop="gradeNumber" label="学年" width="140" />
- <el-table-column prop="deptName" label="所属学院" show-overflow-tooltip />
- <el-table-column prop="year1CreditHours" label="第一年" width="140" align="center" />
- <el-table-column prop="year2CreditHours" label="第二年" width="140" align="center" />
- <el-table-column prop="year3CreditHours" label="第三年" width="140" align="center" />
- <el-table-column prop="year4CreditHours" label="第四年" width="140" align="center" />
- <el-table-column prop="totalCreditHours" label="总时长" width="140" align="center" />
- </el-table>
- <pagination :page-sizes="[20, 30, 40, 50]"
- v-show="total>0"
- :total="total"
- :page.sync="queryParams.page"
- :limit.sync="queryParams.pageSize"
- @pagination="examElStatisticsCreditHourList"
- />
- </div>
- </div>
- </template>
- <script>
- import echarts from 'echarts'
- import {
- systemUserGetPost,
- } from "@/api/basicsModules/index";
- import {
- examElStatisticsCreditHourChart,examElStatisticsCreditHourList,
- systemUserGetAcademicYear,systemDeptCurrentDept,
- } from "@/api/safetyEducationExaminationNew/index";
- export default {
- name: 'StudyHourStats',
- data() {
- return {
- adminType:0,
- filterData: {
- personType: '',
- college: '',
- grade: '',
- keyword: '',
- page: 1,
- colleges: ['化学与化工学院','生命科学学院','物理学院','电气工程学院','材料科学学院','机械工程学院','自动化学院','资源环境学院'],
- grades: ['2017级','2018级','2019级','2020级','2021级','2022级'],
- },
- chartData: [
- // { label: '化学与化工', graduate: 320, undergrad: 180, staff: 95 },
- // { label: '生命科学', graduate: 280, undergrad: 160, staff: 72 },
- // { label: '物理', graduate: 240, undergrad: 145, staff: 68 },
- // { label: '电气工程', graduate: 300, undergrad: 195, staff: 85 },
- // { label: '材料科学', graduate: 220, undergrad: 135, staff: 60 },
- // { label: '机械工程', graduate: 195, undergrad: 170, staff: 55 },
- // { label: '自动化', graduate: 180, undergrad: 120, staff: 48 },
- // { label: '资源环境', graduate: 165, undergrad: 110, staff: 52 },
- ],
- tableData: [],
- optionListA:[],
- optionListB:[],
- queryParams:{
- page:1,
- pageSize:20,
- personType:'',
- deptId:'',
- gradeNumber:'',
- searchValue:'',
- },
- total:0,
- }
- },
- mounted() {
- this.systemUserGetPost();
- },
- beforeDestroy() {
- if (this._barChart) this._barChart.dispose()
- },
- methods: {
- //查询当前登录用户身份-校级/院级
- systemUserGetPost(){
- systemUserGetPost({}).then(response => {
- for(let i=0;i<response.data.length;i++){
- if(response.data[i].postCode == 'school_level_admin'){
- if(response.data[i].isPost){
- this.$set(this,'adminType','1');
- }
- }else if(response.data[i].postCode == 'college_admin'){
- if(response.data[i].isPost){
- this.$set(this,'adminType','2');
- }
- }
- }
- this.systemUserGetAcademicYear();
- this.systemDeptCurrentDept();
- this.examElStatisticsCreditHourChart();
- this.examElStatisticsCreditHourList();
- });
- },
- //导出
- exportButton(){
- let self = this;
- self.$confirm(`确认导出数据?`, "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(async () => {
- let obj = {
- academicYear:this.valueYear,
- gradeNumber:this.queryParams.gradeNumber,
- searchValue:this.queryParams.searchValue,
- };
- if(this.adminType == 1){
- obj.deptId = this.queryParams.deptId;
- }else{
- obj.deptId = localStorage.getItem('deptId');
- }
- self.download('/exam/elStatistics/creditHour/export', {...obj}, '学时统计.xlsx')
- }).catch(() => {})
- },
- initBarChart() {
- const chart = echarts.init(this.$refs.barChart)
- this._barChart = chart
- const data = this.chartData
- const pageSize = 6
- const total = data.length
- const endPercent = total > pageSize ? (pageSize / total) * 100 : 100
- chart.setOption({
- legend: {
- data: ['研究生', '本科生', '教职工'],
- top: 10,
- right: 'center',
- itemWidth: 14,
- itemHeight: 14,
- textStyle: { fontSize: 12, color: '#555' },
- },
- // bottom 加大,给滚动条留空间
- grid: { top: 50, bottom: 76, left: 56, right: 20, containLabel: false },
- xAxis: {
- type: 'category',
- data: data.map(d => d.deptName),
- axisLine: { lineStyle: { color: '#ddd' } },
- axisTick: { show: false },
- axisLabel: { fontSize: 12, color: '#666', rotate: 30 },
- },
- yAxis: {
- type: 'value',
- name: '学时',
- nameTextStyle: { fontSize: 11, color: '#aaa', padding: [0, 30, 0, 0] },
- max: (value) => {
- return Math.ceil(value.max / 50) * 50
- },
- interval: 50,
- splitLine: { lineStyle: { color: '#f0f0f0' } },
- axisLabel: { fontSize: 11, color: '#aaa' },
- axisLine: { show: false },
- axisTick: { show: false },
- },
- dataZoom: [
- {
- type: 'slider',
- show: true,
- xAxisIndex: [0],
- bottom: 10,
- start: 0,
- end: endPercent,
- height: 14,
- handleSize: '80%',
- showDetail: false,
- },
- {
- type: 'inside',
- xAxisIndex: [0],
- start: 0,
- end: endPercent,
- zoomOnMouseWheel: false,
- moveOnMouseMove: true,
- },
- ],
- series: [
- {
- name: '研究生',
- type: 'bar',
- barGap: '10%',
- barCategoryGap: '40%',
- data: data.map(d => d.graduateCreditHours),
- itemStyle: { color: '#5b9cf6' },
- label: {
- show: true,
- position: 'top',
- fontSize: 11,
- color: '#555',
- formatter: '{c}',
- },
- },
- {
- name: '本科生',
- type: 'bar',
- data: data.map(d => d.undergraduateCreditHours),
- itemStyle: { color: '#4fbe7e' },
- label: {
- show: true,
- position: 'top',
- fontSize: 11,
- color: '#555',
- formatter: '{c}',
- },
- },
- {
- name: '教职工',
- type: 'bar',
- data: data.map(d => d.staffCreditHours),
- itemStyle: { color: '#f59e42' },
- label: {
- show: true,
- position: 'top',
- fontSize: 11,
- color: '#555',
- formatter: '{c}',
- },
- },
- ],
- tooltip: {
- trigger: 'axis',
- axisPointer: { type: 'shadow' },
- },
- })
- },
- //学时统计图表
- examElStatisticsCreditHourChart(){
- let obj = {};
- if(this.adminType == 1){
- obj.deptId = this.queryParams.deptId;
- }else{
- obj.deptId = localStorage.getItem('deptId');
- }
- examElStatisticsCreditHourChart(obj).then(response => {
- this.$set(this,'chartData',response.data.deptStats);
- if(response.data.deptStats[0]){
- this.$nextTick(() => {
- this.initBarChart()
- })
- }
- });
- },
- //学时统计列表
- examElStatisticsCreditHourList(){
- let obj = JSON.parse(JSON.stringify(this.queryParams))
- if(this.adminType == 1){
- obj.deptId = this.queryParams.deptId;
- }else{
- obj.deptId = localStorage.getItem('deptId');
- }
- examElStatisticsCreditHourList(obj).then(response => {
- this.$set(this,'tableData',response.data.records);
- this.$set(this,'total',response.data.total);
- });
- },
- //学年下拉列表
- systemUserGetAcademicYear(){
- systemUserGetAcademicYear({}).then(response => {
- this.$set(this,'optionListB',response.data);
- });
- },
- //学院列表
- systemDeptCurrentDept(){
- systemDeptCurrentDept({}).then(response => {
- const list = response.data || [];
- this.formatTreeData(list);
- if(list[0]){
- this.$set(this,'optionListA',list[0].child);
- }else{
- this.$set(this,'optionListA',[]);
- }
- });
- },
- //查询按钮
- handleQuery(){
- this.$set(this.queryParams,'page',1);
- this.examElStatisticsCreditHourList();
- },
- //重置按钮
- resetQuery(){
- this.$set(this,'dateRange',[])
- this.$set(this,'queryParams',{
- page:1,
- pageSize:20,
- personType:'',
- deptId:'',
- gradeNumber:'',
- searchValue:'',
- });
- this.examElStatisticsCreditHourList();
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .study-hour-card {
- background: #fff;
- /*border-radius: 6px;*/
- padding: 16px 20px;
- margin-bottom: 12px;
- /*box-shadow: 0 1px 4px rgba(0,0,0,0.06);*/
- background: rgba(255, 255, 255, 0.95);
- border: 1px solid #e8edf5;
- border-radius: 16px;
- box-shadow: 0 4px 20px rgba(37, 50, 74, 0.06);
- .card-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 16px;
- .card-title { font-size: 16px; font-weight: 700; color: #222; }
- }
- .export-btn {
- display: inline-block;
- padding: 0 16px;
- height: 40px;
- line-height: 40px;
- border-radius: 4px;
- font-size: 14px;
- cursor: pointer;
- background-color: #0183fa;
- color: #fff;
- border: 1px solid #0183fa;
- }
- .chart-wrap {
- border: 1px solid #eee;
- border-radius: 6px;
- margin-bottom: 16px;
- height: 300px;
- }
- .filter-row {
- display: flex;
- gap: 20px;
- margin-bottom: 12px;
- flex-wrap: wrap;
- }
- .page-content-box{
- height:500px;
- padding:0;
- }
- .link-blue { color: #409eff; }
- .pagination-wrap {
- display: flex;
- justify-content: center;
- margin-top: 14px;
- }
- }
- </style>
|