| | |
| | | <template> |
| | | <div id="warp"> |
| | | <div> |
| | | <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect" |
| | | style="margin-bottom: 10px"> |
| | | <el-menu-item index="0">省厅月度</el-menu-item> |
| | | <el-menu-item index="2">省厅季度</el-menu-item> |
| | | <el-menu-item index="1">区县月度</el-menu-item> |
| | | <el-menu-item index="3">区县季度</el-menu-item> |
| | | </el-menu> |
| | | <div style="display: flex;position: relative"> |
| | | <div style="width: 100%"> |
| | | <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect" |
| | | style="margin-bottom: 10px"> |
| | | <el-menu-item index="0">省厅考核</el-menu-item> |
| | | <el-menu-item index="1">区县考核</el-menu-item> |
| | | <el-menu-item index="2">公安部考核</el-menu-item> |
| | | </el-menu> |
| | | </div> |
| | | <!-- 导出按钮 --> |
| | | <div style="position: absolute;top:10px; right: 5px;z-index: 2" v-hasPermi="['check:result:export']"> |
| | | <el-popover |
| | | placement="left" |
| | | width="300px" |
| | | trigger="click"> |
| | | <span style="font-weight: bold;font-size: 16px">导出</span> |
| | | |
| | | <el-form ref="exportForm" :model="exportForm" :rules="exportRules" label-width="100px"> |
| | | <el-form-item label="考核时间" prop="quarter" required> |
| | | <el-date-picker |
| | | :clearable="false" |
| | | v-model="exportForm.quarter" |
| | | type="monthrange" |
| | | format="yyyy-MM" |
| | | value-format="yyyy-MM" |
| | | unlink-panels |
| | | range-separator="至" |
| | | start-placeholder="开始月份" |
| | | end-placeholder="结束月份" |
| | | :picker-options="pickerOptions"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="区县" prop="deptIds"> |
| | | <el-select v-model="exportForm.deptIds" multiple clearable> |
| | | <el-option v-for="dept in areaList" |
| | | :value="dept.id" |
| | | :key="dept.value" |
| | | :label="dept.value"/> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="考核标签" prop="examineTags"> |
| | | <el-checkbox-group v-model="exportForm.examineTags"> |
| | | <el-checkbox |
| | | v-for="item in tagOptions" |
| | | :key="item.value" |
| | | :label="item.value" |
| | | >{{ item.label }} |
| | | </el-checkbox> |
| | | </el-checkbox-group> |
| | | </el-form-item> |
| | | <el-form-item label="计算平均值" prop="average"> |
| | | <el-switch |
| | | v-model="exportForm.average" |
| | | > |
| | | </el-switch> |
| | | </el-form-item> |
| | | <el-button type="primary" size="small" style="width: 400px" @click="handleExport">导出</el-button> |
| | | </el-form> |
| | | <el-button slot="reference" type="primary" size="mini" plain>导出</el-button> |
| | | </el-popover> |
| | | </div> |
| | | |
| | | </div> |
| | | |
| | | <div class="data-chart-container"> |
| | |
| | | <div class="card-content"> |
| | | <div class="title-container"> |
| | | <h1>考核成绩</h1> |
| | | <div class="select-container"> |
| | | <el-date-picker v-model="date" |
| | | format="yyyy-MM-dd" |
| | | value-format="yyyy-MM-dd" |
| | | type="daterange" |
| | | placeholder="选择日期" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | @change="dateChange" |
| | | @clear="handleClear" |
| | | :picker-options="pickerOptions"> |
| | | </el-date-picker> |
| | | </div> |
| | | </div> |
| | | <div class="echart-container"> |
| | | <div id="barChart" ref="barChart"></div> |
| | |
| | | </div> |
| | | </div> |
| | | <div class="bottom-publish"> |
| | | <el-button v-hasPermi="['check:score:publish']" size="medium" :type="isAnyUnpublished(city) ? 'success' : 'danger'" @click="publish(city)"> |
| | | <el-button v-hasPermi="['check:score:publish']" size="medium" |
| | | :type="isAnyUnpublished(city) ? 'success' : 'danger'" @click="publish(city)"> |
| | | {{ isAnyUnpublished(city) ? '发布' : '取消' }} |
| | | </el-button> |
| | | <el-button size="medium" @click="jumpDetail(index)" type="primary">详情</el-button> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { areaSelect } from '@/api/system/dept'; |
| | | import { listScore, getScore, delScore, addScore, updateScore, publishScore } from "@/api/platform/check-score"; |
| | | import {areaSelect} from '@/api/system/dept'; |
| | | import {listScore, publishScore} from "@/api/platform/check-score"; |
| | | import * as echarts from 'echarts'; |
| | | import {barScore} from "../../../../api/platform/check-score"; |
| | | |
| | | let observer = null; |
| | | let chart = null; |
| | | export default { |
| | | name: 'index', |
| | | data() { |
| | | return { |
| | | tagOptions: [ |
| | | {value: 0, label: '省厅'}, |
| | | {value: 1, label: '区县'}, |
| | | {value: 2, label: '公安部'} |
| | | ], |
| | | pickerOptions: { |
| | | shortcuts: [{ |
| | | text: '第一季度', |
| | | onClick(picker) { |
| | | picker.$emit('pick', [new Date(new Date().getFullYear() + "-01"+ "-01"), new Date(new Date().getFullYear() + "-03"+"-31")]); |
| | | } |
| | | }, |
| | | { |
| | | text: '第二季度', |
| | | onClick(picker) { |
| | | picker.$emit('pick', [new Date(new Date().getFullYear() + "-04"+"-01"), new Date(new Date().getFullYear() + "-06"+"-30")]); |
| | | } |
| | | }, |
| | | { |
| | | text: '第三季度', |
| | | onClick(picker) { |
| | | picker.$emit('pick', [new Date(new Date().getFullYear() + "-07"+"-01"), new Date(new Date().getFullYear() + "-09"+"-30")]) |
| | | } |
| | | }, |
| | | { |
| | | text: '第四季度', |
| | | onClick(picker) { |
| | | picker.$emit('pick', [new Date(new Date().getFullYear() + "-10"+"-01"), new Date(new Date().getFullYear() + "-12"+"-31")]) |
| | | } |
| | | }] |
| | | }, |
| | | province: { |
| | | id: [], |
| | | publish: null, |
| | | }, |
| | | // 导出表单验证 |
| | | exportRules: { |
| | | quarter: [ |
| | | { type: 'array', required: true, message: '请选择时间', trigger: 'change' } |
| | | ], |
| | | }, |
| | | checkScoreList: [], |
| | | areaList: [], |
| | | activeIndex: '0', |
| | | date: '', |
| | | date: [], |
| | | company: '', |
| | | // 导出 |
| | | exportForm: { |
| | | quarter: [], |
| | | deptIds: [], |
| | | examineTags: [], |
| | | examineCategories: [], |
| | | average: null, |
| | | }, |
| | | // 查询参数 |
| | | queryParams: { |
| | | examineTag: null, |
| | | createTime: null |
| | | }, |
| | | // 查询参数 |
| | | barParams: { |
| | | examineTag: null, |
| | | createTime: null |
| | | }, |
| | |
| | | }, |
| | | mounted() { |
| | | this.queryParams.examineTag = this.activeIndex |
| | | this.getList(); |
| | | this.areaSelect(); |
| | | this.barParams.examineTag = this.activeIndex |
| | | chart = echarts.init(this.$refs.barChart); |
| | | this.setChartOption(this.checkScoreList); |
| | | const currentDate = new Date(); |
| | | const year = currentDate.getFullYear(); |
| | | const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1,并且保证两位数 |
| | | const day = String(currentDate.getDate()).padStart(2, '0'); // 保证两位数 |
| | | this.date = [`${year}-${month}-${day}`,`${year}-${month}-${day}`]; |
| | | this.areaSelect() |
| | | // this.setChartOption(this.checkScoreList); |
| | | }, |
| | | methods: { |
| | | jumpDetail(index) { |
| | |
| | | tooltip: {}, |
| | | xAxis: { |
| | | type: 'category', |
| | | axisLabel: { |
| | | }, |
| | | axisLabel: {}, |
| | | data: this.dataList.name |
| | | }, |
| | | yAxis: { |
| | |
| | | tooltip: {}, |
| | | xAxis: { |
| | | type: 'category', |
| | | axisLabel: { |
| | | }, |
| | | axisLabel: {}, |
| | | data: nameArray |
| | | |
| | | }, |
| | |
| | | }, |
| | | filterData(mapData, tag) { |
| | | if (!mapData) return; |
| | | if(!Array.isArray(mapData)) return; |
| | | if (!Array.isArray(mapData)) return; |
| | | const tempArray = []; |
| | | mapData.forEach((item) => { |
| | | if(item.data.length) { |
| | | if (item.data.length) { |
| | | let flag = false; |
| | | item.data.forEach((examine) => { |
| | | if(examine.examineCategory === tag) { |
| | | if (examine.examineCategory === tag) { |
| | | flag = true |
| | | tempArray.push(examine.score); |
| | | } |
| | | }) |
| | | if(!flag){ |
| | | if (!flag) { |
| | | tempArray.push(0); |
| | | } |
| | | } |
| | |
| | | areaSelect() { |
| | | areaSelect().then(res => { |
| | | this.areaList = res.data; |
| | | this.getList(); |
| | | this.getChart(); |
| | | }) |
| | | }, |
| | | translateDeptId(deptId) { |
| | | const department = this.areaList.find(dept => dept.id === deptId); |
| | | console.log(deptId,this.areaList) |
| | | return department ? department.value : '未知'; |
| | | }, |
| | | |
| | |
| | | handleSelect(key) { |
| | | this.activeIndex = key; // 更新当前激活的菜单项 |
| | | this.queryParams.examineTag = key; |
| | | this.barParams.examineTag = key; |
| | | this.getList(); |
| | | this.getChart(); |
| | | }, |
| | | /** 查询考核成绩列表 */ |
| | | dateChange() { |
| | | this.getChart(); |
| | | }, |
| | | handleClear() { |
| | | const currentDate = new Date(); |
| | | const year = currentDate.getFullYear(); |
| | | const month = String(currentDate.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1,并且保证两位数 |
| | | const day = String(currentDate.getDate()).padStart(2, '0'); // 保证两位数 |
| | | this.barParams.startDate = `${year}-${month}-${day}`; |
| | | this.barParams.endDate = `${year}-${month}-${day}`; |
| | | this.getChart(); |
| | | }, |
| | | /** 获取柱状图数据 */ |
| | | getChart() { |
| | | this.loading = true; |
| | | if(this.date) { |
| | | this.barParams.startDate = this.date[0] |
| | | this.barParams.endDate = this.date[1] |
| | | } |
| | | barScore(this.barParams).then(response => { |
| | | this.setChartOption(response.data); |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | /** |
| | | * 查询考核成绩列表 |
| | | * 卡片列表默认显示当天 |
| | | * */ |
| | | getList() { |
| | | this.loading = true; |
| | | // 获取当前日期 |
| | | const today = new Date(); |
| | | |
| | | // 计算昨天的日期 |
| | | const yesterday = new Date(today); |
| | | yesterday.setDate(today.getDate() - 1); |
| | | |
| | | // 将昨天的日期格式化为字符串,这里假设后端期望的是ISO 8601格式 |
| | | this.queryParams.createTime = yesterday.toISOString().split('T')[0]; |
| | | |
| | | console.log(this.queryParams); |
| | | listScore(this.queryParams).then(response => { |
| | | this.checkScoreList = response.data; |
| | | console.log(this.checkScoreList); |
| | | this.setChartOption(this.checkScoreList); |
| | | // this.setChartOption(this.checkScoreList); |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | |
| | | // 错误处理逻辑 |
| | | }); |
| | | }, |
| | | // clickItem(value) { |
| | | // value === this.exportForm.examineTag ? this.exportForm.examineTag = null : this.exportForm.examineTag = value |
| | | // }, |
| | | /** 导出按钮操作 */ |
| | | handleExport() { |
| | | this.$refs['exportForm'].validate((valid) => { |
| | | if (valid) { |
| | | this.download( |
| | | "/check/score/export", |
| | | { |
| | | ...this.exportForm, |
| | | }, |
| | | `考核指标_${new Date().getTime()}.xlsx` |
| | | ); |
| | | } |
| | | }) |
| | | }, |
| | | }, |
| | | } |
| | | </script> |