提交 4550f9b2 authored 作者: Yroc's avatar Yroc

表格合并

上级 b3c3b7ca
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<!-- --> <!-- -->
<template> <template>
<div class="container_box"> <div class="container_box">
<table class="table_box" :id="chart_id"> <table class="table_box" :id="chart_id" v-if="is_show_table">
<tr> <tr>
<th v-for="(e, i) in labers" :key="i" style="padding: 15px 10px"> <th v-for="(e, i) in labers" :key="i" style="padding: 15px 10px">
{{ e.label {{ e.label
...@@ -37,7 +37,22 @@ ...@@ -37,7 +37,22 @@
v-for="(item, index) in table_data" v-for="(item, index) in table_data"
:key="index" :key="index"
> >
<td v-for="(e, i) in labers" :key="i"> <td
v-for="(e, i) in labers"
:key="i"
:rowspan="
merge_fields && merge_fields.indexOf(e.key) > -1
? merge_fields_fun(index, e.key, 'sss')
: 1
"
v-if="
merge_fields && merge_fields.indexOf(e.key) > -1
? show_row_key[e.key]
? show_row_key[e.key][index]
: false
: true
"
>
<div v-if="e.key == 'distribute'"> <div v-if="e.key == 'distribute'">
<div <div
v-if=" v-if="
...@@ -135,9 +150,12 @@ ...@@ -135,9 +150,12 @@
<script> <script>
export default { export default {
props: ['table_data', 'labers', 'chart_id'], props: ['table_data', 'labers', 'chart_id', 'merge_fields'],
data() { data() {
return { return {
is_show_table: false,
show_row_key: {},
row_data_name: {},
sort_field: null, sort_field: null,
sort_type: null, sort_type: null,
}; };
...@@ -146,12 +164,68 @@ export default { ...@@ -146,12 +164,68 @@ export default {
components: {}, components: {},
computed: {}, computed: {},
created() {}, created() {
this.data_f();
},
mounted() { mounted() {
// console.log(this.table_data); // console.log(this.table_data);
// console.log(this.labers);
}, },
methods: { methods: {
data_f() {
this.is_show_table = false;
for (let d in this.merge_fields) {
for (let i in this.table_data) {
let s = 0;
if (this.show_row_key[this.merge_fields[d]]) {
s = this.merge_fields_fun(i, this.merge_fields[d]);
this.show_row_key[this.merge_fields[d]][i] = s ? true : false;
} else {
let a = {};
let s = this.merge_fields_fun(i, this.merge_fields[d]);
a[i] = s ? true : false;
this.show_row_key[this.merge_fields[d]] = a;
}
i += s;
}
}
this.row_data_name = {};
console.log(this.show_row_key);
this.is_show_table = true;
// setTimeout((), 300)/;
},
merge_fields_fun(index, key, a = false) {
let num = 0;
if (!a) {
console.log(index);
console.log(key);
console.log(this.table_data[index][key]);
}
if (
!this.row_data_name[key] ||
(this.row_data_name[key] &&
this.row_data_name[key] != this.table_data[index][key])
) {
this.row_data_name[key] = this.table_data[index][key];
for (let mf_i in this.table_data) {
if (mf_i >= index) {
if (this.table_data[index][key] == this.table_data[mf_i][key]) {
num += 1;
} else {
if (!a) {
// console.log(num);
}
return num;
}
}
}
}
if (!a) {
// console.log(num);
}
return num;
},
sort(col, type = 'desc') { sort(col, type = 'desc') {
this.sort_field = col; this.sort_field = col;
this.sort_type = type; this.sort_type = type;
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<div class="content_container" v-if="original_data.type == 'table'"> <div class="content_container" v-if="original_data.type == 'table'">
<Table <Table
v-if="original_data" v-if="original_data"
:merge_fields="original_data.merge_fields"
:table_data="original_data.list" :table_data="original_data.list"
:chart_id="original_data.chart_id" :chart_id="original_data.chart_id"
:labers="original_data.labers" :labers="original_data.labers"
......
...@@ -107,16 +107,40 @@ ...@@ -107,16 +107,40 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-row> <el-row>
<el-col :span="8" style="line-height: 36px;">TOP:</el-col> <el-col :span="8" style="line-height: 36px"
<el-col :span="16"><el-input v-model="request_params.top.error_top"></el-input></el-col> >TOP:</el-col
>
<el-col :span="16"
><el-input
v-model="request_params.top.error_top"
></el-input
></el-col>
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<el-row> <el-row>
<el-col :span="4" style="line-height: 36px;text-align: right;">范围:</el-col> <el-col
<el-col :span="9"><el-input type="number" v-model="request_params.top.error_region_min" ></el-input></el-col> :span="4"
<el-col :span="2" style="line-height: 36px;text-align: center;">- </el-col> style="line-height: 36px; text-align: right"
<el-col :span="9"><el-input type="number" v-model="request_params.top.error_region_max" ></el-input></el-col> >范围:</el-col
>
<el-col :span="9"
><el-input
type="number"
v-model="request_params.top.error_region_min"
></el-input
></el-col>
<el-col
:span="2"
style="line-height: 36px; text-align: center"
>-
</el-col>
<el-col :span="9"
><el-input
type="number"
v-model="request_params.top.error_region_max"
></el-input
></el-col>
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
...@@ -133,16 +157,40 @@ ...@@ -133,16 +157,40 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-row> <el-row>
<el-col :span="8" style="line-height: 36px">TOP:</el-col> <el-col :span="8" style="line-height: 36px"
<el-col :span="16"><el-input v-model="request_params.top.success_top"></el-input></el-col> >TOP:</el-col
>
<el-col :span="16"
><el-input
v-model="request_params.top.success_top"
></el-input
></el-col>
</el-row> </el-row>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<el-row> <el-row>
<el-col :span="4" style="line-height: 36px;text-align: right;">范围:</el-col> <el-col
<el-col :span="9"><el-input type="number" v-model="request_params.top.success_region_min" ></el-input></el-col> :span="4"
<el-col :span="2" style="line-height: 36px;text-align: center;">- </el-col> style="line-height: 36px; text-align: right"
<el-col :span="9"><el-input type="number" v-model="request_params.top.success_region_max" ></el-input></el-col> >范围:</el-col
>
<el-col :span="9"
><el-input
type="number"
v-model="request_params.top.success_region_min"
></el-input
></el-col>
<el-col
:span="2"
style="line-height: 36px; text-align: center"
>-
</el-col>
<el-col :span="9"
><el-input
type="number"
v-model="request_params.top.success_region_max"
></el-input
></el-col>
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
...@@ -458,9 +506,9 @@ export default { ...@@ -458,9 +506,9 @@ export default {
if (res.top_data) if (res.top_data)
this.exactness_question_data = this.changeRight(res.top_data.dataasc); //对题分析 this.exactness_question_data = this.changeRight(res.top_data.dataasc); //对题分析
this.wrong_position_data = this.changeWrongPosition(res.WrongPosition); //错误部位 this.wrong_position_data = this.changeWrongPosition(res.WrongPosition); //错误部位
this.error_level_data = this.changeErrorLevel(res.WrongLevel); //错误等级 // this.error_level_data = this.changeErrorLevel(res.WrongLevel); //错误等级
this.wrong_color_data = this.changeWrongColor(res.WrongColor); //错误颜色 // this.wrong_color_data = this.changeWrongColor(res.WrongColor); //错误颜色
this.wrongG_group_data = this.changeWrongGroup(res.WrongGroup); //错误组别 // this.wrongG_group_data = this.changeWrongGroup(res.WrongGroup); //错误组别
this.holdTobacco_data = this.changeHoldTobacco(res.holdTobacco); //把烟 this.holdTobacco_data = this.changeHoldTobacco(res.holdTobacco); //把烟
this.flakeTobacco_data = this.changeFlakeTobacco(res.flakeTobacco); //片烟 this.flakeTobacco_data = this.changeFlakeTobacco(res.flakeTobacco); //片烟
this.swingHandle_data = this.changeSwingHandle(res.swingHandle); //甩把 this.swingHandle_data = this.changeSwingHandle(res.swingHandle); //甩把
...@@ -933,19 +981,35 @@ export default { ...@@ -933,19 +981,35 @@ export default {
let keys = Object.keys(datas); let keys = Object.keys(datas);
let list = []; let list = [];
let labers = [ let labers = [
{ label: '正确部位', key: 'answer_position' },
{ label: '错误部位', key: 'wrong_position' },
{ label: '题目', key: 'position' }, { label: '题目', key: 'position' },
{ label: '正确答案', key: 'answer' }, { label: '正确答案', key: 'answer' },
{ label: '错题数量', key: 'wrong_num' }, { label: '错题数量', key: 'wrong_num' },
{ label: '错误答案内容', key: 'distribute' }, { label: '错误答案内容', key: 'distribute' },
]; ];
keys.forEach((element, index) => { keys.forEach((element, index) => {
for (let s in datas[element]) {
for (let i in datas[element][s]) {
list.push({ list.push({
position: element, answer_position: element,
answer: datas[element].answer, wrong_position: s,
wrong_num: datas[element].wrong_num, position: datas[element][s][i].title,
distribute: countOccurrences(datas[element].distribute), answer: datas[element][s][i].answer,
distribute_student: datas[element].distribute_student, wrong_num: datas[element][s][i].wrong_num,
distribute: countOccurrences(datas[element][s][i].distribute),
distribute_student: datas[element][s][i].distribute_student,
}); });
}
}
// list.push({
// position: element,
// answer: datas[element].answer,
// wrong_num: datas[element].wrong_num,
// distribute: countOccurrences(datas[element].distribute),
// distribute_student: datas[element].distribute_student,
// });
}); });
return { return {
type: 'table', type: 'table',
...@@ -953,6 +1017,7 @@ export default { ...@@ -953,6 +1017,7 @@ export default {
print_id: 'wrong_position', print_id: 'wrong_position',
color: '#E6A23C', color: '#E6A23C',
title: '错误部位', title: '错误部位',
merge_fields: ['answer_position'], //, 'wrong_position'
labers, labers,
list, list,
is_show: { is_show: {
...@@ -967,19 +1032,39 @@ export default { ...@@ -967,19 +1032,39 @@ export default {
let keys = Object.keys(datas); let keys = Object.keys(datas);
let list = []; let list = [];
let labers = [ let labers = [
{ label: '题目', key: 'level' }, { label: '错误等级', key: 'level' },
{ label: '题目', key: 'title' },
{ label: '正确答案', key: 'answer' }, { label: '正确答案', key: 'answer' },
{ label: '错题数量', key: 'wrong_num' }, { label: '错题数量', key: 'wrong_num' },
{ label: '错误答案内容', key: 'distribute' }, { label: '错误答案内容', key: 'distribute' },
]; ];
// keys.forEach((element, index) => {
// list.push({
// level: element,
// answer: datas[element].answer,
// wrong_num: datas[element].wrong_num,
// distribute: countOccurrences(datas[element].distribute),
// distribute_student: datas[element].distribute_student,
// });
// });
keys.forEach((element, index) => { keys.forEach((element, index) => {
for (let s in datas[element]) {
list.push({ list.push({
level: element, level: element,
answer: datas[element].answer, title: datas[element][s].title,
wrong_num: datas[element].wrong_num, answer: datas[element][s].answer,
distribute: countOccurrences(datas[element].distribute), wrong_num: datas[element][s].wrong_num,
distribute_student: datas[element].distribute_student, distribute: countOccurrences(datas[element][s].distribute),
distribute_student: datas[element][s].distribute_student,
}); });
}
// list.push({
// level: element,
// answer: datas[element].answer,
// wrong_num: datas[element].wrong_num,
// distribute: countOccurrences(datas[element].distribute),
// distribute_student: datas[element].distribute_student,
// });
}); });
return { return {
type: 'table', type: 'table',
...@@ -987,6 +1072,7 @@ export default { ...@@ -987,6 +1072,7 @@ export default {
print_id: 'wrong_level', print_id: 'wrong_level',
color: '#505F79', color: '#505F79',
title: '错误上下一级', title: '错误上下一级',
merge_fields: ['level'],
labers, labers,
list, list,
is_show: { is_show: {
...@@ -1001,19 +1087,31 @@ export default { ...@@ -1001,19 +1087,31 @@ export default {
let keys = Object.keys(datas); let keys = Object.keys(datas);
let list = []; let list = [];
let labers = [ let labers = [
{ label: '题目', key: 'color' }, { label: '错误颜色', key: 'color' },
{ label: '题目', key: 'title' },
{ label: '正确答案', key: 'answer' }, { label: '正确答案', key: 'answer' },
{ label: '错题数量', key: 'wrong_num' }, { label: '错题数量', key: 'wrong_num' },
{ label: '错误答案内容', key: 'distribute' }, { label: '错误答案内容', key: 'distribute' },
]; ];
keys.forEach((element, index) => { keys.forEach((element, index) => {
for (let s in datas[element]) {
list.push({ list.push({
color: element, color: element,
answer: datas[element].answer, title: datas[element][s].title,
wrong_num: datas[element].wrong_num, answer: datas[element][s].answer,
distribute: countOccurrences(datas[element].distribute), wrong_num: datas[element][s].wrong_num,
distribute_student: datas[element].distribute_student, distribute: countOccurrences(datas[element][s].distribute),
distribute_student: datas[element][s].distribute_student,
}); });
}
// list.push({
// color: element,
// answer: datas[element].answer,
// wrong_num: datas[element].wrong_num,
// distribute: countOccurrences(datas[element].distribute),
// distribute_student: datas[element].distribute_student,
// });
}); });
return { return {
type: 'table', type: 'table',
...@@ -1021,6 +1119,7 @@ export default { ...@@ -1021,6 +1119,7 @@ export default {
print_id: 'wrong_color', print_id: 'wrong_color',
color: '#99A9BF', color: '#99A9BF',
title: '错误颜色', title: '错误颜色',
merge_fields: ['color'],
labers, labers,
list, list,
is_show: { is_show: {
...@@ -1035,20 +1134,33 @@ export default { ...@@ -1035,20 +1134,33 @@ export default {
let keys = Object.keys(datas); let keys = Object.keys(datas);
let list = []; let list = [];
let labers = [ let labers = [
{ label: '题目', key: 'group' }, { label: '组别', key: 'group' },
{ label: '题目', key: 'title' },
{ label: '正确答案', key: 'answer' }, { label: '正确答案', key: 'answer' },
{ label: '错题数量', key: 'wrong_num' }, { label: '错题数量', key: 'wrong_num' },
{ label: '错误答案内容', key: 'distribute' }, { label: '错误答案内容', key: 'distribute' },
]; ];
keys.forEach((element, index) => { keys.forEach((element, index) => {
for (let s in datas[element]) {
list.push({ list.push({
group: element, group: element,
answer: datas[element].answer, title: datas[element][s].title,
wrong_num: datas[element].wrong_num, answer: datas[element][s].answer,
distribute: countOccurrences(datas[element].distribute), wrong_num: datas[element][s].wrong_num,
distribute_student: datas[element].distribute_student, distribute: countOccurrences(datas[element][s].distribute),
distribute_student: datas[element][s].distribute_student,
}); });
}
// list.push({
// group: element,
// answer: datas[element].answer,
// wrong_num: datas[element].wrong_num,
// distribute: countOccurrences(datas[element].distribute),
// distribute_student: datas[element].distribute_student,
// });
}); });
console.log(list);
return { return {
type: 'table', type: 'table',
chart_id: 'wrong_group', chart_id: 'wrong_group',
...@@ -1056,6 +1168,7 @@ export default { ...@@ -1056,6 +1168,7 @@ export default {
color: '#529B2E', color: '#529B2E',
title: '错误组别', title: '错误组别',
labers, labers,
merge_fields: ['group'],
list, list,
is_show: { is_show: {
key: 'is_WrongGroup', key: 'is_WrongGroup',
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论