|
|
|
@ -13,6 +13,7 @@ |
|
|
|
|
</li> |
|
|
|
|
</ul> |
|
|
|
|
<div> |
|
|
|
|
<el-button type="info" @click="batchGenerate">一键批量生成账号</el-button> |
|
|
|
|
<el-button v-auth="'教师管理:新增教师'" type="info" round @click="addTeacher">新增教师</el-button> |
|
|
|
|
<el-button v-auth="'教师管理:批量导入'" type="primary" round @click="batchImport">批量导入</el-button> |
|
|
|
|
<el-button v-auth="'教师管理:批量删除'" type="primary" round @click="delAllSelection">批量删除</el-button> |
|
|
|
@ -23,12 +24,15 @@ |
|
|
|
|
@selection-change="handleSelectionChange"> |
|
|
|
|
<el-table-column type="selection" width="55" align="center"></el-table-column> |
|
|
|
|
<el-table-column type="index" label="序号" width="55" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="account" label="账号" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="userName" label="教师姓名" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="workNumber" label="教师工号" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="dept" label="部门" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="phone" label="手机号" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="email" label="邮箱" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="roleName" label="账号角色" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="logInNumber" label="登录次数" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="lastLoginTime" label="上次登录时间" align="center"></el-table-column> |
|
|
|
|
<el-table-column prop="lastLoginTime" label="上次登录时间" width="160" align="center"></el-table-column> |
|
|
|
|
<el-table-column label="操作" width="200" align="center"> |
|
|
|
|
<template slot-scope="scope"> |
|
|
|
|
<el-button v-auth="'教师管理:教师查看'" type="text" @click="showTeacher(scope.row)">查看</el-button> |
|
|
|
@ -49,11 +53,14 @@ |
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="150px" :disabled="isDetail" |
|
|
|
|
style='margin-right: 80px;'> |
|
|
|
|
<el-form-item prop="workNumber" label="工号"> |
|
|
|
|
<el-input v-model.trim="form.workNumber" placeholder="请输入教师工号" @blur="workNumberChange"></el-input> |
|
|
|
|
<el-input v-model.trim="form.workNumber" placeholder="请输入教师工号"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="userName" label="用户姓名"> |
|
|
|
|
<el-input v-model.trim="form.userName" placeholder="请输入教师姓名"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item v-if="form.accountId" label="账号"> |
|
|
|
|
{{ form.account }} |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="roleValue" label="账号角色"> |
|
|
|
|
<el-select v-model="form.roleValue" @change="roleChange" @remove-tag="roleRemove" multiple |
|
|
|
|
style="width: 100%;height: 32px"> |
|
|
|
@ -61,9 +68,6 @@ |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item prop="uniqueIdentification" label="唯一标识"> |
|
|
|
|
<el-input disabled v-model.trim="form.uniqueIdentification" placeholder="请输入教师工号获取唯一标识"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item v-for="item in form.roleAndDeptList" :label="`${item.roleName}所属部门`" :rules="{ |
|
|
|
|
required: true, message: '请选择', trigger: 'change' |
|
|
|
|
}"> |
|
|
|
@ -100,19 +104,42 @@ |
|
|
|
|
<el-button type="primary" @click="uploadSure">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
<el-dialog title="一键批量生成账号" :visible.sync="generateVisible" :close-on-click-modal="false" width="400px"> |
|
|
|
|
<el-form ref="generateForm" :model="generateForm" :rules="generateRules" label-width="110px"> |
|
|
|
|
<el-form-item prop="roleId" label="账号角色"> |
|
|
|
|
<el-select v-model="generateForm.roleId" style="width: 100%;height: 32px"> |
|
|
|
|
<el-option v-for="item in roleList" :key="item.id" :label="item.roleName" :value="item.id"> |
|
|
|
|
</el-option> |
|
|
|
|
</el-select> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="老师所属部门" prop="dep"> |
|
|
|
|
<el-cascader v-model="generateForm.dep" :options="orgList" :props="casProps" |
|
|
|
|
style="width: 100%"></el-cascader> |
|
|
|
|
</el-form-item> |
|
|
|
|
<el-form-item label="账号数" prop="numberOfUsers"> |
|
|
|
|
<el-input v-model.trim="generateForm.numberOfUsers" placeholder="请输入账号数"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
<el-button @click="generateVisible = false">取 消</el-button> |
|
|
|
|
<el-button type="primary" @click="generateSubmit">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<script> |
|
|
|
|
import Setting from "@/setting"; |
|
|
|
|
import util from "@/libs/util"; |
|
|
|
|
import Util from '@/libs/util' |
|
|
|
|
import Setting from '@/setting' |
|
|
|
|
import org from "./staffSide" |
|
|
|
|
import { mapState } from "vuex"; |
|
|
|
|
import _ from 'lodash' |
|
|
|
|
export default { |
|
|
|
|
data () { |
|
|
|
|
return { |
|
|
|
|
exportCode: "", |
|
|
|
|
headers: { |
|
|
|
|
token: util.local.get(Setting.tokenKey) |
|
|
|
|
token: Util.local.get(Setting.tokenKey) |
|
|
|
|
}, |
|
|
|
|
isDetail: false, |
|
|
|
|
isAdd: false, |
|
|
|
@ -147,7 +174,6 @@ export default { |
|
|
|
|
{ required: true, message: "请选择账号角色", trigger: "change" } |
|
|
|
|
], |
|
|
|
|
workNumber: [ |
|
|
|
|
{ required: true, message: "请输入工号", trigger: 'blur' }, |
|
|
|
|
{ |
|
|
|
|
pattern: /^[A-Za-z0-9]*$/, |
|
|
|
|
message: "教师工号必须为数字或英文", |
|
|
|
@ -185,7 +211,25 @@ export default { |
|
|
|
|
|
|
|
|
|
gradeId: "", // 教师年级ID |
|
|
|
|
staffArchitectureId: "", // 教师部门ID |
|
|
|
|
submiting: false // 新增编辑教师防抖标识 |
|
|
|
|
submiting: false, // 新增编辑教师防抖标识 |
|
|
|
|
|
|
|
|
|
generateVisible: false, |
|
|
|
|
generateForm: { |
|
|
|
|
roleId: '', |
|
|
|
|
dep: [], |
|
|
|
|
numberOfUsers: '', |
|
|
|
|
}, |
|
|
|
|
generateRules: { |
|
|
|
|
roleId: [ |
|
|
|
|
{ required: true, message: '请选择账号角色', trigger: 'change' } |
|
|
|
|
], |
|
|
|
|
dep: [ |
|
|
|
|
{ required: true, message: '请选择老师所属部门', trigger: 'change' } |
|
|
|
|
], |
|
|
|
|
numberOfUsers: [ |
|
|
|
|
{ required: true, message: '请输入账号数', trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
components: { |
|
|
|
@ -271,6 +315,39 @@ export default { |
|
|
|
|
this.$refs.form.clearValidate(); |
|
|
|
|
this.teacherVisible = false; |
|
|
|
|
}, |
|
|
|
|
// 批量生成账号 |
|
|
|
|
batchGenerate () { |
|
|
|
|
this.generateForm = { |
|
|
|
|
roleId: '', |
|
|
|
|
dep: [], |
|
|
|
|
numberOfUsers: '', |
|
|
|
|
} |
|
|
|
|
this.generateVisible = true |
|
|
|
|
}, |
|
|
|
|
// 批量生成账号提交 |
|
|
|
|
generateSubmit () { |
|
|
|
|
this.$refs.generateForm.validate(async (valid) => { |
|
|
|
|
if (valid) { |
|
|
|
|
const form = _.cloneDeep(this.generateForm) |
|
|
|
|
const { dep } = form |
|
|
|
|
if (dep && dep.length) { |
|
|
|
|
form.staffArchitectureId = dep[0] |
|
|
|
|
if (dep.length > 1) form.gradeId = dep[dep.length - 1] |
|
|
|
|
} |
|
|
|
|
debugger |
|
|
|
|
await this.$post(this.api.generate, { |
|
|
|
|
...form, |
|
|
|
|
platformId: Setting.platformId, |
|
|
|
|
type: 2, |
|
|
|
|
}) |
|
|
|
|
this.generateVisible = false |
|
|
|
|
Util.successMsg('批量生成成功!') |
|
|
|
|
this.initData() |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
addTeacher () { // 新增教师 |
|
|
|
|
this.isDetail = false; |
|
|
|
|
this.isAdd = true; |
|
|
|
@ -292,7 +369,7 @@ export default { |
|
|
|
|
resetPassword (row) { // 重置密码 |
|
|
|
|
this.$confirm(`重置后的密码为:${Setting.initialPassword},确定重置?`, "提示", { type: "warning" }).then(() => { |
|
|
|
|
this.$get(`${this.api.resetPassword}?userId=${row.userId}&newPwd=1122aa`).then(res => { |
|
|
|
|
util.successMsg("重置成功"); |
|
|
|
|
Util.successMsg("重置成功"); |
|
|
|
|
}).catch(res => { |
|
|
|
|
}); |
|
|
|
|
}).catch(() => { |
|
|
|
@ -312,28 +389,6 @@ export default { |
|
|
|
|
this.orgList = this.$refs.org.orgList; |
|
|
|
|
this.getStaffDetail(row.accountId); |
|
|
|
|
}, |
|
|
|
|
// 组合账号 |
|
|
|
|
renderAccount () { |
|
|
|
|
const form = this.form |
|
|
|
|
// 平台id-端id-schoolId-workNumber组成账号 |
|
|
|
|
form.account = `${Setting.platformId}-0-${this.schoolId}-${form.workNumber}` |
|
|
|
|
}, |
|
|
|
|
workNumberChange () { // 切换工号 |
|
|
|
|
const form = this.form |
|
|
|
|
const { workNumber, accountId } = form |
|
|
|
|
if (workNumber) { |
|
|
|
|
this.$post(`${this.api.checkWorkNumOrAccount}?platformId=${Setting.platformId}&type=${Setting.platformType}${accountId ? `&accountId=${form.accountId}` : ''}&workNumber=${workNumber}&account=`).then(res => { |
|
|
|
|
if (res.status === 200) { |
|
|
|
|
this.workNumberReapeat = false |
|
|
|
|
this.renderAccount() |
|
|
|
|
} |
|
|
|
|
}).catch(err => { |
|
|
|
|
this.workNumberReapeat = true |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
this.renderAccount() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
phoneChange () { // 切换手机号 |
|
|
|
|
let regex = /^1[3456789]\d{9}$/; |
|
|
|
|
if (regex.test(this.form.phone)) { |
|
|
|
@ -406,9 +461,9 @@ export default { |
|
|
|
|
this.$refs[form].validate((valid) => { |
|
|
|
|
if (valid) { |
|
|
|
|
if (this.submiting) return false |
|
|
|
|
if (this.workNumberReapeat) return util.errorMsg('工号/学号已存在!'); |
|
|
|
|
if (this.phoneRepeat) return util.errorMsg("该手机号已存在"); |
|
|
|
|
if (this.emailRepeat) return util.errorMsg("该邮箱已存在"); |
|
|
|
|
if (this.workNumberReapeat) return Util.errorMsg('工号/学号已存在!'); |
|
|
|
|
if (this.phoneRepeat) return Util.errorMsg("该手机号已存在"); |
|
|
|
|
if (this.emailRepeat) return Util.errorMsg("该邮箱已存在"); |
|
|
|
|
let data = { |
|
|
|
|
accountId: this.form.accountId, |
|
|
|
|
account: this.form.account, |
|
|
|
@ -422,7 +477,7 @@ export default { |
|
|
|
|
if (this.form.roleAndDeptList.length) { |
|
|
|
|
for (let i = 0; i < this.form.roleAndDeptList.length; i++) { |
|
|
|
|
if (this.form.roleAndDeptList[i].cascaderValue.length < 2) { |
|
|
|
|
util.warningMsg(`请选择${this.form.roleAndDeptList[i].roleName}所属部门`) |
|
|
|
|
Util.warningMsg(`请选择${this.form.roleAndDeptList[i].roleName}所属部门`) |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
let obj = { |
|
|
|
@ -437,7 +492,7 @@ export default { |
|
|
|
|
this.submiting = true |
|
|
|
|
if (this.form.accountId) { |
|
|
|
|
this.$post(this.api.modifyStaff, data).then(res => { |
|
|
|
|
util.successMsg("编辑成功"); |
|
|
|
|
Util.successMsg("编辑成功"); |
|
|
|
|
this.closeTeacher(); |
|
|
|
|
this.getData(); |
|
|
|
|
this.submiting = false |
|
|
|
@ -446,7 +501,7 @@ export default { |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
this.$post(this.api.saveStaff, data).then(res => { |
|
|
|
|
util.successMsg("添加成功"); |
|
|
|
|
Util.successMsg("添加成功"); |
|
|
|
|
this.closeTeacher(); |
|
|
|
|
this.getData(); |
|
|
|
|
this.submiting = false |
|
|
|
@ -464,7 +519,7 @@ export default { |
|
|
|
|
type: "warning" |
|
|
|
|
}).then(() => { |
|
|
|
|
this.$post(`${this.api.delStaff}?accountIds=${row.accountId}`).then(res => { |
|
|
|
|
util.successMsg("删除成功"); |
|
|
|
|
Util.successMsg("删除成功"); |
|
|
|
|
this.getData(); |
|
|
|
|
}).catch(res => { }); |
|
|
|
|
}).catch(() => { }); |
|
|
|
@ -484,14 +539,14 @@ export default { |
|
|
|
|
this.$post(`${this.api.delStaff}?accountIds=${ids.toString()}`).then(res => { |
|
|
|
|
this.multipleSelection = []; |
|
|
|
|
this.$refs.table.clearSelection(); |
|
|
|
|
util.successMsg("删除成功"); |
|
|
|
|
Util.successMsg("删除成功"); |
|
|
|
|
this.getData(); |
|
|
|
|
}).catch(res => { |
|
|
|
|
}); |
|
|
|
|
}).catch(() => { |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
util.errorMsg("请先选择教师 !"); |
|
|
|
|
Util.errorMsg("请先选择教师 !"); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
batchImport () { |
|
|
|
@ -515,7 +570,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 上传文件 |
|
|
|
|
handleExceed (files, fileList) { |
|
|
|
|
util.warningMsg( |
|
|
|
|
Util.warningMsg( |
|
|
|
|
`当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
@ -527,9 +582,9 @@ export default { |
|
|
|
|
this.exportCode = res.data.exportCode; |
|
|
|
|
this.uploadFaild = true; |
|
|
|
|
} |
|
|
|
|
util.successMsg(`上传成功${res.data.successNum},上传失败${res.data.failureNum}`); |
|
|
|
|
Util.successMsg(`上传成功${res.data.successNum},上传失败${res.data.failureNum}`); |
|
|
|
|
} else { |
|
|
|
|
res.message ? util.errorMsg(res.message) : util.errorMsg("上传失败,请检查数据"); |
|
|
|
|
res.message ? Util.errorMsg(res.message) : Util.errorMsg("上传失败,请检查数据"); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
uploadError (err, file, fileList) { |
|
|
|
|