parent
1c1c28a93a
commit
dfa5632b29
39 changed files with 1266 additions and 718 deletions
@ -1,565 +1,66 @@ |
||||
<template> |
||||
<div> |
||||
<breadcrumb :data="'学生管理/学生列表'"></breadcrumb> |
||||
<breadcrumb :data="'学生管理/' + tabs[active]" ref="breadcrumb"></breadcrumb> |
||||
<div class="page"> |
||||
<div class="tabs"> |
||||
<a class="item active">学生列表</a> |
||||
<a class="item" v-for="(item,index) in tabs" :key="index" :class="{active: index == active}" @click="tabChange(index)">{{item}}</a> |
||||
</div> |
||||
<div class="page-content"> |
||||
<div class="tool"> |
||||
<ul class="filter"> |
||||
<li> |
||||
<label>筛选:</label> |
||||
<el-cascader :options="orgList" :props="props" collapse-tags clearable size="small" @change="orgChange"></el-cascader> |
||||
</li> |
||||
<li> |
||||
<label>搜索:</label> |
||||
<el-input placeholder="请输入学生名称" prefix-icon="el-icon-search" v-model="keyword" clearable size="small"></el-input> |
||||
</li> |
||||
</ul> |
||||
<div> |
||||
<el-button type="primary" size="small" round @click="addstudent" v-auth>新增学生</el-button> |
||||
<el-button type="primary" size="small" round @click="batchImport" v-auth>批量导入</el-button> |
||||
<el-button type="primary" size="small" round @click="delAllSelection" v-auth>批量删除</el-button> |
||||
</div> |
||||
</div> |
||||
<!-- <StudentSide ref="getSelectData" @fircheck="fircheck" @twocheck="twocheck" @threecheck="threecheck" @getData="getData"></StudentSide> --> |
||||
|
||||
<el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> |
||||
<el-table-column type="selection" width="80" align="center"></el-table-column> |
||||
<el-table-column type="index" label="序号" width="55" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="studentName" label="学生姓名" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="workNumber" label="学生学号" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="stuProfessionalArchitectureName" label="专业" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="gradeName" label="年级" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="className" label="班级" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="loginNumber" label="登录次数" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="lastLoginTime" label="上次登录时间" width="150" align="center"> |
||||
</el-table-column> |
||||
<el-table-column label="操作" width="180" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-button type="text" @click="editstudent(scope.row)" v-auth>编辑</el-button> |
||||
<el-button type="text" @click="resetPassword(scope.row)" v-auth>重置密码</el-button> |
||||
<el-button type="text" @click="delstudent(scope.row)" v-auth>删除</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<div class="pagination"> |
||||
<el-pagination background layout="total,prev, pager, next" :current-page="page" @current-change="handleCurrentChange" :total="total"></el-pagination> |
||||
</div> |
||||
<student v-if="active == 'student'"></student> |
||||
<organization v-else-if="active == 'organization'"></organization> |
||||
</div> |
||||
</div> |
||||
|
||||
<el-dialog :title="isAdd ? '新增学生' : '编辑学生'" :visible.sync="studentVisible" width="30%" @close="closestudent" class="dialog" :close-on-click-modal="false"> |
||||
<el-form ref="studentForm" :model="studentForm" :rules="rules" label-width="90px"> |
||||
<el-form-item prop="account" label="账号"> |
||||
<el-input v-model="studentForm.account" placeholder="请输入学生账号" @change="accountChange"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="userName" label="学生姓名"> |
||||
<el-input v-model="studentForm.userName" placeholder="请输入学生姓名"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="uniqueIdentificationAccount" label="唯一标识"> |
||||
<el-input disabled v-model="studentForm.uniqueIdentificationAccount" placeholder="请输入学生学号获取唯一标识"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="workNumber" label="学生学号"> |
||||
<el-input v-model="studentForm.workNumber" placeholder="请输入学生学号" @change="workNumberChange"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="professionalId" label="专业"> |
||||
<el-select v-model="studentForm.professionalId" placeholder="请选择专业" @change="getGrade"> |
||||
<el-option v-for="(item,index) in orgList" :key="index" |
||||
:label="item.stuProfessionalArchitectureName" :value="item.stuProfessionalArchitectureId"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item prop="gradeId" label="年级"> |
||||
<el-select v-model="studentForm.gradeId" placeholder="请选择年级" :disabled="studentForm.professionalId ? false : true" @change="getClass"> |
||||
<el-option v-for="(item,index) in gradeList" :key="index" |
||||
:label="item.gradeName" :value="item.gradeId"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item prop="classId" label="班级"> |
||||
<el-select v-model="studentForm.classId" placeholder="请选择班级" :disabled="studentForm.gradeId ? false : true"> |
||||
<el-option v-for="(item,index) in classList" :key="index" |
||||
:label="item.className" :value="item.classId"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item prop="phone" label="手机号"> |
||||
<el-input v-model="studentForm.phone" placeholder="可以用于登录平台,以及找回密码" maxlength="11"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="邮箱"> |
||||
<el-input v-model="studentForm.email" placeholder="可以用于登录平台,以及找回密码"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button @click="studentVisible = false">取消</el-button> |
||||
<el-button type="primary" @click="saveSure('studentForm')">确定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
|
||||
<el-dialog title="批量导入" :visible.sync="importVisible" width="400px" :close-on-click-modal="false"> |
||||
<div class="upload-wrap" :class="{lg: uploadFaild}"> |
||||
<el-button class="download" size="small" @click="downLoad"><img src="../../../assets/img/download.png" alt=""> 模板下载</el-button> |
||||
<el-upload accept=".xls,.xlsx" :on-remove="handleRemove" :on-error="uploadError" :on-success="uploadSuccess" :before-remove="beforeRemove" :limit="1" :on-exceed="handleExceed" :action="this.api.uploadFileStudent" :file-list="uploadList" :data="{schoolId: this.clientId}" name="file"> |
||||
<el-button size="small"><img src="../../../assets/img/upload.png" alt=""> 上传文件</el-button> |
||||
</el-upload> |
||||
<div class="link" v-if="uploadFaild"> |
||||
<el-link type="primary" @click="showFaild">导入失败,查看原因</el-link> |
||||
</div> |
||||
</div> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button size="small" @click="importVisible = false">取 消</el-button> |
||||
<el-button size="small" type="primary" @click="uploadSure">确 定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { mapState,mapGetters } from 'vuex' |
||||
import util from '@/libs/util' |
||||
import { mapState } from 'vuex' |
||||
import Setting from '@/setting' |
||||
import student from './student.vue' |
||||
import organization from './organization.vue' |
||||
import breadcrumb from '@/components/breadcrumb' |
||||
export default { |
||||
data() { |
||||
return { |
||||
props: { multiple: true }, |
||||
orgList: [], |
||||
twoDepartmentIds: '', |
||||
studentVisible: false, |
||||
studentForm: { |
||||
clientId: this.clientId, |
||||
clientName: this.clientName, |
||||
studentId: '', |
||||
userId: '', |
||||
userName: '', |
||||
workNumber: '', |
||||
phone: '', |
||||
email: '', |
||||
professionalId: '', |
||||
gradeId: '', |
||||
classId: '' , |
||||
uniqueIdentificationAccount: '', |
||||
account: '' |
||||
}, |
||||
rules: { |
||||
userName: [ |
||||
{ required: true, message: '请输入学生姓名', trigger: 'blur' } |
||||
], |
||||
workNumber: [ |
||||
{ required: true, message: '请输入学生学号', trigger: 'blur' }, |
||||
{ |
||||
pattern: /^[A-Za-z0-9]+$/, |
||||
message: '请输入正确的学生学号', |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
account: [ |
||||
{ required: true, message: '请输入账号', trigger: 'blur' }, |
||||
{ |
||||
pattern: /^[A-Za-z0-9]*$/, |
||||
message: '请输入正确的账号', |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
professionalId: [ |
||||
{ required: true, message: '请选择专业', trigger: 'change' } |
||||
], |
||||
gradeId: [ |
||||
{ required: true, message: '请选择年级', trigger: 'change' } |
||||
], |
||||
classId: [ |
||||
{ required: true, message: '请选择班级', trigger: 'change' } |
||||
], |
||||
phone: [ |
||||
{ |
||||
pattern: /^1[3456789]\d{9}$/, |
||||
message: '请输入正确的手机号', |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
email: [ |
||||
{ |
||||
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/, |
||||
message: '请输入正确的邮箱', |
||||
trigger: 'blur' |
||||
} |
||||
] |
||||
}, |
||||
listData: [], |
||||
importVisible: false, |
||||
keyword: '', |
||||
page: 1, |
||||
pageSize: 10, |
||||
total: 0, |
||||
searchTimer: null, |
||||
gradeList: [], |
||||
classList: [], |
||||
professionalIds: '', |
||||
professionalStudentIds: '', |
||||
gradeIds: '', |
||||
classIds: '', |
||||
multipleSelection: [], |
||||
uploadList: [], |
||||
parmData: [], |
||||
uploadFaild: false, |
||||
token: '', |
||||
schooldId: 1, |
||||
isAdd: true, |
||||
accountRepeat: false, |
||||
workNumberRepeat: false, |
||||
originalAccount: '', |
||||
originalWorkNumber: '' |
||||
active: 'student', |
||||
tabs: { |
||||
student: '学生管理', |
||||
organization: '架构管理' |
||||
} |
||||
}; |
||||
}, |
||||
computed: { |
||||
...mapState('user', [ |
||||
'userId','clientId','clientName' |
||||
]) |
||||
}, |
||||
components: { |
||||
student, |
||||
organization, |
||||
breadcrumb |
||||
}, |
||||
watch: { |
||||
keyword: function(val) { |
||||
clearTimeout(this.searchTimer) |
||||
this.searchTimer = setTimeout(() => { |
||||
this.getData() |
||||
},500) |
||||
} |
||||
computed: { |
||||
...mapState('auth', [ |
||||
'btns' |
||||
]) |
||||
}, |
||||
mounted(){ |
||||
this.getOrg() |
||||
this.studentForm.clientId = this.clientId |
||||
this.studentForm.clientName = this.clientName |
||||
this.getData() |
||||
created() { |
||||
Setting.dynamicRoute && this.initTabs() |
||||
}, |
||||
methods: { |
||||
getOrg(){ |
||||
let data = { |
||||
schoolId: this.clientId |
||||
} |
||||
this.$get(this.api.queryStudentProfessionalArchitecture,data).then(res => { |
||||
let StaffProfessionalArchitectureList = res.data.StaffProfessionalArchitectureList |
||||
if(StaffProfessionalArchitectureList){ |
||||
StaffProfessionalArchitectureList.map(e => { |
||||
e.isParent = true |
||||
e.value = e.stuProfessionalArchitectureId |
||||
e.label = e.stuProfessionalArchitectureName |
||||
let data = { |
||||
stuProfessionalArchitectureId: e.stuProfessionalArchitectureId |
||||
} |
||||
this.$get(this.api.queryGrade,data).then(res => { |
||||
e.children = res.data.Grade |
||||
e.children.map(e => { |
||||
e.value = e.gradeId |
||||
e.label = e.gradeName |
||||
let data = { |
||||
gradeId: e.gradeId |
||||
} |
||||
this.$get(this.api.queryClass,data).then(res => { |
||||
res.data.Class.map(e => { |
||||
e.value = e.classId |
||||
e.label = e.className |
||||
}) |
||||
e.children = res.data.Class |
||||
}).catch(res => {}) |
||||
}) |
||||
}).catch(res => {}) |
||||
}) |
||||
setTimeout(() => { |
||||
this.orgList = StaffProfessionalArchitectureList |
||||
}, 500) |
||||
} |
||||
}).catch(res => {}) |
||||
}, |
||||
getData(){ |
||||
let data = { |
||||
searchContent: this.keyword, |
||||
professionalIds: this.professionalStudentIds, |
||||
gradeIds: this.gradeIds, |
||||
classIds: this.classIds, |
||||
schoolId: this.clientId |
||||
} |
||||
this.$get(`${this.api.queryStudent}/${this.page}/${this.pageSize}`,data).then(res => { |
||||
this.listData = res.data.studentList |
||||
this.total = res.data.total |
||||
}).catch(res => {}) |
||||
}, |
||||
orgChange(node){ |
||||
this.classIds = node.map(n => n[2]).toString() |
||||
this.getData() |
||||
}, |
||||
closestudent(){ |
||||
this.$refs.studentForm.resetFields() |
||||
}, |
||||
addstudent(){ |
||||
this.studentForm.studentId = '' |
||||
this.studentVisible = true |
||||
this.isAdd = true |
||||
}, |
||||
editstudent(row){ |
||||
this.studentVisible = true |
||||
this.isAdd = false |
||||
this.studentForm.studentId = row.studentId |
||||
this.studentForm.userId = row.userId |
||||
this.$get(`${this.api.getStudent}/${row.studentId}`).then(res => { |
||||
let student = res.data.student |
||||
let userInfo = res.data.userInfo |
||||
this.studentForm.userName = userInfo.userName, |
||||
this.studentForm.workNumber = student.workNumber, |
||||
this.originalWorkNumber = student.workNumber, |
||||
this.studentForm.uniqueIdentificationAccount = userInfo.uniqueIdentificationAccount, |
||||
this.studentForm.professionalId = student.professionalId, |
||||
this.studentForm.gradeId = student.gradeId, |
||||
this.studentForm.classId = student.classId, |
||||
this.studentForm.phone = userInfo.phone, |
||||
this.studentForm.email = userInfo.email, |
||||
this.studentForm.account = userInfo.account |
||||
this.originalAccount = userInfo.account |
||||
this.getGradeData() |
||||
this.getClassData() |
||||
}).catch(res => {}); |
||||
}, |
||||
resetPassword(row){ |
||||
this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, '提示',).then(() => { |
||||
let data = { |
||||
userId: row.userId, |
||||
password: Setting.initialPassword |
||||
} |
||||
this.$post(this.api.userinfoUpdate,data).then(res => { |
||||
if(res.success){ |
||||
util.successMsg('重置成功') |
||||
}else{ |
||||
util.errorMsg('重置失败') |
||||
} |
||||
}).catch(res => {}) |
||||
}).catch(() => {}) |
||||
}, |
||||
// 获取年级 |
||||
getGrade(){ |
||||
this.studentForm.gradeId = '' |
||||
this.studentForm.classId = '' |
||||
this.getGradeData() |
||||
}, |
||||
getGradeData(){ |
||||
let data = { |
||||
stuProfessionalArchitectureId: this.studentForm.professionalId |
||||
} |
||||
this.$get(this.api.queryGrade,data).then(res => { |
||||
this.gradeList = res.data.Grade |
||||
}).catch(res => {}); |
||||
}, |
||||
//获取班级 |
||||
getClass(){ |
||||
this.studentForm.classId = '' |
||||
this.getClassData() |
||||
}, |
||||
getClassData(){ |
||||
let data = { |
||||
gradeId: this.studentForm.gradeId |
||||
} |
||||
this.$get(this.api.queryClass,data).then(res => { |
||||
this.classList = res.data.Class |
||||
}).catch(res => {}); |
||||
tabChange(index){ |
||||
this.active = index |
||||
this.$refs.breadcrumb.update('学生管理/' + this.tabs[this.active]) |
||||
}, |
||||
async accountChange(){ |
||||
if(this.studentForm.account !== this.originalAccount){ |
||||
this.$get(`${this.api.getAccount}?account=${this.studentForm.account}`).then(res => { |
||||
if(res.data.userInfo){ |
||||
this.accountRepeat = true |
||||
util.warningMsg('该账号已存在') |
||||
}else{ |
||||
this.accountRepeat = false |
||||
} |
||||
}).catch(res => {}) |
||||
}else{ |
||||
this.accountRepeat = false |
||||
} |
||||
}, |
||||
workNumberChange(){ |
||||
if(this.studentForm.workNumber !== this.originalWorkNumber){ |
||||
this.$get(`${this.api.studentGetWorkNumber}?workNumber=${this.studentForm.workNumber}`).then(res => { |
||||
if(res.data.student){ |
||||
this.workNumberRepeat = true |
||||
util.warningMsg('该学号已存在') |
||||
}else{ |
||||
this.workNumberRepeat = false |
||||
} |
||||
}).catch(res => {}) |
||||
}else{ |
||||
this.workNumberRepeat = false |
||||
} |
||||
}, |
||||
saveSure(studentForm){ |
||||
this.$refs[studentForm].validate((valid) => { |
||||
if (valid) { |
||||
if(this.accountRepeat) return util.warningMsg('该账号已存在') |
||||
if(this.workNumberRepeat) return util.warningMsg('该学号已存在') |
||||
let data = { |
||||
userInfo: { |
||||
isPort: 2, |
||||
roleId: 4, |
||||
clientId: this.studentForm.clientId, |
||||
clientName: this.studentForm.clientName, |
||||
userName: this.studentForm.userName, |
||||
account: this.studentForm.account, |
||||
phone: this.studentForm.phone, |
||||
email: this.studentForm.email, |
||||
uniqueIdentificationAccount: this.studentForm.uniqueIdentificationAccount, |
||||
userId: this.studentForm.userId ? this.studentForm.userId : '' |
||||
}, |
||||
student: { |
||||
userId: this.studentForm.userId, |
||||
studentId: this.studentForm.studentId, |
||||
roleId: 4, |
||||
isPort: 2, |
||||
clientId: this.studentForm.clientId, |
||||
clientName: this.studentForm.clientName, |
||||
professionalId: this.studentForm.professionalId, |
||||
gradeId: this.studentForm.gradeId, |
||||
classId: this.studentForm.classId, |
||||
workNumber: this.studentForm.workNumber, |
||||
} |
||||
} |
||||
if(this.studentForm.studentId){ |
||||
this.$post(this.api.updateStudent,data).then(res => { |
||||
this.studentVisible = false |
||||
util.successMsg('编辑成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
}else{ |
||||
this.$post(this.api.addStudent,data).then(res => { |
||||
this.studentVisible = false |
||||
util.successMsg('添加成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
} |
||||
}else{ |
||||
return false; |
||||
} |
||||
}) |
||||
}, |
||||
delstudent(row){ |
||||
this.$confirm('此删除操作不可逆,是否确认删除选中项?', '提示', { |
||||
type: 'warning' |
||||
}) |
||||
.then(() => { |
||||
let data = { |
||||
studentIds: row.studentId |
||||
} |
||||
this.$del(this.api.deleteStudents,data).then(res => { |
||||
util.successMsg('删除成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
}) |
||||
.catch(() => {}); |
||||
}, |
||||
handleSelectionChange(val) { |
||||
this.multipleSelection = val; |
||||
}, |
||||
delAllSelection() { |
||||
if(this.multipleSelection.length != ''){ |
||||
let newArr = this.multipleSelection |
||||
let delList = newArr.map(item => { |
||||
return item.studentId |
||||
}) |
||||
// 批量删除 |
||||
this.$confirm(`此批量删除操作不可逆,是否确认删除${util.ellipsisStr(newArr[0].studentName)}等${newArr.length}个选中项?`, '提示', { |
||||
type: 'warning' |
||||
}) |
||||
.then(() => { |
||||
let data = { |
||||
studentIds: delList.join() |
||||
} |
||||
this.$del(this.api.deleteStudents,data).then(res => { |
||||
this.multipleSelection = [] |
||||
util.successMsg('删除成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
}).catch(() => {}); |
||||
}else{ |
||||
util.errorMsg('请先选择学生') |
||||
} |
||||
}, |
||||
batchImport(){ |
||||
this.importVisible = true |
||||
}, |
||||
searchstudent(){ |
||||
this.page = 1 |
||||
this.getData() |
||||
}, |
||||
handleCurrentChange(val) { |
||||
this.page = val; |
||||
this.getData(); |
||||
}, |
||||
downLoad(){ |
||||
location.href = this.api.downloadStudentTemp |
||||
}, |
||||
// 上传文件 |
||||
handleExceed(files, fileList) { |
||||
util.warningMsg( |
||||
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` |
||||
); |
||||
}, |
||||
showFaild(){ |
||||
location.href = `${this.api.exportFailureStudent}?token=${this.token}` |
||||
}, |
||||
uploadSuccess(res, file, fileList) { |
||||
this.uploadFaild = false |
||||
if(res.success){ |
||||
if(res.data.data.token){ |
||||
this.token = res.data.data.token |
||||
this.uploadFaild = true |
||||
}else{ |
||||
util.successMsg('上传成功') |
||||
} |
||||
}else{ |
||||
res.data.message ? util.errorMsg(res.data.message) : util.errorMsg('上传失败,请检查数据') |
||||
initTabs(){ |
||||
let tab1 = this.btns.includes('学生管理:学生管理') |
||||
let tab2 = this.btns.includes('学生管理:架构管理') |
||||
|
||||
if(!tab1 && tab2){ |
||||
this.active = 'organization' |
||||
} |
||||
}, |
||||
uploadError(err, file, fileList) { |
||||
this.$message({ |
||||
message: "上传出错,请重试!", |
||||
type: "error", |
||||
center: true |
||||
}); |
||||
}, |
||||
beforeRemove(file, fileList) { |
||||
return this.$confirm(`确定移除 ${file.name}?`); |
||||
}, |
||||
handleRemove(file, fileList) { |
||||
this.uploadList = fileList |
||||
this.uploadFaild = false |
||||
}, |
||||
uploadSure(){ |
||||
this.importVisible = false |
||||
this.page = 1 |
||||
this.classIds = '' |
||||
this.keyword = '' |
||||
this.getData() |
||||
if(!tab1) delete this.tabs.student |
||||
if(!tab2) delete this.tabs.organization |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
/deep/.dialog{ |
||||
.el-form-item{ |
||||
.el-form-item__label{ |
||||
font-size: 16px; |
||||
color: rgba(0, 0, 0, 0.65); |
||||
&:before{ |
||||
margin-right: 0; |
||||
color: #CC221C; |
||||
} |
||||
} |
||||
} |
||||
.el-input,.el-select{ |
||||
width: 100%; |
||||
} |
||||
} |
||||
|
||||
<style lang="scss" scopted> |
||||
|
||||
</style> |
@ -0,0 +1,390 @@ |
||||
<template> |
||||
<div> |
||||
<div class="tool"> |
||||
<ul class="filter"></ul> |
||||
<div> |
||||
<el-button type="primary" size="small" round @click="addMajor" v-auth="'/student/list:架构管理:新增架构'">新增架构</el-button> |
||||
</div> |
||||
</div> |
||||
|
||||
<el-table :data="listData" stripe header-align="center" row-key="index" :tree-props="treeProps" :indent="9"> |
||||
<el-table-column prop="label" label="架构名称"> |
||||
<template slot-scope="scope"> |
||||
<span class="text">{{scope.row.label}}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="操作" width="200" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-button type="text" @click="edit(scope.row)" v-auth="'/student/list:架构管理:编辑'">编辑</el-button> |
||||
<el-button v-if="scope.row.level" type="text" @click="add(scope.row)" v-auth="'/student/list:架构管理:添加'">添加</el-button> |
||||
<el-button type="text" @click="del(scope.row)" v-auth="'/student/list:架构管理:删除'">删除</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
|
||||
<el-dialog :title="Form.classmajorId ? '编辑专业' : '新增专业'" :visible.sync="isaddClassMajor" width="460px" @close="closeAddClass" :close-on-click-modal="false"> |
||||
<el-form ref="Form" :model="Form"> |
||||
<el-form-item prop="classmajorName"> |
||||
<el-input placeholder="请输入专业名称" v-model="Form.classmajorName" @change="majorChange"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button size="small" @click="isaddClassMajor = false">取消</el-button> |
||||
<el-button size="small" type="primary" @click="sure">确定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
|
||||
<el-dialog :title="Form2.departmentId ? '编辑年级' : '新增年级'" :visible.sync="isAddDepartment" width="460px" @close="closeAddClass2" :close-on-click-modal="false"> |
||||
<el-form ref="Form2" :model="Form2"> |
||||
<el-form-item prop="departmentName"> |
||||
<el-input placeholder="请输入年级名称" v-model.number="Form2.departmentName"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button size="small" @click="isAddDepartment = false">取消</el-button> |
||||
<el-button size="small" type="primary" @click="sureDepartment">确定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
|
||||
<el-dialog :title="Form3.classId ? '编辑班级' : '新增班级'" :visible.sync="isAddClass" width="460px" @close="closeAddClass3" :close-on-click-modal="false"> |
||||
<el-form ref="Form3" :model="Form3"> |
||||
<el-form-item prop="className"> |
||||
<el-input placeholder="请输入班级名称" v-model.number="Form3.className"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button size="small" @click="isAddClass = false">取消</el-button> |
||||
<el-button size="small" type="primary" @click="sureClass('Form3')">确定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { mapState } from 'vuex' |
||||
import util from '@/libs/util' |
||||
export default { |
||||
name: 'organization', |
||||
data() { |
||||
return { |
||||
treeProps: {children: 'children', hasChildren: 'hasChildren'}, |
||||
listData: [], |
||||
isaddClassMajor: false, |
||||
isAddDepartment: false, |
||||
isAddClass: false, |
||||
Form: { |
||||
classmajorId: '', |
||||
classmajorName: '', |
||||
}, |
||||
Form2: { |
||||
departmentId: '', |
||||
departmentName: '', |
||||
}, |
||||
Form3: { |
||||
classId: '', |
||||
className: '' |
||||
}, |
||||
majorNoAdd: true, |
||||
}; |
||||
}, |
||||
computed: { |
||||
...mapState('user', [ |
||||
'clientId','clientName' |
||||
]), |
||||
}, |
||||
mounted() { |
||||
this.getData() |
||||
}, |
||||
methods: { |
||||
getData(){ |
||||
let data = { |
||||
schoolId: this.clientId |
||||
} |
||||
this.$get(this.api.queryStudentProfessionalArchitecture,data).then(res => { |
||||
let StaffProfessionalArchitectureList = res.data.StaffProfessionalArchitectureList |
||||
if(StaffProfessionalArchitectureList){ |
||||
let index = 0 |
||||
StaffProfessionalArchitectureList.map(e => { |
||||
e.level = 1 |
||||
e.id = e.stuProfessionalArchitectureId |
||||
e.label = e.stuProfessionalArchitectureName |
||||
e.index = ++index |
||||
let data = { |
||||
stuProfessionalArchitectureId: e.stuProfessionalArchitectureId |
||||
} |
||||
this.$get(this.api.queryGrade,data).then(res => { |
||||
e.children = res.data.Grade |
||||
e.children.map(e => { |
||||
e.level = 2 |
||||
e.id = e.gradeId |
||||
e.label = e.gradeName |
||||
e.index = ++index |
||||
let data = { |
||||
gradeId: e.gradeId |
||||
} |
||||
this.$get(this.api.queryClass,data).then(res => { |
||||
res.data.Class.map(e => { |
||||
e.id = e.classId |
||||
e.label = e.className |
||||
e.index = ++index |
||||
}) |
||||
e.children = res.data.Class |
||||
}).catch(res => {}) |
||||
}) |
||||
}).catch(res => {}) |
||||
}) |
||||
setTimeout(() => { |
||||
this.listData = StaffProfessionalArchitectureList |
||||
}, 500) |
||||
} |
||||
}).catch(res => {}) |
||||
}, |
||||
closeAddClass(){ |
||||
this.$refs.Form.resetFields() |
||||
}, |
||||
closeAddClass2(){ |
||||
this.$refs.Form2.resetFields() |
||||
}, |
||||
closeAddClass3(){ |
||||
this.$refs.Form3.resetFields() |
||||
}, |
||||
add(item){ |
||||
if(item.level == 1){ |
||||
this.addClassDepartment(item) |
||||
}else if(item.level == 2){ |
||||
this.addClass(item) |
||||
} |
||||
}, |
||||
edit(item){ |
||||
if(item.level == 1){ |
||||
this.editmajorClass(item) |
||||
}else if(item.level == 2){ |
||||
this.editDepartment(item) |
||||
}else{ |
||||
this.editClass(item) |
||||
} |
||||
}, |
||||
del(item){ |
||||
if(item.level == 1){ |
||||
this.delClassDepartment(item) |
||||
}else if(item.level == 2){ |
||||
this.delDepart(item) |
||||
}else{ |
||||
this.delClass(item) |
||||
} |
||||
}, |
||||
addMajor(){ |
||||
this.Form.classmajorId = '' |
||||
this.Form.classmajorName = '' |
||||
this.isaddClassMajor = true |
||||
}, |
||||
editmajorClass(item){ |
||||
this.Form.classmajorId = item.stuProfessionalArchitectureId, |
||||
this.Form.classmajorName = item.stuProfessionalArchitectureName |
||||
this.isaddClassMajor = true |
||||
}, |
||||
delClassDepartment(item){ |
||||
this.$confirm('确定要删除该专业吗?', '提示', { |
||||
type: 'warning' |
||||
}) |
||||
.then(() => { |
||||
this.$post(`${this.api.deleteStudentProfessionalArchitecture}?studentProfessionalArchitectureIds=${item.stuProfessionalArchitectureId}`).then(res => { |
||||
util.successMsg('删除成功') |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
}).catch(() => {}) |
||||
}, |
||||
sure(){ |
||||
if(!this.Form.classmajorName) return util.warningMsg('请输入专业名称') |
||||
if(!this.majorNoAdd) return util.warningMsg('该专业名称已存在') |
||||
let data = { |
||||
stuProfessionalArchitectureName: this.Form.classmajorName, |
||||
stuProfessionalArchitectureId: this.Form.classmajorId, |
||||
schoolId: this.clientId |
||||
} |
||||
if(this.Form.classmajorId){ |
||||
this.$post(this.api.updateStudentProfessionalArchitecture,data).then(res => { |
||||
util.successMsg('编辑成功') |
||||
this.isaddClassMajor = false |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
}else{ |
||||
this.$post(this.api.addStudentProfessionalArchitecture,data).then(res => { |
||||
util.successMsg('添加成功') |
||||
this.isaddClassMajor = false |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
} |
||||
|
||||
}, |
||||
addClassDepartment(item){ |
||||
this.Form2.departmentId = '' |
||||
this.Form2.departmentName = '' |
||||
this.isAddDepartment = true |
||||
this.Form.classmajorId = item.stuProfessionalArchitectureId |
||||
}, |
||||
editDepartment(item){ |
||||
this.Form2.departmentId = item.gradeId, |
||||
this.Form2.departmentName = item.gradeName |
||||
this.isAddDepartment = true |
||||
for (let j = 0; j < this.listData.length; j++) { |
||||
for (let k = 0; k < this.listData[j].children.length; k++) { |
||||
if(this.listData[j].children[k].gradeName == item.gradeName){ |
||||
this.Form.classmajorId = this.listData[j].stuProfessionalArchitectureId |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
delDepart(item){ |
||||
this.$confirm('确定要删除该年级吗?', '提示', { |
||||
type: 'warning' |
||||
}) |
||||
.then(() => { |
||||
this.$post(`${this.api.deleteGrade}?gradeIds=${item.gradeId}`).then(res => { |
||||
util.successMsg('删除成功') |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
}) |
||||
.catch(() => {}); |
||||
}, |
||||
sureDepartment(){ |
||||
if(!this.Form2.departmentName) return util.warningMsg('请输入年级名称') |
||||
if(isNaN(this.Form2.departmentName)) return util.warningMsg('年级名称必须为数字') |
||||
let data = { |
||||
gradeName: this.Form2.departmentName, |
||||
gradeId: this.Form2.departmentId, |
||||
stuProfessionalArchitectureId: this.Form.classmajorId, |
||||
} |
||||
if(this.Form2.departmentId){ |
||||
this.$post(this.api.updateGrade,data).then(res => { |
||||
util.successMsg('编辑成功') |
||||
this.isAddDepartment = false |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
}else{ |
||||
this.$post(this.api.addGrade,data).then(res => { |
||||
util.successMsg('添加成功') |
||||
this.isAddDepartment = false |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
} |
||||
|
||||
}, |
||||
async majorChange(){ |
||||
let res = await this.$get(this.api.queryStudentPAN, { name: this.Form.classmajorName,schoolId: this.clientId }) |
||||
if(res.data.studentProfessionalArchitecture != null){ |
||||
util.warningMsg('该专业组织已存在') |
||||
this.majorNoAdd = false |
||||
}else{ |
||||
this.majorNoAdd = true |
||||
} |
||||
}, |
||||
addClass(two){ |
||||
this.Form3.classId = '' |
||||
this.Form3.className = '' |
||||
this.isAddClass = true |
||||
this.Form2.departmentId = two.gradeId |
||||
}, |
||||
editClass(three){ |
||||
this.Form3.classId = three.classId, |
||||
this.Form3.className = three.className |
||||
this.isAddClass = true |
||||
for (let j = 0; j < this.listData.length; j++) { |
||||
for (let k = 0; k < this.listData[j].children.length; k++) { |
||||
for(let l = 0; l < this.listData[j].children[k].children.length; l++){ |
||||
if(this.listData[j].children[k].children[l].className == three.className){ |
||||
this.Form2.departmentId = this.listData[j].gradeId |
||||
} |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
delClass(item,index){ |
||||
this.$confirm('确定要删除该班级吗?', '提示', { |
||||
type: 'warning' |
||||
}) |
||||
.then(() => { |
||||
this.$post(`${this.api.deleteClass}?classIds=${item.classId}`).then(res => { |
||||
util.successMsg('删除成功') |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
}) |
||||
.catch(() => {}); |
||||
}, |
||||
sureClass(){ |
||||
if(!this.Form3.className) return util.warningMsg('请输入班级名称') |
||||
let data = { |
||||
className: this.Form3.className, |
||||
classId: this.Form3.classId, |
||||
gradeId: this.Form2.departmentId |
||||
} |
||||
if(this.Form3.classId){ |
||||
this.$post(this.api.updateClass,data).then(res => { |
||||
util.successMsg('编辑成功') |
||||
this.isAddClass = false |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
}else{ |
||||
this.$post(this.api.addClass,data).then(res => { |
||||
util.successMsg('添加成功') |
||||
this.isAddClass = false |
||||
this.getData() |
||||
}).catch(res => {}) |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
/deep/.el-table{ |
||||
th:first-child{ |
||||
.cell{ |
||||
&:before{ |
||||
content: ''; |
||||
display: inline-block; |
||||
padding-left: 25vw; |
||||
} |
||||
} |
||||
} |
||||
.el-table__body-wrapper{ |
||||
td:first-child{ |
||||
.cell{ |
||||
display: flex; |
||||
justify-content: flex-end; |
||||
align-items: center; |
||||
flex-direction: row-reverse; |
||||
i{ |
||||
font-size: 16px; |
||||
} |
||||
.text:before{ |
||||
content: ''; |
||||
display: inline-block; |
||||
padding-left: 25vw; |
||||
} |
||||
|
||||
.el-table__placeholder + .text:before{ |
||||
padding-left: 27vw; |
||||
} |
||||
.el-table__expand-icon{ |
||||
transform: rotate(90deg); |
||||
&.el-table__expand-icon--expanded{ |
||||
transform: rotate(-90deg); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.el-table__row--level-1{ |
||||
td:first-child{ |
||||
.cell{ |
||||
.text:before{ |
||||
content: ''; |
||||
display: inline-block; |
||||
padding-left: 26vw; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,553 @@ |
||||
<template> |
||||
<div> |
||||
<div class="tool"> |
||||
<ul class="filter"> |
||||
<li> |
||||
<label>筛选:</label> |
||||
<el-cascader :options="orgList" :props="props" collapse-tags clearable size="small" @change="orgChange"></el-cascader> |
||||
</li> |
||||
<li> |
||||
<label>搜索:</label> |
||||
<el-input placeholder="请输入学生名称" prefix-icon="el-icon-search" v-model="keyword" clearable size="small"></el-input> |
||||
</li> |
||||
</ul> |
||||
<div> |
||||
<el-button type="primary" size="small" round @click="addstudent" v-auth="'/student/list:学生管理:新增学生'">新增学生</el-button> |
||||
<el-button type="primary" size="small" round @click="batchImport" v-auth="'/student/list:学生管理:批量导入'">批量导入</el-button> |
||||
<el-button type="primary" size="small" round @click="delAllSelection" v-auth="'/student/list:学生管理:批量删除'">批量删除</el-button> |
||||
</div> |
||||
</div> |
||||
<!-- <StudentSide ref="getSelectData" @fircheck="fircheck" @twocheck="twocheck" @threecheck="threecheck" @getData="getData"></StudentSide> --> |
||||
|
||||
<el-table :data="listData" class="table" ref="table" stripe header-align="center" @selection-change="handleSelectionChange"> |
||||
<el-table-column type="selection" width="80" align="center"></el-table-column> |
||||
<el-table-column type="index" label="序号" width="55" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="studentName" label="学生姓名" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="workNumber" label="学生学号" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="stuProfessionalArchitectureName" label="专业" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="gradeName" label="年级" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="className" label="班级" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="loginNumber" label="登录次数" align="center"> |
||||
</el-table-column> |
||||
<el-table-column prop="lastLoginTime" label="上次登录时间" width="150" align="center"> |
||||
</el-table-column> |
||||
<el-table-column label="操作" width="180" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-button type="text" @click="editstudent(scope.row)" v-auth="'/student/list:学生管理:编辑'">编辑</el-button> |
||||
<el-button type="text" @click="resetPassword(scope.row)" v-auth="'/student/list:学生管理:重置密码'">重置密码</el-button> |
||||
<el-button type="text" @click="delstudent(scope.row)" v-auth="'/student/list:学生管理:删除'">删除</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<div class="pagination"> |
||||
<el-pagination background layout="total,prev, pager, next" :current-page="page" @current-change="handleCurrentChange" :total="total"></el-pagination> |
||||
</div> |
||||
|
||||
<el-dialog :title="isAdd ? '新增学生' : '编辑学生'" :visible.sync="studentVisible" width="30%" @close="closestudent" class="dialog" :close-on-click-modal="false"> |
||||
<el-form ref="studentForm" :model="studentForm" :rules="rules" label-width="100px" label-suffix=":"> |
||||
<el-form-item prop="account" label="账号"> |
||||
<el-input v-model="studentForm.account" placeholder="请输入学生账号" @change="accountChange"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="userName" label="学生姓名"> |
||||
<el-input v-model="studentForm.userName" placeholder="请输入学生姓名"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="uniqueIdentificationAccount" label="唯一标识"> |
||||
<el-input disabled v-model="studentForm.uniqueIdentificationAccount" placeholder="请输入学生学号获取唯一标识"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="workNumber" label="学生学号"> |
||||
<el-input v-model="studentForm.workNumber" placeholder="请输入学生学号" @change="workNumberChange"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="professionalId" label="专业"> |
||||
<el-select v-model="studentForm.professionalId" placeholder="请选择专业" @change="getGrade"> |
||||
<el-option v-for="(item,index) in orgList" :key="index" |
||||
:label="item.stuProfessionalArchitectureName" :value="item.stuProfessionalArchitectureId"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item prop="gradeId" label="年级"> |
||||
<el-select v-model="studentForm.gradeId" placeholder="请选择年级" :disabled="studentForm.professionalId ? false : true" @change="getClass"> |
||||
<el-option v-for="(item,index) in gradeList" :key="index" |
||||
:label="item.gradeName" :value="item.gradeId"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item prop="classId" label="班级"> |
||||
<el-select v-model="studentForm.classId" placeholder="请选择班级" :disabled="studentForm.gradeId ? false : true"> |
||||
<el-option v-for="(item,index) in classList" :key="index" |
||||
:label="item.className" :value="item.classId"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item prop="phone" label="手机号"> |
||||
<el-input v-model="studentForm.phone" placeholder="可以用于登录平台,以及找回密码" maxlength="11"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="邮箱"> |
||||
<el-input v-model="studentForm.email" placeholder="可以用于登录平台,以及找回密码"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button size="small" @click="studentVisible = false">取消</el-button> |
||||
<el-button size="small" type="primary" @click="saveSure('studentForm')">确定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
|
||||
<el-dialog title="批量导入" :visible.sync="importVisible" width="400px" :close-on-click-modal="false"> |
||||
<div class="upload-wrap" :class="{lg: uploadFaild}"> |
||||
<el-button class="download" size="small" @click="downLoad"><img src="../../../assets/img/download.png" alt=""> 模板下载</el-button> |
||||
<el-upload accept=".xls,.xlsx" :on-remove="handleRemove" :on-error="uploadError" :on-success="uploadSuccess" :before-remove="beforeRemove" :limit="1" :on-exceed="handleExceed" :action="this.api.uploadFileStudent" :file-list="uploadList" :data="{schoolId: this.clientId}" name="file"> |
||||
<el-button size="small"><img src="../../../assets/img/upload.png" alt=""> 上传文件</el-button> |
||||
</el-upload> |
||||
<div class="link" v-if="uploadFaild"> |
||||
<el-link type="primary" @click="showFaild">导入失败,查看原因</el-link> |
||||
</div> |
||||
</div> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button size="small" @click="importVisible = false">取 消</el-button> |
||||
<el-button size="small" type="primary" @click="uploadSure">确 定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import { mapState,mapGetters } from 'vuex' |
||||
import util from '@/libs/util' |
||||
import Setting from '@/setting' |
||||
export default { |
||||
data() { |
||||
return { |
||||
props: { multiple: true }, |
||||
orgList: [], |
||||
twoDepartmentIds: '', |
||||
studentVisible: false, |
||||
studentForm: { |
||||
clientId: this.clientId, |
||||
clientName: this.clientName, |
||||
studentId: '', |
||||
userId: '', |
||||
userName: '', |
||||
workNumber: '', |
||||
phone: '', |
||||
email: '', |
||||
professionalId: '', |
||||
gradeId: '', |
||||
classId: '' , |
||||
uniqueIdentificationAccount: '', |
||||
account: '' |
||||
}, |
||||
rules: { |
||||
userName: [ |
||||
{ required: true, message: '请输入学生姓名', trigger: 'blur' } |
||||
], |
||||
workNumber: [ |
||||
{ required: true, message: '请输入学生学号', trigger: 'blur' }, |
||||
{ |
||||
pattern: /^[A-Za-z0-9]+$/, |
||||
message: '请输入正确的学生学号', |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
account: [ |
||||
{ required: true, message: '请输入账号', trigger: 'blur' }, |
||||
{ |
||||
pattern: /^[A-Za-z0-9]*$/, |
||||
message: '请输入正确的账号', |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
professionalId: [ |
||||
{ required: true, message: '请选择专业', trigger: 'change' } |
||||
], |
||||
gradeId: [ |
||||
{ required: true, message: '请选择年级', trigger: 'change' } |
||||
], |
||||
classId: [ |
||||
{ required: true, message: '请选择班级', trigger: 'change' } |
||||
], |
||||
phone: [ |
||||
{ |
||||
pattern: /^1[3456789]\d{9}$/, |
||||
message: '请输入正确的手机号', |
||||
trigger: 'blur' |
||||
} |
||||
], |
||||
email: [ |
||||
{ |
||||
pattern: /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/, |
||||
message: '请输入正确的邮箱', |
||||
trigger: 'blur' |
||||
} |
||||
] |
||||
}, |
||||
listData: [], |
||||
importVisible: false, |
||||
keyword: '', |
||||
page: 1, |
||||
pageSize: 10, |
||||
total: 0, |
||||
searchTimer: null, |
||||
gradeList: [], |
||||
classList: [], |
||||
professionalIds: '', |
||||
professionalStudentIds: '', |
||||
gradeIds: '', |
||||
classIds: '', |
||||
multipleSelection: [], |
||||
uploadList: [], |
||||
parmData: [], |
||||
uploadFaild: false, |
||||
token: '', |
||||
schooldId: 1, |
||||
isAdd: true, |
||||
accountRepeat: false, |
||||
workNumberRepeat: false, |
||||
originalAccount: '', |
||||
originalWorkNumber: '' |
||||
}; |
||||
}, |
||||
computed: { |
||||
...mapState('user', [ |
||||
'userId','clientId','clientName' |
||||
]) |
||||
}, |
||||
watch: { |
||||
keyword: function(val) { |
||||
clearTimeout(this.searchTimer) |
||||
this.searchTimer = setTimeout(() => { |
||||
this.getData() |
||||
},500) |
||||
} |
||||
}, |
||||
mounted(){ |
||||
this.getOrg() |
||||
this.studentForm.clientId = this.clientId |
||||
this.studentForm.clientName = this.clientName |
||||
this.getData() |
||||
}, |
||||
methods: { |
||||
getOrg(){ |
||||
let data = { |
||||
schoolId: this.clientId |
||||
} |
||||
this.$get(this.api.queryStudentProfessionalArchitecture,data).then(res => { |
||||
let StaffProfessionalArchitectureList = res.data.StaffProfessionalArchitectureList |
||||
if(StaffProfessionalArchitectureList){ |
||||
StaffProfessionalArchitectureList.map(e => { |
||||
e.isParent = true |
||||
e.value = e.stuProfessionalArchitectureId |
||||
e.label = e.stuProfessionalArchitectureName |
||||
let data = { |
||||
stuProfessionalArchitectureId: e.stuProfessionalArchitectureId |
||||
} |
||||
this.$get(this.api.queryGrade,data).then(res => { |
||||
e.children = res.data.Grade |
||||
e.children.map(e => { |
||||
e.value = e.gradeId |
||||
e.label = e.gradeName |
||||
let data = { |
||||
gradeId: e.gradeId |
||||
} |
||||
this.$get(this.api.queryClass,data).then(res => { |
||||
res.data.Class.map(e => { |
||||
e.value = e.classId |
||||
e.label = e.className |
||||
}) |
||||
e.children = res.data.Class |
||||
}).catch(res => {}) |
||||
}) |
||||
}).catch(res => {}) |
||||
}) |
||||
setTimeout(() => { |
||||
this.orgList = StaffProfessionalArchitectureList |
||||
}, 500) |
||||
} |
||||
}).catch(res => {}) |
||||
}, |
||||
getData(){ |
||||
let data = { |
||||
searchContent: this.keyword, |
||||
professionalIds: this.professionalStudentIds, |
||||
gradeIds: this.gradeIds, |
||||
classIds: this.classIds, |
||||
schoolId: this.clientId |
||||
} |
||||
this.$get(`${this.api.queryStudent}/${this.page}/${this.pageSize}`,data).then(res => { |
||||
this.listData = res.data.studentList.list |
||||
this.total = res.data.studentList.totalCount |
||||
}).catch(res => {}) |
||||
}, |
||||
orgChange(node){ |
||||
this.classIds = node.map(n => n[2]).toString() |
||||
this.getData() |
||||
}, |
||||
closestudent(){ |
||||
this.$refs.studentForm.resetFields() |
||||
}, |
||||
addstudent(){ |
||||
this.studentForm.studentId = '' |
||||
this.studentVisible = true |
||||
this.isAdd = true |
||||
}, |
||||
editstudent(row){ |
||||
this.studentVisible = true |
||||
this.isAdd = false |
||||
this.studentForm.studentId = row.studentId |
||||
this.studentForm.userId = row.userId |
||||
this.$get(`${this.api.getStudent}/${row.studentId}`).then(res => { |
||||
let student = res.data.student |
||||
let userInfo = res.data.userInfo |
||||
this.studentForm.userName = userInfo.userName, |
||||
this.studentForm.workNumber = student.workNumber, |
||||
this.originalWorkNumber = student.workNumber, |
||||
this.studentForm.uniqueIdentificationAccount = userInfo.uniqueIdentificationAccount, |
||||
this.studentForm.professionalId = student.professionalId, |
||||
this.studentForm.gradeId = student.gradeId, |
||||
this.studentForm.classId = student.classId, |
||||
this.studentForm.phone = userInfo.phone, |
||||
this.studentForm.email = userInfo.email, |
||||
this.studentForm.account = userInfo.account |
||||
this.originalAccount = userInfo.account |
||||
this.getGradeData() |
||||
this.getClassData() |
||||
}).catch(res => {}); |
||||
}, |
||||
resetPassword(row){ |
||||
this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, '提示',).then(() => { |
||||
let data = { |
||||
userId: row.userId, |
||||
password: Setting.initialPassword |
||||
} |
||||
this.$post(this.api.userinfoUpdate,data).then(res => { |
||||
if(res.success){ |
||||
util.successMsg('重置成功') |
||||
}else{ |
||||
util.errorMsg('重置失败') |
||||
} |
||||
}).catch(res => {}) |
||||
}).catch(() => {}) |
||||
}, |
||||
// 获取年级 |
||||
getGrade(){ |
||||
this.studentForm.gradeId = '' |
||||
this.studentForm.classId = '' |
||||
this.getGradeData() |
||||
}, |
||||
getGradeData(){ |
||||
let data = { |
||||
stuProfessionalArchitectureId: this.studentForm.professionalId |
||||
} |
||||
this.$get(this.api.queryGrade,data).then(res => { |
||||
this.gradeList = res.data.Grade |
||||
}).catch(res => {}); |
||||
}, |
||||
//获取班级 |
||||
getClass(){ |
||||
this.studentForm.classId = '' |
||||
this.getClassData() |
||||
}, |
||||
getClassData(){ |
||||
let data = { |
||||
gradeId: this.studentForm.gradeId |
||||
} |
||||
this.$get(this.api.queryClass,data).then(res => { |
||||
this.classList = res.data.Class |
||||
}).catch(res => {}); |
||||
}, |
||||
async accountChange(){ |
||||
if(this.studentForm.account !== this.originalAccount){ |
||||
this.$get(`${this.api.getAccount}?account=${this.studentForm.account}`).then(res => { |
||||
if(res.data.userInfo){ |
||||
this.accountRepeat = true |
||||
util.warningMsg('该账号已存在') |
||||
}else{ |
||||
this.accountRepeat = false |
||||
} |
||||
}).catch(res => {}) |
||||
}else{ |
||||
this.accountRepeat = false |
||||
} |
||||
}, |
||||
workNumberChange(){ |
||||
if(this.studentForm.workNumber !== this.originalWorkNumber){ |
||||
this.$get(`${this.api.studentGetWorkNumber}?workNumber=${this.studentForm.workNumber}`).then(res => { |
||||
if(res.data.student){ |
||||
this.workNumberRepeat = true |
||||
util.warningMsg('该学号已存在') |
||||
}else{ |
||||
this.workNumberRepeat = false |
||||
} |
||||
}).catch(res => {}) |
||||
}else{ |
||||
this.workNumberRepeat = false |
||||
} |
||||
}, |
||||
saveSure(studentForm){ |
||||
this.$refs[studentForm].validate((valid) => { |
||||
if (valid) { |
||||
if(this.accountRepeat) return util.warningMsg('该账号已存在') |
||||
if(this.workNumberRepeat) return util.warningMsg('该学号已存在') |
||||
let data = { |
||||
userInfo: { |
||||
isPort: 2, |
||||
roleId: 4, |
||||
clientId: this.studentForm.clientId, |
||||
clientName: this.studentForm.clientName, |
||||
userName: this.studentForm.userName, |
||||
account: this.studentForm.account, |
||||
phone: this.studentForm.phone, |
||||
email: this.studentForm.email, |
||||
uniqueIdentificationAccount: this.studentForm.uniqueIdentificationAccount, |
||||
userId: this.studentForm.userId ? this.studentForm.userId : '' |
||||
}, |
||||
student: { |
||||
userId: this.studentForm.userId, |
||||
studentId: this.studentForm.studentId, |
||||
roleId: 4, |
||||
isPort: 2, |
||||
clientId: this.studentForm.clientId, |
||||
clientName: this.studentForm.clientName, |
||||
professionalId: this.studentForm.professionalId, |
||||
gradeId: this.studentForm.gradeId, |
||||
classId: this.studentForm.classId, |
||||
workNumber: this.studentForm.workNumber, |
||||
} |
||||
} |
||||
if(this.studentForm.studentId){ |
||||
this.$post(this.api.updateStudent,data).then(res => { |
||||
this.studentVisible = false |
||||
util.successMsg('编辑成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
}else{ |
||||
this.$post(this.api.addStudent,data).then(res => { |
||||
this.studentVisible = false |
||||
util.successMsg('添加成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
} |
||||
}else{ |
||||
return false; |
||||
} |
||||
}) |
||||
}, |
||||
delstudent(row){ |
||||
this.$confirm('此删除操作不可逆,是否确认删除选中项?', '提示', { |
||||
type: 'warning' |
||||
}) |
||||
.then(() => { |
||||
let data = { |
||||
studentIds: row.studentId |
||||
} |
||||
this.$del(this.api.deleteStudents,data).then(res => { |
||||
util.successMsg('删除成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
}) |
||||
.catch(() => {}); |
||||
}, |
||||
handleSelectionChange(val) { |
||||
this.multipleSelection = val; |
||||
}, |
||||
delAllSelection() { |
||||
if(this.multipleSelection.length != ''){ |
||||
let newArr = this.multipleSelection |
||||
let delList = newArr.map(item => { |
||||
return item.studentId |
||||
}) |
||||
// 批量删除 |
||||
this.$confirm(`此批量删除操作不可逆,是否确认删除${util.ellipsisStr(newArr[0].studentName)}等${newArr.length}个选中项?`, '提示', { |
||||
type: 'warning' |
||||
}) |
||||
.then(() => { |
||||
let data = { |
||||
studentIds: delList.join() |
||||
} |
||||
this.$del(this.api.deleteStudents,data).then(res => { |
||||
this.multipleSelection = [] |
||||
util.successMsg('删除成功') |
||||
this.getData() |
||||
}).catch(res => {}); |
||||
}).catch(() => {}); |
||||
}else{ |
||||
util.errorMsg('请先选择学生') |
||||
} |
||||
}, |
||||
batchImport(){ |
||||
this.importVisible = true |
||||
}, |
||||
searchstudent(){ |
||||
this.page = 1 |
||||
this.getData() |
||||
}, |
||||
handleCurrentChange(val) { |
||||
this.page = val; |
||||
this.getData(); |
||||
}, |
||||
downLoad(){ |
||||
location.href = this.api.downloadStudentTemp |
||||
}, |
||||
// 上传文件 |
||||
handleExceed(files, fileList) { |
||||
util.warningMsg( |
||||
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` |
||||
); |
||||
}, |
||||
showFaild(){ |
||||
location.href = `${this.api.exportFailureStudent}?token=${this.token}` |
||||
}, |
||||
uploadSuccess(res, file, fileList) { |
||||
this.uploadFaild = false |
||||
if(res.success){ |
||||
if(res.data.data.token){ |
||||
this.token = res.data.data.token |
||||
this.uploadFaild = true |
||||
}else{ |
||||
util.successMsg('上传成功') |
||||
} |
||||
}else{ |
||||
res.data.message ? util.errorMsg(res.data.message) : util.errorMsg('上传失败,请检查数据') |
||||
} |
||||
}, |
||||
uploadError(err, file, fileList) { |
||||
this.$message({ |
||||
message: "上传出错,请重试!", |
||||
type: "error", |
||||
center: true |
||||
}); |
||||
}, |
||||
beforeRemove(file, fileList) { |
||||
return this.$confirm(`确定移除 ${file.name}?`); |
||||
}, |
||||
handleRemove(file, fileList) { |
||||
this.uploadList = fileList |
||||
this.uploadFaild = false |
||||
}, |
||||
uploadSure(){ |
||||
this.importVisible = false |
||||
this.page = 1 |
||||
this.classIds = '' |
||||
this.keyword = '' |
||||
this.getData() |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style lang="scss" scoped> |
||||
/deep/.dialog{ |
||||
.el-form-item{ |
||||
.el-form-item__label{ |
||||
font-size: 16px; |
||||
color: rgba(0, 0, 0, 0.65); |
||||
&:before{ |
||||
margin-right: 0; |
||||
color: #CC221C; |
||||
} |
||||
} |
||||
} |
||||
.el-input,.el-select{ |
||||
width: 100%; |
||||
} |
||||
} |
||||
</style> |
Loading…
Reference in new issue