Commit da9346ee2016249d24cc25c97eaeb51ee894bfce

Authored by 梁保满
1 parent ee00775c

全选和排序问题

src/views/standard/test/contrast.vue
@@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
94 <el-table-column 94 <el-table-column
95 prop="rank" 95 prop="rank"
96 label="排名" 96 label="排名"
  97 + sortable
97 align="center" 98 align="center"
98 ></el-table-column> 99 ></el-table-column>
99 <el-table-column 100 <el-table-column
@@ -104,7 +105,6 @@ @@ -104,7 +105,6 @@
104 <el-table-column 105 <el-table-column
105 prop="className" 106 prop="className"
106 label="班级" 107 label="班级"
107 - sortable  
108 align="center" 108 align="center"
109 ></el-table-column> 109 ></el-table-column>
110 <el-table-column 110 <el-table-column
@@ -116,7 +116,6 @@ @@ -116,7 +116,6 @@
116 <el-table-column 116 <el-table-column
117 prop="levelName" 117 prop="levelName"
118 label="成绩等级" 118 label="成绩等级"
119 - sortable  
120 align="center" 119 align="center"
121 ></el-table-column> 120 ></el-table-column>
122 </el-table> 121 </el-table>
@@ -389,7 +388,11 @@ export default { @@ -389,7 +388,11 @@ export default {
389 this.title = data.title; 388 this.title = data.title;
390 this.subjectNames = data.subjectName; 389 this.subjectNames = data.subjectName;
391 this.tableData = data.classes || []; 390 this.tableData = data.classes || [];
392 - this.tableData2 = data.students || []; 391 + this.tableData2 =
  392 + data.students.map((item) => {
  393 + item.score = Number(item.score);
  394 + return item;
  395 + }) || [];
393 } else { 396 } else {
394 this.$message.error(info); 397 this.$message.error(info);
395 } 398 }
@@ -521,7 +524,7 @@ export default { @@ -521,7 +524,7 @@ export default {
521 } 524 }
522 } 525 }
523 } 526 }
524 -.p1{  
525 - line-height:18px; 527 +.p1 {
  528 + line-height: 18px;
526 } 529 }
527 </style> 530 </style>
528 \ No newline at end of file 531 \ No newline at end of file
src/views/standard/test/index.vue
@@ -32,6 +32,9 @@ @@ -32,6 +32,9 @@
32 multiple 32 multiple
33 collapse-tags 33 collapse-tags
34 > 34 >
  35 + <el-checkbox v-model="classAll" @change="selectAll" class="select-all"
  36 + >全选</el-checkbox
  37 + >
35 <el-option 38 <el-option
36 :disabled=" 39 :disabled="
37 query.classIds.length == 1 && query.classIds[0] == item.value 40 query.classIds.length == 1 && query.classIds[0] == item.value
@@ -525,12 +528,7 @@ @@ -525,12 +528,7 @@
525 </p> 528 </p>
526 </div> 529 </div>
527 <div v-show="query.classIds.length > 1" class="table-box"> 530 <div v-show="query.classIds.length > 1" class="table-box">
528 - <el-empty  
529 - :imag-size="48"  
530 - v-if="!classTableLen && !loading"  
531 - description="暂无数据"  
532 - ></el-empty>  
533 - <div class="head-box" v-if="classTableLen"> 531 + <div class="head-box">
534 <div class="tit"> 532 <div class="tit">
535 <p class="txt">已考试卷信息</p> 533 <p class="txt">已考试卷信息</p>
536 <p> 534 <p>
@@ -552,7 +550,12 @@ @@ -552,7 +550,12 @@
552 ></el-button> 550 ></el-button>
553 </el-input> 551 </el-input>
554 </div> 552 </div>
555 - <ul class="tab-ul"> 553 + <el-empty
  554 + :imag-size="48"
  555 + v-if="!classTableLen && !loading"
  556 + description="暂无数据"
  557 + ></el-empty>
  558 + <ul class="tab-ul" v-if="classTableLen">
556 <template v-for="(item, index) in classTable"> 559 <template v-for="(item, index) in classTable">
557 <li class="tab-li"> 560 <li class="tab-li">
558 <p class="tab-tit"> 561 <p class="tab-tit">
@@ -681,6 +684,7 @@ export default { @@ -681,6 +684,7 @@ export default {
681 total: 0, 684 total: 0,
682 multipleSelection: [], //选中的试卷ID 685 multipleSelection: [], //选中的试卷ID
683 classTable: [], //多班级数据 686 classTable: [], //多班级数据
  687 + classAll: false, //搜索条件多班全选
684 }; 688 };
685 }, 689 },
686 computed: { 690 computed: {
@@ -731,6 +735,17 @@ export default { @@ -731,6 +735,17 @@ export default {
731 }); 735 });
732 }, 736 },
733 methods: { 737 methods: {
  738 + //搜索条件多班全选
  739 + selectAll(val) {
  740 + this.query.classIds = [];
  741 + if (val) {
  742 + this.classList.forEach((item) => {
  743 + this.query.classIds.push(item.value);
  744 + });
  745 + } else {
  746 + this.query.classIds.push(this.classList[0].value);
  747 + }
  748 + },
734 // 多班级选择同一试卷 749 // 多班级选择同一试卷
735 checkboxDisabled(obj) { 750 checkboxDisabled(obj) {
736 let id = this.multipleSelection[0] || ""; 751 let id = this.multipleSelection[0] || "";
@@ -943,7 +958,12 @@ export default { @@ -943,7 +958,12 @@ export default {
943 this._QueryData(); 958 this._QueryData();
944 }, 959 },
945 //切换班级 960 //切换班级
946 - async changeclass() { 961 + async changeclass(list) {
  962 + if (list.length == this.classList.length) {
  963 + this.classAll = true;
  964 + } else {
  965 + this.classAll = false;
  966 + }
947 if (this.query.classIds.length == 0) { 967 if (this.query.classIds.length == 0) {
948 this.$message.warning("请至少选择一个班级!"); 968 this.$message.warning("请至少选择一个班级!");
949 } 969 }
@@ -1078,11 +1098,11 @@ export default { @@ -1078,11 +1098,11 @@ export default {
1078 if (!query.classId) { 1098 if (!query.classId) {
1079 //多班级 1099 //多班级
1080 this.classTable = []; 1100 this.classTable = [];
1081 - let classIds = [] 1101 + let classIds = [];
1082 let tableData = []; 1102 let tableData = [];
1083 data?.list?.map((item) => { 1103 data?.list?.map((item) => {
1084 - if(!classIds.includes(item.classId)){  
1085 - classIds.push(item.classId) 1104 + if (!classIds.includes(item.classId)) {
  1105 + classIds.push(item.classId);
1086 } 1106 }
1087 let idx = classIds.indexOf(item.classId); 1107 let idx = classIds.indexOf(item.classId);
1088 if (tableData[idx]) { 1108 if (tableData[idx]) {
@@ -1377,4 +1397,7 @@ div::-webkit-scrollbar-thumb { @@ -1377,4 +1397,7 @@ div::-webkit-scrollbar-thumb {
1377 background: transparent; 1397 background: transparent;
1378 } 1398 }
1379 } 1399 }
  1400 +.select-all {
  1401 + padding-left: 16px;
  1402 +}
1380 </style> 1403 </style>
1381 \ No newline at end of file 1404 \ No newline at end of file