KindergartenUI/src/views/system/classconstitution/index.vue
2022-08-31 14:23:56 +08:00

587 lines
16 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 label="所属班级" prop="categoryName" label-width="70px">
<el-button
@click="classshowclick"
style="width: 250px; text-align: left; height: 32px; color: #c0c4cc"
v-if="className == '请选择班级'"
>{{ className }}</el-button
>
<el-button
@click="classshowclick"
style="width: 250px; text-align: left; height: 32px"
v-else
>{{ className }}</el-button
>
</el-form-item>
<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-dialog
width="1000px"
title="选择所属班级"
:visible.sync="classshow"
append-to-body
:before-close="classcancel"
>
<el-table :data="classinfoList" align="center" style="margin-top: 10px" @cell-dblclick="classclick">
<el-table-column label="请选择" width="70" align="center">
<template slot-scope="scope">
<el-button
type="primary"
style="width: 20px; height: 20px"
circle
@click="classclick(scope.row)"
v-if="classId == scope.row.id"
></el-button>
<el-button
v-else
style="width: 15px; height: 15px"
circle
@click="classclick(scope.row)"
></el-button>
</template>
</el-table-column>
<el-table-column
property="kindergartenName"
label="幼儿园名称"
width="190"
align="center"
/>
<el-table-column
property="className"
label="班级名称"
width="180"
align="center"
>
</el-table-column>
<el-table-column
property="classType"
label="班级类型"
width="160"
align="center"
>
<template slot-scope="scope">
{{ scope.row.classType == dictValue1 ? "大班" : "" }}
{{ scope.row.classType == dictValue2 ? "中班" : "" }}
{{ scope.row.classType == dictValue3 ? "小班" : "" }}
{{ scope.row.classType == dictValue4 ? "毕业" : "" }}
</template>
</el-table-column>
<el-table-column
property="classTeacher"
label="班主任姓名"
width="180"
align="center"
>
</el-table-column>
<el-table-column
property="phone"
label="联系电话"
width="190"
align="center"
>
</el-table-column>
</el-table>
<pagination
v-show="total2 > 0"
:total="total2"
:page.sync="classqueryParams.pageNum"
:limit.sync="classqueryParams.pageSize"
@pagination="classinfo"
/>
</el-dialog>
<el-row v-show="itemshow">
<el-col :span="24" :offset="0">
<div style="margin: 0 auto">
<div
style="
display: flex;
text-align: center;
justify-content: center;
color: #fff;
"
>
<div
style="
width: 120px;
line-height: 60px;
border: 1px solid #f0f0f0;
background: #3c9299;
"
>
年龄
</div>
<div
style="
width: 120px;
line-height: 60px;
border: 1px solid #f0f0f0;
background: #3c9299;
"
>
平均总分
</div>
<div v-for="item in categoryTableNameList" :key="item.prentId">
<div
style="
text-align: center;
line-height: 30px;
border: 1px solid #f0f0f0;
background: #3c9299;
"
>
{{ item.parentName }}
</div>
<div
style="
display: flex;
line-height: 30px;
border: 1px solid #f0f0f0;
background: #3c9299;
font-size: 14px;
"
>
<div
v-for="uitem in item.childrenTableNameList"
:key="uitem.categoryId"
style="width: 120px"
>
{{ uitem.categoryName }}
</div>
</div>
</div>
</div>
<div>
<div
style="text-align: center; display: flex; justify-content: center"
v-for="item in categoryScoreList"
:key="item.prentId"
>
<div style="width: 120px; line-height: 60px">
{{ item.className }}
</div>
<div style="width: 120px; line-height: 60px">
{{ item.totalAvScore }}
</div>
<div>
<div style="display: flex; line-height: 60px">
<div
v-for="uitem in item.list"
:key="uitem.categoryId"
style="width: 120px"
>
{{ uitem }}
</div>
</div>
</div>
</div>
</div>
<div></div>
</div>
</el-col>
<el-col :span="24" :offset="0">
<div style="text-align: center">
<span></span>
</div>
<div class="">
<div
ref="chart"
id="chart"
style="width: 1300px; height: 600px; margin: 50px auto"
></div>
</div>
</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 { tKindergartenInfo } from "@/api/system/kindergartenInfo";
import { listClassinfo } from "@/api/system/classinfo";
import { getRoleInfo } from "@/api/system/quality";
import { ClassList } from "@/api/system/classconstitution";
import kindergarten from "../../assembly/kindergarten.vue";
export default {
components: { kindergarten },
name: "classconstitution",
data() {
return {
itemshow: false,
itemshow2: false,
classshow: false,
total2: 0,
//班级类型
dictValue1: "",
dictValue2: "",
dictValue3: "",
dictValue4: "",
ClassType: "class_type",
// 显示搜索条件
showSearch: true,
//班级查询
classqueryParams: {
pageNum: 1,
pageSize: 10,
kindergartenId: "",
className: null,
classType: null,
},
//班级list
classinfoList: [],
//班级名字
className: "请选择班级",
//班级ID
classId: "",
// 查询参数
ClassListlist: {
batchCode: "",
kindergartenId: "",
classId: "",
// batchCode: "PC202208030005",
// kindergartenId: "18",
// classId: "2",
pageNum: 1,
pageSize: 10,
},
categoryTableNameList: [],
categoryAgeFractionList: [],
categoryScoreList: [],
totalAvgFraction: "",
listname: [],
};
},
created() {
this.getList();
this.class();
// this.ClassListinfo();
},
methods: {
handleQuery() {
this.ClassListinfo();
},
kinbatlist(kindergartenId, batchCode) {
console.log(kindergartenId, batchCode);
if (this.ClassListlist.kindergartenId != "") {
this.classqueryParams.kindergartenId = "";
this.className = "请选择班级";
this.classId = "";
}
if (this.classId != "") {
this.classqueryParams.kindergartenId = "";
this.className = "请选择班级";
this.classId = "";
}
this.ClassListlist.kindergartenId = kindergartenId;
this.ClassListlist.batchCode = batchCode;
this.classqueryParams.kindergartenId = kindergartenId;
},
ClassListinfo() {
ClassList(this.ClassListlist).then((res) => {
console.log(res);
var yseries = [];
var name = "";
var names = [];
var ydata = [];
if (res.data == [] || !res.data) {
this.itemshow2 = true;
this.itemshow = false;
} else {
this.listname = [];
this.totalAvgFraction = res.data.totalAvgFraction;
this.categoryTableNameList = res.data.categoryTableNameList;
this.categoryAgeFractionList = res.data.categoryAgeFractionList;
this.categoryScoreList = res.data.categoryScoreList;
var list = [];
this.categoryTableNameList.forEach((e) => {
e.childrenTableNameList.forEach((el) => {
list.push(el.categoryId);
});
});
let yname = [];
this.categoryScoreList.forEach((el) => {
yname.push(el.className);
var listname = list.map((e) => {
var num = 0;
var number = el.categoryScoreList.findIndex(
(o) => o.categoryId == e
);
if (number != -1) {
num = el.categoryScoreList[number].categoryName;
}
return num;
});
this.listname = listname;
var list1 = list.map((e) => {
var num = 0;
var number = el.categoryScoreList.findIndex(
(o) => o.categoryId == e
);
if (number != -1) {
num = el.categoryScoreList[number].avgScore;
}
return num;
});
el.list = list1;
});
console.log(this.categoryScoreList);
console.log(this.listname);
for (var i = 0; i < this.listname.length; i++) {
name = this.categoryScoreList[0].categoryScoreList[i].categoryName;
ydata = [
this.categoryScoreList[0].list[i],
this.categoryScoreList[1].list[i],
this.categoryScoreList[2].list[i],
];
var obj = {
name: name,
type: "bar",
label: labelOption,
emphasis: {
focus: "series",
},
data: ydata,
};
console.log(ydata);
yseries.push(obj);
names.push(name);
}
console.log(yseries);
var myChart = echarts.init(document.getElementById("chart"));
var option;
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: "",
},
},
legend: {
data: names,
},
xAxis: [
{
type: "category",
axisTick: { show: false },
data: yname,
},
],
yAxis: [
{
type: "value",
},
],
series: yseries,
};
option && myChart.setOption(option, true);
this.itemshow2 = false;
this.itemshow = true;
}
});
},
//点击所属班级
classshowclick() {
this.classinfo();
this.classshow = true;
},
//班级关闭
classcancel() {
this.classshow = false;
},
//班级左侧点击
classclick(row) {
// console.log(row);
this.className = row.className;
this.classId = row.id;
this.ClassListlist.classId = row.id;
this.classshow = false;
},
//班级类型
class() {
tKindergartenInfo(this.ClassType).then((res) => {
this.dictValue1 = res.data[0].dictValue;
this.dictValue2 = res.data[1].dictValue;
this.dictValue3 = res.data[2].dictValue;
this.dictValue4 = res.data[3].dictValue;
});
},
//班级list
classinfo() {
listClassinfo(this.classqueryParams).then((response) => {
this.classinfoList = response.rows;
this.total2 = response.total;
});
},
getList() {
//用户权限
getRoleInfo().then((res) => {
console.log(res);
this.ClassListlist.kindergartenId = res.data.kindergartenId;
this.classqueryParams.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-form {
display: inline;
}
</style>