parent
756c2ff214
commit
301a77ac63
8 changed files with 530 additions and 116 deletions
@ -0,0 +1,401 @@ |
||||
<template> |
||||
<div class="page"> |
||||
<h6 class="page-name">筛选</h6> |
||||
<div class="tool"> |
||||
<ul class="filter"> |
||||
<li> |
||||
<el-input style="width: 300px;" placeholder="请输入姓名、手机号、现所在单位、职务" prefix-icon="el-icon-search" |
||||
v-model="keyWord" clearable></el-input> |
||||
</li> |
||||
</ul> |
||||
<div> |
||||
<el-button type="text" @click="add">复制专家登录链接</el-button> |
||||
<el-button type="primary" @click="add" v-auth="'/system:后台账号:新增员工'">新增专家</el-button> |
||||
<el-button type="primary" @click="batchDel" v-auth="'/system:后台账号:批量导入'">批量删除</el-button> |
||||
</div> |
||||
</div> |
||||
|
||||
<el-table :data="list" class="table" ref="table" stripe header-align="center" |
||||
@selection-change="handleSelectionChange" row-key="accountId"> |
||||
<el-table-column type="selection" width="55" align="center" :reserve-selection="true"></el-table-column> |
||||
<el-table-column type="index" width="60" label="序号" align="center"></el-table-column> |
||||
<el-table-column prop="userName" label="姓名" align="center" min-width="100"></el-table-column> |
||||
<el-table-column prop="phone" label="手机号" align="center" width="120"></el-table-column> |
||||
<el-table-column prop="staffArchitectureName" label="现所在单位" align="center" min-width="200"></el-table-column> |
||||
<el-table-column prop="roleName" label="职务" align="center" min-width="200"></el-table-column> |
||||
<el-table-column prop="lastLoginTime" label="登录次数" align="center" width="130"></el-table-column> |
||||
<el-table-column prop="lastLoginTime" label="上次登录时间" align="center" width="130"></el-table-column> |
||||
<el-table-column label="操作" align="center" width="300"> |
||||
<template slot-scope="scope"> |
||||
<el-button type="text" v-auth="'/system:后台账号:查看'" @click="queryStaff(scope.row, true)">查看</el-button> |
||||
<el-button type="text" v-auth="'/system:后台账号:编辑'" @click="queryStaff(scope.row, false)">编辑</el-button> |
||||
<el-button type="text" v-auth="'/system:后台账号:重置密码'" @click="resetPassword(scope.row)">重置密码</el-button> |
||||
<el-button type="text" v-auth="'/system:后台账号:删除'" @click="delStaff(scope.row)">删除</el-button> |
||||
<el-switch v-auth="'/match:启用'" v-model="scope.row.ztOpen" :active-value="0" :inactive-value="1" |
||||
style="margin: 0 10px 0 5px" :active-text="scope.row.ztOpen ? '关' : '开'" |
||||
@change="switchOff($event, scope.row, scope.$index)"></el-switch> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<div class="pagination"> |
||||
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" |
||||
:total="total"></el-pagination> |
||||
</div> |
||||
|
||||
<el-drawer :title="isDetail ? '查看' : (form.accountId ? '编辑' : '新增') + '专家'" :visible.sync="expertVisible" |
||||
size="580px" class="dialog" :close-on-click-modal="false" custom-class="expert-dia" @close="closeStaff"> |
||||
<el-form class="overflow" ref="form" :model="form" :rules="rules" label-width="120px" :disabled="isDetail"> |
||||
<el-form-item prop="userName" label="姓名"> |
||||
<el-input v-model.trim="form.userName" placeholder="请输入姓名"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="phone" label="手机号"> |
||||
<el-input v-model.trim="form.phone" placeholder="请输入手机号" maxlength="11"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="userName" label="登录密码"> |
||||
<el-input type="password" v-model.trim="form.userName" placeholder="请输入密码" show-password></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="电子邮箱"> |
||||
<el-input v-model.trim="form.email" placeholder="请输入电子邮箱"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="性别"> |
||||
<el-radio v-model="form.radio" label="1">男</el-radio> |
||||
<el-radio v-model="form.radio" label="2">女</el-radio> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="学历"> |
||||
<el-select v-model="form.status" clearable placeholder="请选择学历"> |
||||
<el-option v-for="(item, i) in edus" :key="i" :label="item.name" :value="item.id"></el-option> |
||||
</el-select> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="学位"> |
||||
<el-input v-model.trim="form.email" placeholder="请输入学位"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="职称"> |
||||
<el-input v-model.trim="form.email" placeholder="请输入职称"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="职务"> |
||||
<el-input v-model.trim="form.email" placeholder="请输入职务"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="毕业院校"> |
||||
<el-input v-model.trim="form.email" placeholder="请输入毕业院校"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="学术专长"> |
||||
<el-input v-model.trim="form.email" placeholder="请输入学术专长"></el-input> |
||||
</el-form-item> |
||||
<el-form-item prop="email" label="现所在单位"> |
||||
<el-input v-model.trim="form.email" placeholder="请输入现所在单位"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<div class="btns"> |
||||
<el-button @click="expertVisible = false">取消</el-button> |
||||
<el-button v-if="!isDetail" type="primary" @click="submitStaff">保存</el-button> |
||||
</div> |
||||
</el-drawer> |
||||
|
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import Util from '@/libs/util' |
||||
import Setting from '@/setting' |
||||
export default { |
||||
data () { |
||||
const phonePass = (rule, value, callback) => { |
||||
if (value) { |
||||
const pattern = /^1[3456789]\d{9}$/ |
||||
if (pattern.test(value)) { |
||||
// this.phoneChange() |
||||
callback() |
||||
} else { |
||||
callback(new Error('请输入正确手机号格式')) |
||||
} |
||||
} else { |
||||
callback() |
||||
} |
||||
} |
||||
const emailPass = (rule, value, callback) => { |
||||
if (value) { |
||||
const pattern = /^([a-zA-Z]|[0-9])(\w|\-)+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/ |
||||
if (pattern.test(value)) { |
||||
// this.emailChange() |
||||
callback() |
||||
} else { |
||||
callback(new Error('请输入正确邮箱格式')) |
||||
} |
||||
} else { |
||||
callback() |
||||
} |
||||
} |
||||
return { |
||||
isDetail: false, |
||||
keyWord: '', |
||||
edus: [], |
||||
form: { |
||||
accountId: '', |
||||
userName: '', |
||||
phone: '', |
||||
roleList: [], |
||||
uniqueIdentification: '', |
||||
workNumber: '', |
||||
email: '', |
||||
account: '', |
||||
staffArchitectureId: [] |
||||
}, |
||||
rules: { |
||||
phone: [ |
||||
{ required: true, validator: phonePass, trigger: 'blur' } |
||||
], |
||||
email: [ |
||||
{ validator: emailPass, trigger: 'blur' } |
||||
] |
||||
}, |
||||
list: [], |
||||
page: 1, |
||||
pageSize: 10, |
||||
total: 0, |
||||
multipleSelection: [], |
||||
|
||||
expertVisible: false, |
||||
phoneRepeat: false, |
||||
emailRepeat: false, |
||||
submiting: false // 新增编辑防抖标识 |
||||
}; |
||||
}, |
||||
watch: { |
||||
keyWord: function (val) { |
||||
clearTimeout(this.searchTimer); |
||||
this.searchTimer = setTimeout(this.getList, 500); |
||||
} |
||||
}, |
||||
mounted () { |
||||
// this.getRole() |
||||
}, |
||||
methods: { |
||||
getList () { |
||||
this.$post(this.api.staffList, { |
||||
type: this.studentType || 1, |
||||
staffArchitectureId: this.$refs.orgTree.getCurrentKey() || '', |
||||
keyWord: this.keyWord, |
||||
pageNum: this.page, |
||||
pageSize: this.pageSize |
||||
}).then(res => { |
||||
this.list = res.page.records |
||||
this.total = res.page.total |
||||
}).catch(err => { }) |
||||
}, |
||||
// 切换页码 |
||||
currentChange (val) { |
||||
this.page = val |
||||
this.getList() |
||||
}, |
||||
handleSelectionChange (val) { |
||||
this.multipleSelection = val |
||||
}, |
||||
initData () { |
||||
this.$refs.table.clearSelection() |
||||
this.page = 1 |
||||
this.getList() |
||||
}, |
||||
// 删除 |
||||
delStaff (row) { |
||||
this.$confirm("确定要删除吗?", "提示", { |
||||
type: "warning" |
||||
}).then(() => { |
||||
this.$post(`${this.api.delStaff}?accountIds=${row.accountId}`).then(res => { |
||||
Util.successMsg("删除成功") |
||||
this.getList() |
||||
}).catch(res => { }) |
||||
}).catch(() => { }) |
||||
}, |
||||
// 重置密码 |
||||
async resetPassword (row) { |
||||
const newPwd = Setting.initialPassword |
||||
await this.$confirm(`重置后的密码为:手机号码后六位,确定要重置吗?`, "提示", { type: "warning" }) |
||||
await this.$get(`${this.api.resetPwd}?userId=${row.userId}&newPwd=${newPwd}`) |
||||
Util.successMsg('重置成功') |
||||
}, |
||||
async switchOff (val, row) { |
||||
this.$post(this.api.disabledEventsCompetition, { |
||||
competitionId: row.id, |
||||
isOpen: val, |
||||
type: 0 // 禁用平台来源(0中台,1职站) |
||||
}).then(res => { |
||||
util.successMsg(val == 1 ? '禁用成功' : '启用成功') |
||||
}).catch(err => { }) |
||||
|
||||
await this.$post(`${this.api.refreshPageNotification}?content=1`) |
||||
}, |
||||
// 添加员工 |
||||
add () { |
||||
this.expertVisible = true |
||||
this.$nextTick(() => { |
||||
this.$refs.form.clearValidate() |
||||
}) |
||||
}, |
||||
// 批量删除 |
||||
async batchDel () { |
||||
const list = this.multipleSelection |
||||
if (list.length) { |
||||
try { |
||||
await this.$confirm(`确定要删除已选定的${list.length}份试卷吗?`, '提示', { |
||||
confirmButtonText: '确定', |
||||
cancelButtonText: '取消', |
||||
type: 'warning', |
||||
closeOnClickModal: false, |
||||
}) |
||||
await this.$post(this.api.paperDel, { |
||||
delete: false, |
||||
ids: list.map(e => e.paperId) |
||||
}) |
||||
Util.successMsg('删除成功') |
||||
this.multipleSelection = [] |
||||
this.$refs.table.clearSelection() |
||||
this.getList() |
||||
} catch (e) { } |
||||
} else { |
||||
Util.warningMsg('请选择数据') |
||||
} |
||||
}, |
||||
// 编辑/查看 |
||||
queryStaff (row, isDetail) { |
||||
const archId = [] |
||||
// 处理部门id |
||||
const handleArchId = (list, ids, parentId = []) => { |
||||
list.map(e => { |
||||
// 把部门id分割成二维数组,[[1, 2], [3, 4]],每个层级的id都要放进去,后端返回的是最后一级的id,无法回显 |
||||
if (ids.includes(e.id)) { |
||||
archId.push([...parentId, e.id]) |
||||
} else { |
||||
e.children && handleArchId(e.children, ids, [...parentId, e.id]) |
||||
} |
||||
}) |
||||
} |
||||
this.isDetail = isDetail |
||||
this.expertVisible = true |
||||
this.$get(`${this.api.staffDetail}?accountId=${row.accountId}`).then(res => { |
||||
const { data } = res |
||||
const { staffArchitectureId, roleId } = data |
||||
if (roleId) { |
||||
const roleList = roleId.split(',').map(e => Number(e)) |
||||
const list = this.roleList |
||||
if (roleList.length) { |
||||
let has = false // 是否在角色列表里有已选择的角色,全部都被删除了,则提示 |
||||
for (const i in roleList) { |
||||
if (list.find(n => n.id === roleList[i])) { |
||||
has = true |
||||
break |
||||
} |
||||
} |
||||
if (!has) { |
||||
Util.warningMsg('角色被删请重新选择') |
||||
data.roleList = [] |
||||
} else { |
||||
data.roleList = roleList |
||||
} |
||||
} |
||||
} |
||||
if (staffArchitectureId) { |
||||
handleArchId(this.orgList, staffArchitectureId.split(',').map(e => Number(e))) |
||||
data.staffArchitectureId = archId |
||||
} |
||||
this.form = data |
||||
this.originAccount = data.account |
||||
this.originWorkNumber = data.workNumber |
||||
}).catch(res => { }) |
||||
}, |
||||
// 手机号判重 |
||||
phoneChange () { |
||||
const form = this.form |
||||
const { phone } = form |
||||
if (phone) { |
||||
const { accountId } = form |
||||
this.$post(`${this.api.checkEmailOrPhone}?phone=${phone}${accountId ? `&accountId=${accountId}` : ''}`).then(res => { |
||||
this.phoneRepeat = false |
||||
}).catch(err => { |
||||
this.phoneRepeat = true |
||||
}) |
||||
} |
||||
}, |
||||
// 邮箱判重 |
||||
emailChange () { |
||||
const form = this.form |
||||
const { email } = form |
||||
if (email) { |
||||
const { accountId } = form |
||||
this.$post(`${this.api.checkEmailOrPhone}?email=${email}${accountId ? `&accountId=${accountId}` : ''}`).then(res => { |
||||
this.emailRepeat = false |
||||
}).catch(err => { |
||||
this.emailRepeat = true |
||||
}) |
||||
} |
||||
}, |
||||
// 提交新增/编辑员工 |
||||
submitStaff () { |
||||
this.$refs.form.validate((valid) => { |
||||
if (valid) { |
||||
if (this.submiting) return false |
||||
if (this.accountReapeat) return Util.warningMsg("该账号已存在") |
||||
if (this.workNumberReapeat) return Util.warningMsg("该工号已存在") |
||||
if (this.phoneRepeat) return Util.warningMsg("该手机号已存在") |
||||
if (this.emailRepeat) return Util.warningMsg("该邮箱已存在") |
||||
this.submiting = true |
||||
const form = JSON.parse(JSON.stringify(this.form)) |
||||
const ids = form.staffArchitectureId |
||||
if (ids) form.staffArchitectureId = ids.map(e => e[e.length - 1]) |
||||
if (form.accountId) { |
||||
this.$post(this.api.modifyStaff, form).then(res => { |
||||
Util.successMsg("编辑成功!") |
||||
this.expertVisible = false |
||||
setTimeout(() => { |
||||
this.submiting = false |
||||
}, 2000) |
||||
}).catch(res => { |
||||
setTimeout(() => { |
||||
this.submiting = false |
||||
}, 2000) |
||||
}) |
||||
} else { |
||||
form.uniqueIdentification = new Date().getTime() |
||||
this.$post(this.api.saveStaff, form).then(res => { |
||||
Util.successMsg("新增成功!") |
||||
this.expertVisible = false |
||||
setTimeout(() => { |
||||
this.submiting = false |
||||
}, 2000) |
||||
}).catch(res => { |
||||
setTimeout(() => { |
||||
this.submiting = false |
||||
}, 2000) |
||||
}) |
||||
} |
||||
} |
||||
}) |
||||
}, |
||||
// 关闭新增员工对话框 |
||||
closeStaff () { |
||||
this.form = { |
||||
accountId: '', |
||||
userName: '', |
||||
account: '', |
||||
phone: '', |
||||
uniqueIdentification: '', |
||||
workNumber: '', |
||||
email: '', |
||||
staffArchitectureId: [], |
||||
roleList: [] |
||||
} |
||||
this.isDetail = false |
||||
this.getList() |
||||
}, |
||||
} |
||||
}; |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
/deep/.expert-dia { |
||||
.overflow { |
||||
max-height: calc(100vh - 100px); |
||||
padding-right: 40px; |
||||
overflow: auto; |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,19 @@ |
||||
import BasicLayout from '@/layouts/home' |
||||
|
||||
const meta = {} |
||||
|
||||
export default { |
||||
path: '/expert', |
||||
redirect: { |
||||
path: `/expert/list` |
||||
}, |
||||
meta, |
||||
component: BasicLayout, |
||||
children: [ |
||||
{ |
||||
path: 'list', |
||||
component: () => import('@/pages/expert/list'), |
||||
meta: { title: '专家管理' } |
||||
}, |
||||
] |
||||
}; |
Loading…
Reference in new issue