From 3fa0dab14cb55301ca6bda581168b76490717f63 Mon Sep 17 00:00:00 2001 From: yxq Date: Sun, 23 Apr 2023 15:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=BA=E6=AC=A1=E5=AE=89=E6=8E=92=E8=A1=A8?= =?UTF-8?q?=20=E5=BA=A7=E4=BD=8D=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Exam_ArrangeExamTermNew/SeatForm.cshtml | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ArrangeExamTermNew/SeatForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ArrangeExamTermNew/SeatForm.cshtml index 9d7763c13..6172674ec 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ArrangeExamTermNew/SeatForm.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/Exam_ArrangeExamTermNew/SeatForm.cshtml @@ -54,9 +54,43 @@ this.dataOne = res.data.dataOne || {} if (!this.StuList.length) { this.isEmpty = true + return } - //this.dataOne.SeatColumns = 12 - this.width = 100 / (this.dataOne.SeatColumns || 10) + '%' + this.width = 100 / this.dataOne.SeatColumns + '%' + //1列:[],2:[] + let data = {} + //计算出多少行 + let rows = Math.ceil(res.data.StuList.length / this.dataOne.SeatColumns); + if (rows == 1) return + //最后一行个数(行全的列数) + let lastRow = res.data.StuList.length % this.dataOne.SeatColumns + lastRow = lastRow || this.dataOne.SeatColumns + //不缺一行的列数据总个数 + let wholeItems = rows * lastRow + let colCurrent = 1 + this.StuList.forEach((e, i) => { + if (i + 1 <= wholeItems) { + colCurrent = Math.ceil((i + 1) / rows) + colCurrent = colCurrent || 1 + if (!data[colCurrent]) data[colCurrent] = [] + data[colCurrent].push(e) + } else { + let colCurrent_ = Math.ceil((i + 1 - wholeItems) / (rows-1)) + colCurrent_ = colCurrent_ || 1 + if (!data[colCurrent_ + colCurrent]) data[colCurrent_ + colCurrent] = [] + data[colCurrent_ + colCurrent].push(e) + } + }) + console.log(data) + let arr = [] + for (let i = 0; i < rows; i++) { + Object.values(data).forEach(e => { + if (e[i]) { + arr.push(e[i]) + } + }) + } + this.StuList = arr } }, error: function (XMLHttpRequest, textStatus, errorThrown) {