|
|
@@ -13,9 +13,9 @@ |
|
|
|
<span>考试时间:{{dataOne.EaxmStartTime}}{{dataOne.EaxmEndTime}}</span> |
|
|
|
</div> |
|
|
|
<ul class="StuList" style="overflow:scroll;height:600px"> |
|
|
|
<li v-for="item in StuList" :key="item.SitNumber" :style="{width:width,float:'left',padding:'36px 10px',height:'58px',textAlign:'center'}"> |
|
|
|
<li v-for="item in SeatList" :key="item.SitNumber" :style="{width:width,float:'left',padding:'36px 10px',height:'58px',textAlign:'center'}"> |
|
|
|
<div class="content" style="border:1px solid #ccc;padding:6px;"> |
|
|
|
<div>{{item.StuName}}</div> |
|
|
|
<div>{{item.StuName||'-'}}</div> |
|
|
|
{{item.SitNumber}} |
|
|
|
</div> |
|
|
|
</li> |
|
|
@@ -28,6 +28,7 @@ |
|
|
|
data() { |
|
|
|
return { |
|
|
|
StuList: [], |
|
|
|
SeatList: [], |
|
|
|
dataOne: {}, |
|
|
|
StuListColumns: [], |
|
|
|
width: '10%', |
|
|
@@ -50,46 +51,46 @@ |
|
|
|
cache: false, |
|
|
|
success: (res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
let SeatList = [] |
|
|
|
this.StuList = res.data.StuList || [] |
|
|
|
this.dataOne = res.data.dataOne || {} |
|
|
|
if (!this.StuList.length) { |
|
|
|
this.isEmpty = true |
|
|
|
return |
|
|
|
this.dataOne = res.data.dataOne |
|
|
|
//多少列 |
|
|
|
let cols = this.dataOne.SeatColumns |
|
|
|
//多少行 |
|
|
|
let rows = this.dataOne.SeatRows |
|
|
|
//总座位数 |
|
|
|
let total = cols * rows |
|
|
|
//初始化座位 |
|
|
|
for (let i = 0; i < total; i++) { |
|
|
|
let SitNumber = i + 1 |
|
|
|
if (String(SitNumber).length == 1) SitNumber = '00' + String(SitNumber); |
|
|
|
if (String(SitNumber).length == 2) SitNumber = '0' + String(SitNumber) |
|
|
|
SeatList.push({ |
|
|
|
SitNumber, |
|
|
|
StuName: '', |
|
|
|
StuNo:'' |
|
|
|
}) |
|
|
|
} |
|
|
|
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) |
|
|
|
//列的宽度 |
|
|
|
this.width = 100 / cols + '%' |
|
|
|
function arrayToMatrix(arr, size) { |
|
|
|
var matrix = [], index = 0; |
|
|
|
for (var i = 0; i < arr.length; i += size) { |
|
|
|
let pushArr = arr.slice(i, i + size) |
|
|
|
if (index % 2 !== 0) pushArr.reverse(); |
|
|
|
index += 1 |
|
|
|
matrix.push(pushArr); |
|
|
|
} |
|
|
|
return matrix; |
|
|
|
} |
|
|
|
SeatList = arrayToMatrix(SeatList, rows) |
|
|
|
for (let row = 0; row < rows; row++) { |
|
|
|
for (let col = 0; col < cols; col++) { |
|
|
|
let item = SeatList[col][row] |
|
|
|
let obj = this.StuList.find(e => e.SitNumber == item.SitNumber) |
|
|
|
this.SeatList.push(obj || item) |
|
|
|
} |
|
|
|
}) |
|
|
|
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) { |
|
|
|