From 25a23d85d6de5f19e7132bcf2abf4deff9f235a7 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Fri, 4 Aug 2023 11:33:12 +0800 Subject: [PATCH] fix --- src/pages/achievement/info/course.vue | 53 ++++++++++++++++---------- src/pages/achievement/info/project.vue | 50 +++++++----------------- src/pages/product/list/index.vue | 40 +++++++++++++++---- 3 files changed, 78 insertions(+), 65 deletions(-) diff --git a/src/pages/achievement/info/course.vue b/src/pages/achievement/info/course.vue index 1895747..5496c1b 100644 --- a/src/pages/achievement/info/course.vue +++ b/src/pages/achievement/info/course.vue @@ -48,11 +48,11 @@
错误率最高:{{ max.projectName }} - 参加考试{{ max.itemErrorCount }}人 | {{ permissions ? `共${max.errorTotal}人做错,` : '' }}错误率{{ max.errorRate }}% + 参加考试{{ max.numberOfParticipants }}人 | {{ curTab == 1 ? `共${max.itemErrorCount}人做错,` : '' }}错误率{{ max.errorRate }}%
错误率最低:{{ min.projectName }} - 参加考试{{ min.itemErrorCount }}人 | {{ permissions ? `共${min.errorTotal}人做错,` : '' }}错误率{{ min.errorRate }}% + 参加考试{{ min.numberOfParticipants }}人 | {{ curTab == 1 ? `共${min.itemErrorCount}人做错,` : '' }}错误率{{ min.errorRate }}%
{ - if (!data[n[prop]]) { - data[n[prop]] = 1 - } else { - data[n[prop]]++ + const val = n[prop] + if (val === 0) { + data[0]++; + } else if (val > 0 && val <= 10) { + data[1]++; + } else if (val > 10 && val <= 20) { + data[2]++; + } else if (val > 20 && val <= 30) { + data[3]++; + } else if (val > 30 && val <= 40) { + data[4]++; + } else if (val > 40 && val <= 50) { + data[5]++; + } else if (val > 50 && val <= 60) { + data[6]++; + } else if (val > 60 && val <= 70) { + data[7]++; + } else if (val > 70 && val <= 80) { + data[8]++; + } else if (val > 80 && val <= 90) { + data[9]++; + } else if (val > 90 && val <= 100) { + data[10]++; } }) - console.log(333, data, Object.keys(data), Object.values(data)) + let myChart = echarts.init(document.getElementById("chart")); myChart.setOption({ title: { text: "实验分数分布图" }, tooltip: {}, xAxis: { - name: "分数", + name: this.curTab == 1 ? "分数" : "平均分", type: "category", boundaryGap: false, - interval: 5, - axisLabel: { - interval: 9, - }, - data: Object.keys(data) + interval: 10, + data: ["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", '100'] }, yAxis: { - name: this.curTab == 1 ? "人数" : '成绩报告数量', + name: "人数", type: "value", - interval: 10, - axisLabel: { - interval: 9, - }, + interval: 1 }, series: [{ - data: Object.values(data), + data, type: "line", areaStyle: {}, color: ["#8191fd"] diff --git a/src/pages/achievement/info/project.vue b/src/pages/achievement/info/project.vue index 76324b8..1da1f36 100644 --- a/src/pages/achievement/info/project.vue +++ b/src/pages/achievement/info/project.vue @@ -6,7 +6,8 @@ {{ experimentalName }}
-
@@ -341,7 +342,9 @@ export default { let { list } = this.permissions ? await this.$post(`${this.api.spliceClass}?assessmentId=${this.id}`) : await this.$post(this.api.myClass) - if (!this.permissions) list = list.slice(1) + // 去掉无指定范围 + const i = list.findIndex(e => e.id == 1) + i !== -1 && list.splice(i, 1) this.classes = list }, // 成绩 @@ -502,57 +505,30 @@ export default { getChart () { // 初始化折线图 const xData = Array.from({ length: 101 }, (v, k) => k) const yData = Array.from({ length: 101 }, (v, k) => 0) - const data = {} const list = this.listDataAll list.map(n => { - if (!data[n.score]) { - data[n.score] = 1 - } else { - data[n.score]++ - } - yData[n.score]++ }) - let max = Math.max(...Object.values(data)) - console.log("🚀 ~ file: project.vue:517 ~ getChart ~ max:", yData) - const x = Array.from({ length: max }, (v, k) => k) - - for (let i = 0; i <= max; i++) { - const item = yData.findIndex(e => e == i) - console.log("🚀 ~ file: project.vue:521 ~ getChart ~ item:", item) - - } - - xData.map(e => { - for (let i = 0; i <= max; i++) { - - } - }) - // console.log(333, xData, yData, data) + console.log(333, xData, yData) let myChart = echarts.init(document.getElementById("chart")); myChart.setOption({ title: { text: "实验分数分布图" }, tooltip: {}, xAxis: { - name: this.permissions ? "人数" : '成绩报告数量', - type: "value", - boundaryGap: false, - interval: 5, - axisLabel: { - interval: 5 - }, - }, - yAxis: { name: "分数", type: "category", - min: 0, - max: 100, + boundaryGap: false, interval: 5, axisLabel: { - interval: 9 + interval: 9, }, data: xData }, + yAxis: { + name: this.permissions ? "人数" : '成绩报告数量', + type: "value", + interval: 5 + }, series: [{ data: yData, type: "line", diff --git a/src/pages/product/list/index.vue b/src/pages/product/list/index.vue index 50a50a2..5a27f38 100644 --- a/src/pages/product/list/index.vue +++ b/src/pages/product/list/index.vue @@ -57,17 +57,16 @@ @click="catetoryClick(1)">不限
- {{ item.name }} + :class="['category-item', {active: item.disciplineId == categoryId}]"> + {{ item.val.length ? item.name : item.categoryName }} + @change="id => categoryChange(id, item, i)">
@@ -412,6 +411,7 @@ export default { val: [], disciplineId: e.disciplineId, name: e.disciplineName, + categoryName: e.disciplineName, list }) }).catch(err => { }) @@ -425,10 +425,27 @@ export default { }) }).catch(err => { }) }, - nameClick (i) { + nameClick (item, i) { + this.categoryId = item.disciplineId + this.professionalCategoryId = '' + this.professionalId = '' this.$refs['category' + i][0].toggleDropDownVisible() + this.clearCategory() + this.initData() + }, + // 清除所有学科所选 + clearCategory () { + const list = this.category + list.map(e => { + e.val = [] + }) }, - categoryChange (val, item) { + categoryChange (val, item, i) { + const name = this.$refs['category' + i][0].getCheckedNodes()[0].pathLabels + console.log("🚀 ~ file: index.vue:431 ~ categoryChange ~ val, item:", val, item, name) + item.name = item.categoryName + '/' + name.join('/') + this.clearCategory() + item.val = val this.categoryId = item.disciplineId this.professionalCategoryId = val[0] || '' this.professionalId = val[1] || '' @@ -501,6 +518,7 @@ export default { this.categoryId = id this.professionalCategoryId = id this.professionalId = id + this.clearCategory() this.initData() }, // 获取产品类型 @@ -570,9 +588,10 @@ export default { } .texts { position: absolute; - top: 200px; + top: 50%; left: 188px; color: #fff; + transform: translateY(-50%); } h6 { margin-bottom: 25px; @@ -686,6 +705,11 @@ export default { width: 30px; } } + &.active { + .name { + color: #9278ff; + } + } } /deep/.el-cascader { width: auto;