fix:绩效统计合格率取整

This commit is contained in:
shijing 2024-03-26 13:35:48 +08:00
parent dcecde3c11
commit 2346b053b5
2 changed files with 121 additions and 68 deletions

View File

@ -74,12 +74,12 @@
<el-table-column label="不合格数" prop="不合格数"> <el-table-column label="不合格数" prop="不合格数">
</el-table-column> </el-table-column>
<el-table-column label="完成进度" prop="完成进度"> <el-table-column label="完成进度" prop="完成进度">
<template slot-scope="scope"> <template #default="scope">
{{ Math.round(scope.row.完成进度 * 100) }}% {{ Math.round(scope.row.完成进度 * 100) }}%
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="合格率" prop="合格率"> <el-table-column label="合格率" prop="合格率">
<template slot-scope="scope"> <template #default="scope">
{{ Math.round(scope.row.合格率 * 100) }}% {{ Math.round(scope.row.合格率 * 100) }}%
</template> </template>
</el-table-column> </el-table-column>

View File

@ -2,27 +2,60 @@
<el-container> <el-container>
<el-header> <el-header>
<div class="right-panel"> <div class="right-panel">
<el-select v-model="queryBelongDept" clearable style="width:200px" placeholder="请选择部门"> <el-select
<el-option v-for="item in deptData" :key="item.id" :label="item.name" :value="item.name"> v-model="queryBelongDept"
clearable
style="width: 200px"
placeholder="请选择部门"
>
<el-option
v-for="item in deptData"
:key="item.id"
:label="item.name"
:value="item.name"
>
</el-option> </el-option>
</el-select> </el-select>
<el-date-picker v-model="queryDate" type="month" placeholder="查询月期" value-format="YYYY-MM" <el-date-picker
style="width:200px"> v-model="queryDate"
type="month"
placeholder="查询月期"
value-format="YYYY-MM"
style="width: 200px"
>
</el-date-picker> </el-date-picker>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button> <el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
></el-button>
</div> </div>
</el-header> </el-header>
<el-main id="elMain"> <el-main id="elMain">
<el-row :gutter="15" style="height: 100%;"> <el-row :gutter="15" style="height: 100%">
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never"> <el-card shadow="never">
<scEcharts :height="chartHeight" :option="option" id="chartHeight"></scEcharts> <scEcharts
:height="chartHeight"
:option="option"
id="chartHeight"
></scEcharts>
</el-card> </el-card>
</el-col> </el-col>
<el-col :lg="12"> <el-col :lg="12">
<el-card shadow="never" style="position: relative;"> <el-card shadow="never" style="position: relative">
<el-button @click="handleExport" class="tables" type="primary">导出</el-button> <el-button
<el-table :data="tableData" id="exportDiv" style="width: 100%" :height="chartHeight"> @click="handleExport"
class="tables"
type="primary"
>导出</el-button
>
<el-table
:data="tableData"
id="exportDiv"
style="width: 100%"
:height="chartHeight"
>
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column label="日期" prop="date"> <el-table-column label="日期" prop="date">
<template #default="scope"> <template #default="scope">
@ -43,6 +76,9 @@
<el-table-column label="不合格数" prop="不合格数"> <el-table-column label="不合格数" prop="不合格数">
</el-table-column> </el-table-column>
<el-table-column label="合格率" prop="合格率"> <el-table-column label="合格率" prop="合格率">
<template #default="scope">
{{ Math.round(scope.row.合格率) }}%
</template>
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-card> </el-card>
@ -53,52 +89,52 @@
</template> </template>
<script> <script>
import scEcharts from '@/components/scEcharts'; import scEcharts from "@/components/scEcharts";
export default { export default {
name: 'chart', name: "chart",
components: { components: {
scEcharts scEcharts,
}, },
data() { data() {
return { return {
queryBelongDept: '', queryBelongDept: "",
queryDate: '', queryDate: "",
start_date: '', start_date: "",
end_date: '', end_date: "",
currentYear: '', currentYear: "",
currentMonth: '', currentMonth: "",
deptData: [], deptData: [],
tableData: [], tableData: [],
option: { option: {
title: { title: {
text: '人员统计', text: "人员统计",
// subtext: '', // subtext: '',
}, },
grid: { grid: {
top: '80px' top: "80px",
}, },
tooltip: { tooltip: {
trigger: 'axis' trigger: "axis",
}, },
xAxis: { xAxis: {
type: 'value', type: "value",
position: 'top', position: "top",
axisLine: { axisLine: {
show: true show: true,
} },
}, },
yAxis: { yAxis: {
type: 'category', type: "category",
data: [] data: [],
}, },
series: { series: {
data: [], data: [],
type: 'bar', type: "bar",
barWidth: '15px', barWidth: "15px",
} },
}, },
chartHeight:0, chartHeight: 0,
} };
}, },
mounted() { mounted() {
let date = new Date(); let date = new Date();
@ -107,71 +143,88 @@ export default {
let days = new Date(year, month, 0).getDate(); let days = new Date(year, month, 0).getDate();
this.currentYear = year; this.currentYear = year;
this.currentMonth = month; this.currentMonth = month;
this.start_date = year + '-' + month + '-01'; this.start_date = year + "-" + month + "-01";
this.end_date = year + '-' + month + '-' + new Date(year, month, 0).getDate(); this.end_date =
this.queryDate = year + '-' + month; year + "-" + month + "-" + new Date(year, month, 0).getDate();
this.queryDate = year + "-" + month;
this.getData(); this.getData();
this.getDept(); this.getDept();
let mainHeight = document.getElementById('elMain').clientHeight; let mainHeight = document.getElementById("elMain").clientHeight;
this.chartHeight = (mainHeight-40)+'px'; this.chartHeight = mainHeight - 40 + "px";
}, },
methods: { methods: {
getDept() { getDept() {
this.$API.system.dept.list.req({ page: 0, type: 'dept' }).then(res => { this.$API.system.dept.list
this.deptData = res; .req({ page: 0, type: "dept" })
this.queryBelongDept = res[0].name; .then((res) => {
}); this.deptData = res;
this.queryBelongDept = res[0].name;
});
}, },
queryTypeChange(value) { queryTypeChange(value) {
this.queryDate = ''; this.queryDate = "";
}, },
getData() { getData() {
let that = this; let that = this;
let obj = { let obj = {
query: { start_date: this.start_date, end_date: this.end_date, dept_name: this.queryBelongDept }, query: {
start_date: this.start_date,
end_date: this.end_date,
dept_name: this.queryBelongDept,
},
}; };
that.$API.bi.dataset.exec.req('performance', obj).then((res) => { that.$API.bi.dataset.exec.req("performance", obj).then((res) => {
console.log('绩效统计:', res); console.log("绩效统计:", res);
let data = res.data2.ds0; let data = res.data2.ds0;
let seriesData = [], yAxisData = []; let seriesData = [],
data.forEach(item => { yAxisData = [];
data.forEach((item) => {
seriesData.push(item.合格数); seriesData.push(item.合格数);
yAxisData.push(item.操作人+'∙'+item.工段); yAxisData.push(item.操作人 + "∙" + item.工段);
}) });
console.log(yAxisData) console.log(yAxisData);
console.log(seriesData) console.log(seriesData);
console.log(data) console.log(data);
that.tableData = data; that.tableData = data;
that.option.yAxis.data = yAxisData; that.option.yAxis.data = yAxisData;
that.option.series.data = seriesData; that.option.series.data = seriesData;
}); });
}, },
handleQuery() { handleQuery() {
if (this.queryDate !== '') { if (this.queryDate !== "") {
this.start_date = this.queryDate + '-01'; this.start_date = this.queryDate + "-01";
let arr = this.queryDate.split('-'); let arr = this.queryDate.split("-");
this.end_date = this.queryDate + '-' + new Date(arr[0], arr[1], 0).getDate(); this.end_date =
this.queryDate +
"-" +
new Date(arr[0], arr[1], 0).getDate();
} else { } else {
this.start_date = this.currentYear + '-' + this.currentMonth + '-01'; this.start_date =
this.end_date = this.currentYear + '-' + this.currentMonth + '-' + new Date(this.currentYear, this.currentMonth, 0).getDate(); this.currentYear + "-" + this.currentMonth + "-01";
this.end_date =
this.currentYear +
"-" +
this.currentMonth +
"-" +
new Date(this.currentYear, this.currentMonth, 0).getDate();
} }
console.log('查询query', this.start_date, this.end_date) console.log("查询query", this.start_date, this.end_date);
this.getData(); this.getData();
}, },
handleExport() { handleExport() {
this.exportLoading = true; this.exportLoading = true;
this.$XLSX('#exportDiv', '人员统计'); this.$XLSX("#exportDiv", "人员统计");
this.exportLoading = false; this.exportLoading = false;
}, },
}, },
} };
</script> </script>
<style scoped> <style scoped>
.tables { .tables {
position: absolute; position: absolute;
top: 4px; top: 4px;
left: 4px; left: 4px;
z-index: 10; z-index: 10;
} }
</style> </style>