|
@@ -29,21 +29,25 @@
|
|
|
<span class="table-info-label">{{$t('stuAccount.importInfo1')}}</span>
|
|
|
<span class="table-info-num">{{totalNum}}</span>
|
|
|
</div>
|
|
|
- <div class="table-info-item">
|
|
|
+ <div class="table-info-item" v-if="repeatNum != 0">
|
|
|
<span class="table-info-label">{{$t('stuAccount.importInfo2')}}</span>
|
|
|
<span class="table-info-num">{{repeatNum}}</span>
|
|
|
</div>
|
|
|
- <div class="table-info-item">
|
|
|
+ <div class="table-info-item" v-if="seatRepeatNum != 0">
|
|
|
<span class="table-info-label">{{$t('stuAccount.importInfo3')}}</span>
|
|
|
- <span class="table-info-num">{{existNum}}</span>
|
|
|
+ <span class="table-info-num">{{seatRepeatNum}}</span>
|
|
|
</div>
|
|
|
- <div class="table-info-item">
|
|
|
+ <div class="table-info-item" v-if="noClassroomNum != 0">
|
|
|
<span class="table-info-label">{{$t('stuAccount.importInfo4')}}</span>
|
|
|
<span class="table-info-num">{{noClassroomNum}}</span>
|
|
|
</div>
|
|
|
|
|
|
- <div class="table-info-item">
|
|
|
+ <div class="table-info-item" v-if="existNum != 0">
|
|
|
<span class="table-info-label">{{$t('stuAccount.importInfo5')}}</span>
|
|
|
+ <span class="table-info-num">{{existNum}}</span>
|
|
|
+ </div>
|
|
|
+ <div class="table-info-item" style="display:none;">
|
|
|
+ <span class="table-info-label">{{$t('stuAccount.importInfo6')}}</span>
|
|
|
<span class="table-info-num">{{totalNum - repeatNum - existNum}}</span>
|
|
|
</div>
|
|
|
<!--<div class="table-info-item">
|
|
@@ -55,12 +59,13 @@
|
|
|
<p>{{(row.password == '' || row.password == null)? '— —' : row.password+''}}</p>
|
|
|
</template>
|
|
|
<template slot-scope="{ row,index }" slot="status">
|
|
|
- <p :class="(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.account) == -1) ? 'account-success-tips':'account-error-tips'">{{(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.account) == -1)?"":"警告:账号重复!" }}</p>
|
|
|
- <p :class="(row.classroomCode == '' || row.classroomCode == null) ? 'account-warning-tips':''">{{(row.classroomCode == '' || row.classroomCode == null)?"注意:未找到指定教室":"" }}</p>
|
|
|
+ <p :class="(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.account) == -1) ? 'account-success-tips':'account-error-tips'">{{(repeatAccounts.length == 0 || repeatAccounts.indexOf(row.account) == -1)?"":"错误:账号重复!" }}</p>
|
|
|
+ <p :class="(row.classroomCode == '' || row.classroomCode == null) ? 'account-warning-tips':''">{{(row.classroomCode == '' || row.classroomCode == null)?"警告 :未找到指定教室":"" }}</p>
|
|
|
+ <p :class="row.seatRepeat? 'account-error-tips':''">{{row.seatRepeat ? "错误:座位号重复":"" }}</p>
|
|
|
</template>
|
|
|
</Table>
|
|
|
<p style="margin-top:15px;">{{$t('stuAccount.passwordTips')}}</p>
|
|
|
- <Button class="confirm-btn confirm-btn-active" :loading="uploadLoading" @click="saveFileData">
|
|
|
+ <Button class="confirm-btn" :class=" isError == 0 ?'confirm-btn-active':'' " :loading="uploadLoading" @click="saveFileData">
|
|
|
{{$t('stuAccount.submitList')}}
|
|
|
</Button>
|
|
|
</div>
|
|
@@ -85,9 +90,10 @@
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- totalNum:0,
|
|
|
+ totalNum: 0,
|
|
|
+ seatRepeatNum:0,
|
|
|
repeatNum: 0,
|
|
|
- existNum:0,
|
|
|
+ existNum: 0,
|
|
|
repeatAccounts:[],
|
|
|
noClassroomNum:0,
|
|
|
uploadLoading: false,
|
|
@@ -104,13 +110,17 @@
|
|
|
'password',
|
|
|
'name',
|
|
|
'classroomName',
|
|
|
- 'classroomCode'
|
|
|
+ 'classroomCode',
|
|
|
+ 'seatNo'
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
},
|
|
|
computed: {
|
|
|
+ isError() {
|
|
|
+ return this.seatRepeatNum + this.repeatNum + this.existNum + this.noClassroomNum;
|
|
|
+ },
|
|
|
show: {
|
|
|
get() {
|
|
|
return this.isShow;
|
|
@@ -123,9 +133,15 @@
|
|
|
watch: {
|
|
|
},
|
|
|
methods: {
|
|
|
+ getSelectInfo() {
|
|
|
+
|
|
|
+ },
|
|
|
+ cancelAll() {
|
|
|
+
|
|
|
+ },
|
|
|
rowClassName(row, index) {
|
|
|
let className = ''
|
|
|
- if (!(this.repeatAccounts.length == 0 || this.repeatAccounts.indexOf(row.account) == -1)) {
|
|
|
+ if (!(this.repeatAccounts.length == 0 || this.repeatAccounts.indexOf(row.account) == -1) || row.seatRepeat) {
|
|
|
className = className + 'account-error-row-bg ';
|
|
|
}
|
|
|
if (row.classroomCode == '' || row.classroomCode == null) {
|
|
@@ -188,12 +204,10 @@
|
|
|
let flag = true;
|
|
|
let column = '';
|
|
|
for (let item of this.systemColumn) {
|
|
|
- console.log(item);
|
|
|
let f = 0;
|
|
|
for (let i of columns) {
|
|
|
if (i == item) {
|
|
|
f = 1;
|
|
|
-
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -205,16 +219,17 @@
|
|
|
}
|
|
|
if (flag) {
|
|
|
//处理表格导入数据类型
|
|
|
- console.log(results);
|
|
|
this.tableData = results.filter(item => {
|
|
|
let arr = item.account.split("#");
|
|
|
if (arr.length == 2) {
|
|
|
for (let i of this.systemColumn) {
|
|
|
- if (typeof item[i] == "number") {
|
|
|
- item[i] = item[i] + "";
|
|
|
- }
|
|
|
- if (item.password == undefined) {
|
|
|
- item.password = arr[1]
|
|
|
+ if (i != 'seatNo') {
|
|
|
+ if (typeof item[i] == "number") {
|
|
|
+ item[i] = item[i] + "";
|
|
|
+ }
|
|
|
+ if (item.password == undefined) {
|
|
|
+ item.password = arr[1]
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -223,25 +238,40 @@
|
|
|
}
|
|
|
return item;
|
|
|
});
|
|
|
- console.log(this.tableData);
|
|
|
//计算重复账号数量和重复账号,过滤重复账号
|
|
|
this.totalNum = this.tableData.length;
|
|
|
let accounts = this.tableData.map(item => { return item.account });
|
|
|
this.repeatAccounts = accounts.filter((item, index, self) => self.indexOf(item) != index);
|
|
|
this.repeatAccounts = this.repeatAccounts.filter((item, index, self) => self.indexOf(item) === index);
|
|
|
- this.tableData = this.tableData.filter((item, index, self) => {
|
|
|
- if (accounts.indexOf(item.account) === index) {
|
|
|
- return 1;
|
|
|
- } else {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- console.log(this.tableData);
|
|
|
+ //直接过滤重复账号
|
|
|
+ //this.tableData = this.tableData.filter((item, index, self) => {
|
|
|
+ // if (accounts.indexOf(item.account) === index) {
|
|
|
+ // return 1;
|
|
|
+ // } else {
|
|
|
+ // return 0;
|
|
|
+ // }
|
|
|
+ //});
|
|
|
accounts = accounts.filter((item, index, self) => self.indexOf(item) === index);
|
|
|
- this.repeatNum = this.totalNum - accounts.length;
|
|
|
-
|
|
|
-
|
|
|
+ this.repeatNum = this.totalNum - accounts.length + this.repeatAccounts.length;
|
|
|
+ //根据教室Code GroupBy,判断班级座位号是否重复
|
|
|
+ console.log("++++++++++");
|
|
|
+ let classStu = this.groupBy(this.tableData, 'classroomCode');
|
|
|
+ for (let item of classStu) {
|
|
|
+ let seatNoArr = item.map(item => { return item.seatNo });
|
|
|
+ for (let index in item) {
|
|
|
+ let flag = seatNoArr.indexOf(item[index]['seatNo'])
|
|
|
+ if (flag != index) {
|
|
|
+ let tableIndex = this.getIndex(this.tableData, item[flag]);
|
|
|
+ if (this.tableData[tableIndex].seatRepeat != true) {
|
|
|
+ this.seatRepeatNum++;
|
|
|
+ this.tableData[tableIndex].seatRepeat = true;
|
|
|
+ }
|
|
|
+ tableIndex = this.getIndex(this.tableData, item[index]);
|
|
|
+ this.tableData[tableIndex].seatRepeat = true;
|
|
|
+ this.seatRepeatNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//筛选没有教室账号
|
|
|
let noRoom = this.tableData.filter(item => { return (item.classroomCode == '' || item.classroomCode == null) });
|
|
|
this.noClassroomNum = noRoom.length;
|
|
@@ -257,19 +287,65 @@
|
|
|
this.showRemoveFile = true;
|
|
|
}
|
|
|
},
|
|
|
+ groupBy(array, key) {
|
|
|
+ const groups = {}
|
|
|
+ array.forEach(function (item) {
|
|
|
+ const group = JSON.stringify(item[key])
|
|
|
+ groups[group] = groups[group] || []
|
|
|
+ groups[group].push(item)
|
|
|
+ })
|
|
|
+ return Object.keys(groups).map(function (group) {
|
|
|
+ return groups[group]
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /*
|
|
|
+ *获取对象在对象数组的中index
|
|
|
+ */
|
|
|
+ getIndex(_arr, _obj) {
|
|
|
+ var len = _arr.length;
|
|
|
+ for (let i = 0; i < len; i++) {
|
|
|
+ if (this.isObjEqual(_arr[i],_obj)) {
|
|
|
+ return parseInt(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ },
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 判断两个json对象是否相同
|
|
|
+ */
|
|
|
+ isObjEqual(o1, o2) {
|
|
|
+ var props1 = Object.keys(o1);
|
|
|
+ var props2 = Object.keys(o2);
|
|
|
+ console.log(props1);
|
|
|
+ if (props1.length != props2.length) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ for (var i = 0, max = props1.length; i < max; i++) {
|
|
|
+ var propName = props1[i];
|
|
|
+ if (o1[propName] !== o2[propName]) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
saveFileData() {
|
|
|
- this.uploadLoading = true;
|
|
|
-
|
|
|
- if (this.repeatNum != 0) {
|
|
|
- let accounts = this.tableData.map(item => { return item.account });
|
|
|
- let repeat = accounts.filter((item, index, self) => self.indexOf(item) != index);
|
|
|
- this.tableData = this.tableData.filter((item, index, self) => repeat.indexOf(item.account) === -1)
|
|
|
+ if (this.isError == 0) {
|
|
|
+ this.uploadLoading = true;
|
|
|
+ //if (this.repeatNum != 0) {
|
|
|
+ // let accounts = this.tableData.map(item => { return item.account });
|
|
|
+ // let repeat = accounts.filter((item, index, self) => self.indexOf(item) != index);
|
|
|
+ // this.tableData = this.tableData.filter((item, index, self) => repeat.indexOf(item.account) === -1)
|
|
|
+ //}
|
|
|
+ this.$emit("importStudentInfo", {
|
|
|
+ data: this.tableData
|
|
|
+ });
|
|
|
+ this.initData();
|
|
|
+ this.uploadLoading = false;
|
|
|
+ } else {
|
|
|
+ this.$Message.error(this.$t('stuAccount.importTips12'));
|
|
|
}
|
|
|
- this.$emit("importStudentInfo", {
|
|
|
- data: this.tableData
|
|
|
- });
|
|
|
- this.initData();
|
|
|
- this.uploadLoading = false;
|
|
|
+
|
|
|
},
|
|
|
cancel() {
|
|
|
this.initData();
|
|
@@ -281,6 +357,7 @@
|
|
|
this.totalNum = 0;
|
|
|
this.repeatNum = 0;
|
|
|
this.existNum = 0;
|
|
|
+ this.seatRepeatNum = 0;
|
|
|
this.repeatAccounts = [];
|
|
|
this.noClassroomNum = 0;
|
|
|
this.uploadLoading = false;
|
|
@@ -295,6 +372,11 @@
|
|
|
width: 80,
|
|
|
align: 'center'
|
|
|
},
|
|
|
+ {
|
|
|
+ title: this.$t('stuAccount.seatNo'),
|
|
|
+ key: 'seatNo',
|
|
|
+ width: 80,
|
|
|
+ },
|
|
|
{
|
|
|
title: this.$t('stuAccount.account'),
|
|
|
key:'account'
|