KindergartenUI/src/views/system/heightAndWeight/index.vue
2022-08-31 10:12:22 +08:00

399 lines
11 KiB
Vue

<template>
<div class="app-container">
<el-form
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="90px"
>
<kindergarten
@kinbatlist="kinbatlist"
style="width: 500px; display: inline"
></kindergarten>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="handleQuery"
>查看</el-button
>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<el-row v-show="itemshow">
<el-col :span="24" class="card-box" style="">
<el-card>
<div style="display: flex; margin-top: 40px">
<div
slot="header"
style="width: 50%; text-align: center; font-size: 18px"
>
<span>各年级男/女平均身高(cm)</span>
<div
id="main"
style="
width: 500px;
height: 300px;
margin: 0 auto;
padding-top: 40px;
"
></div>
</div>
<div
slot="header"
style="width: 50%; text-align: center; font-size: 18px"
>
<span>各年级男/女平均体重(kg)</span>
<div
id="main2"
style="
width: 500px;
height: 300px;
margin: 0 auto;
padding-top: 40px;
"
></div>
</div>
</div>
</el-card>
</el-col>
</el-row>
<el-row :gutter="20" v-if="itemshow2">
<el-col :span="24" :offset="0">
<el-card>
<div slot="header" style="text-align: center">
<img style="width: 40px" src="@/icons/笑脸.png" alt="" />
<div><!-- card title -->该批次暂无数据</div>
</div>
<!-- card body -->
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import * as echarts from "echarts";
import { getRoleInfo } from "@/api/system/quality";
import { analysis } from "@/api/system/heightAndWeight";
import Kindergarten from "../../assembly/kindergarten.vue";
export default {
name: "KindergartenPhysicalTest",
components: { Kindergarten },
data() {
return {
itemshow: false,
itemshow2: false,
// 显示搜索条件
showSearch: true,
analysislist: [],
//查询传值
analysisqueryParams: {
kindergartenId: "",
batchCode: "",
// kindergartenId: "18",
// batchCode: "PC202208030005",
},
};
},
mounted() {},
created() {
this.getList();
},
methods: {
handleQuery() {
this.analysisinfo();
},
kinbatlist(kindergartenId, batchCode) {
console.log(kindergartenId, batchCode);
this.analysisqueryParams.kindergartenId = kindergartenId;
this.analysisqueryParams.batchCode = batchCode;
if (batchCode == "请选择批次") {
this.analysisqueryParams.batchCode = "";
}
},
analysisinfo() {
analysis(this.analysisqueryParams).then((res) => {
if (!res.data) {
this.itemshow2 = true;
this.itemshow = false;
} else {
this.analysislist = res.data;
console.log(this.analysislist);
var yclassname = [];
var grilsheight = [];
var boyheight = [];
var boyweight = [];
var grilsweight = [];
for (var i = 0; i < this.analysislist.length; i++) {
this.analysislist[i].weightAndHeightAvgScoreList.forEach((el) => {
if (el.itemCode == "H001" && el.studentSex == "MALE") {
boyheight.push(el.averageScore);
} else if (el.itemCode == "H001" && el.studentSex == "FEMALE") {
grilsheight.push(el.averageScore);
} else if (el.itemCode == "W001" && el.studentSex == "FEMALE") {
grilsweight.push(el.averageScore);
} else if (el.itemCode == "W001" && el.studentSex == "MALE") {
boyweight.push(el.averageScore);
}
});
if (grilsheight.length == i) {
grilsheight.push(0);
}
if (boyheight.length == i) {
boyheight.push(0);
}
if (boyweight.length == i) {
boyweight.push(0);
}
if (grilsweight.length == i) {
grilsweight.push(0);
}
}
this.analysislist.forEach((e) => {
yclassname.push(e.className);
});
console.log(grilsheight, boyheight);
console.log(grilsweight, boyweight);
var app = {};
var myChart = echarts.init(document.getElementById("main"));
var myChart2 = echarts.init(document.getElementById("main2"));
var option;
var option2;
const posList = [
"left",
"right",
"top",
"bottom",
"inside",
"insideTop",
"insideLeft",
"insideRight",
"insideBottom",
"insideTopLeft",
"insideTopRight",
"insideBottomLeft",
"insideBottomRight",
];
app.configParameters = {
rotate: {
min: 0,
max: 90,
},
align: {
options: {
left: "left",
center: "center",
right: "right",
},
},
verticalAlign: {
options: {
top: "top",
middle: "middle",
bottom: "bottom",
},
},
position: {
options: posList.reduce(function (map, pos) {
map[pos] = pos;
return map;
}, {}),
},
distance: {
min: 0,
max: 100,
},
};
app.config = {
rotate: 0,
align: "center",
verticalAlign: "middle",
position: "top",
distance: 15,
onChange: function () {
const labelOption = {
rotate: app.config.rotate,
align: app.config.align,
verticalAlign: app.config.verticalAlign,
position: app.config.position,
distance: app.config.distance,
};
myChart.setOption({
series: [
{
label: labelOption,
},
{
label: labelOption,
},
{
label: labelOption,
},
{
label: labelOption,
},
],
});
},
};
const labelOption = {
show: true,
position: app.config.position,
distance: app.config.distance,
align: app.config.align,
verticalAlign: app.config.verticalAlign,
rotate: app.config.rotate,
formatter: "{c}",
fontSize: 16,
rich: {
name: {},
},
};
option = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
},
legend: {
data: ["男", "女"],
},
xAxis: [
{
type: "category",
axisTick: { show: false },
data: yclassname,
},
],
yAxis: [
{
type: "value",
},
],
series: [
{
name: "男",
type: "bar",
barGap: 0,
color: "#00B050",
label: labelOption,
emphasis: {
focus: "series",
},
data: boyheight,
},
{
name: "女",
type: "bar",
color: "red",
label: labelOption,
emphasis: {
focus: "series",
},
data: grilsheight,
},
],
};
option2 = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
},
legend: {
data: ["男", "女"],
},
xAxis: [
{
type: "category",
axisTick: { show: false },
data: yclassname,
},
],
yAxis: [
{
type: "value",
},
],
series: [
{
name: "男",
type: "bar",
barGap: 0,
color: "#00B050",
label: labelOption,
emphasis: {
focus: "series",
},
data: boyweight,
},
{
name: "女",
type: "bar",
color: "red",
label: labelOption,
emphasis: {
focus: "series",
},
data: grilsweight,
},
],
};
option && myChart.setOption(option);
option2 && myChart2.setOption(option2);
this.itemshow = true;
this.itemshow2 = false;
}
});
},
getList() {
//用户权限
getRoleInfo().then((res) => {
console.log(res);
this.analysisqueryParams.kindergartenId = res.data.kindergartenId;
var user = res.data.roleKeys;
console.log(user);
if (user.includes("enchou")) {
return;
} else if (user.includes("teacher")) {
return;
} else if (user.includes("parent")) {
return;
}
});
},
// 表单重置
reset() {
this.form = {};
this.resetForm("form");
},
},
};
</script>
<style scoped='scss'>
::v-deep .el-card__header {
border: none;
}
::v-deep .el-form {
display: inline;
}
</style>