|
|
|
@ -3,7 +3,7 @@ |
|
|
|
|
<div class="page" style="width: 320px"> |
|
|
|
|
<div class="m-b-20"> |
|
|
|
|
<p class="page-name mb">后台员工账号</p> |
|
|
|
|
<el-radio-group v-model="studentType" @change="changeType"> |
|
|
|
|
<el-radio-group v-model="staffType" @change="changeType"> |
|
|
|
|
<div class="m-b-20"> |
|
|
|
|
<el-radio :label="1">所有员工</el-radio> |
|
|
|
|
</div> |
|
|
|
@ -20,7 +20,7 @@ |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<div style="height: 504px;overflow: auto"> |
|
|
|
|
<el-tree class="org" ref="orgs" :data="orgs" :props="defaultProps" default-expand-all node-key="id" @node-click="handleNodeClick"> |
|
|
|
|
<el-tree class="org" ref="orgs" :data="orgs" :props="defaultProps" highlight-current :expand-on-click-node="false" default-expand-all node-key="id" @node-click="handleNodeClick"> |
|
|
|
|
<span class="node-wrap" slot-scope="{ node, data }"> |
|
|
|
|
<div class="left"> |
|
|
|
|
<img src="@/assets/img/node.png" alt=""> |
|
|
|
@ -76,8 +76,7 @@ |
|
|
|
|
<div class="page list-wrap"> |
|
|
|
|
<div class="tool"> |
|
|
|
|
<div class="search-wrap"> |
|
|
|
|
<el-input placeholder="请输入员工姓名" v-model.trim="keyword" clearable @keyup.enter.native="initData"></el-input> |
|
|
|
|
<el-button type="primary" @click="initData">查询</el-button> |
|
|
|
|
<el-input placeholder="请输入员工姓名/账号" v-model.trim="keyword" clearable></el-input> |
|
|
|
|
</div> |
|
|
|
|
<div class="actions"> |
|
|
|
|
<el-dropdown class="setting" trigger="click" :hide-on-click="false"> |
|
|
|
@ -123,7 +122,7 @@ |
|
|
|
|
<el-pagination background @current-change="currentChange" :current-page="page" layout="total, prev, pager, next" :total="total"></el-pagination> |
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
<el-dialog :title="isDetail ? '查看' : (form.accountId ? '编辑' : '新增') + '员工'" :visible.sync="staffVisible" width="500px" class="dialog" :close-on-click-modal="false" @close="closeStaff"> |
|
|
|
|
<el-dialog :title="isDetail ? '查看' : (form.id ? '编辑' : '新增') + '员工'" :visible.sync="staffVisible" width="500px" class="dialog" :close-on-click-modal="false" @close="closeStaff"> |
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px" :disabled="isDetail" style='margin-right: 60px;'> |
|
|
|
|
<el-form-item prop="jobNumber" label="工号"> |
|
|
|
|
<el-input v-model.trim="form.jobNumber" placeholder="请输入工号"></el-input> |
|
|
|
@ -139,7 +138,7 @@ |
|
|
|
|
<template v-for="item in roleIds"> |
|
|
|
|
<!-- 不显示超管 --> |
|
|
|
|
<el-option |
|
|
|
|
v-if="item.roleName !== '超级管理员'" |
|
|
|
|
v-if="item.name !== '超级管理员'" |
|
|
|
|
:key="item.id" |
|
|
|
|
:label="item.name" |
|
|
|
|
:value="item.id"> |
|
|
|
@ -242,39 +241,13 @@ export default { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
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 { |
|
|
|
|
orgs: [], |
|
|
|
|
defaultProps: { |
|
|
|
|
label: 'name' |
|
|
|
|
}, |
|
|
|
|
orgListDia: [], |
|
|
|
|
studentType: 1, //类型:必填一个(1.所有员工 2.未加入班级员工) |
|
|
|
|
staffType: 1, //类型:必填一个(1.所有员工 2.未加入班级员工) |
|
|
|
|
orgVisible: false, // 员工组织架对话框 |
|
|
|
|
orgForm: { |
|
|
|
|
id: '', |
|
|
|
@ -291,6 +264,7 @@ export default { |
|
|
|
|
treeResolve: [], |
|
|
|
|
isDetail: false, |
|
|
|
|
keyword: '', |
|
|
|
|
searchTimer: null, |
|
|
|
|
originSettings: [], |
|
|
|
|
settings: [ |
|
|
|
|
{ |
|
|
|
@ -343,7 +317,7 @@ export default { |
|
|
|
|
phone: '', |
|
|
|
|
jobNumber: '', |
|
|
|
|
email: '', |
|
|
|
|
groupId: '', |
|
|
|
|
groupId: 1, |
|
|
|
|
roleIds: [], |
|
|
|
|
deptArchitectureId: [] |
|
|
|
|
}, |
|
|
|
@ -365,11 +339,8 @@ export default { |
|
|
|
|
roleIds: [ |
|
|
|
|
{ required: true, message: "请选择授权角色", trigger: "change" } |
|
|
|
|
], |
|
|
|
|
phone: [ |
|
|
|
|
{ validator: phonePass, trigger: 'blur' } |
|
|
|
|
], |
|
|
|
|
email: [ |
|
|
|
|
{ validator: emailPass, trigger: 'blur' } |
|
|
|
|
groupId: [ |
|
|
|
|
{ required: true, message: "请选择用户组", trigger: "change" } |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
list: [], |
|
|
|
@ -392,6 +363,7 @@ export default { |
|
|
|
|
value: 'id', |
|
|
|
|
isLeaf: 'leaf' |
|
|
|
|
}, |
|
|
|
|
archId: [], |
|
|
|
|
|
|
|
|
|
importVisible: false, |
|
|
|
|
uploadList: [], |
|
|
|
@ -420,9 +392,15 @@ export default { |
|
|
|
|
this.originForm = JSON.parse(JSON.stringify(this.form)) |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
|
filterText(val) { |
|
|
|
|
this.$refs.classTree.filter(val); |
|
|
|
|
} |
|
|
|
|
keyword: function(val) { |
|
|
|
|
clearTimeout(this.searchTimer) |
|
|
|
|
this.searchTimer = setTimeout(() => { |
|
|
|
|
this.initData() |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
filterText(val) { |
|
|
|
|
this.$refs.classTree.filter(val); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 获取组织树形 |
|
|
|
@ -533,7 +511,7 @@ export default { |
|
|
|
|
// 点击树节点查询列表数据 |
|
|
|
|
handleNodeClick(data) { |
|
|
|
|
this.$refs.table.clearSelection() |
|
|
|
|
this.studentType = null |
|
|
|
|
this.staffType = null |
|
|
|
|
this.getStaff() |
|
|
|
|
}, |
|
|
|
|
// 关闭组织新增编辑弹框 |
|
|
|
@ -549,7 +527,7 @@ export default { |
|
|
|
|
// 员工列表 |
|
|
|
|
getStaff() { |
|
|
|
|
this.$post(this.api.users, { |
|
|
|
|
type: this.studentType || 1, |
|
|
|
|
type: this.staffType || 1, |
|
|
|
|
deptArchitectureId: this.$refs.orgs.getCurrentKey() || '', |
|
|
|
|
keyWord: this.keyword, |
|
|
|
|
pageNum: this.page, |
|
|
|
@ -602,7 +580,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 重置密码 |
|
|
|
|
resetPassword(row) { |
|
|
|
|
this.$confirm(`确定重置密码?`, "提示", { type: "warning" }).then(() => { |
|
|
|
|
this.$confirm(`确定重置密码?重置后密码为111aaa。`, "提示", { type: "warning" }).then(() => { |
|
|
|
|
this.$get(`${this.api.resetPwd}?userId=${row.id}`).then(res => { |
|
|
|
|
util.successMsg("重置成功") |
|
|
|
|
}).catch(res => {}) |
|
|
|
@ -610,36 +588,40 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 添加员工 |
|
|
|
|
addStaff() { |
|
|
|
|
if (!this.staffType) { |
|
|
|
|
this.archId = [] |
|
|
|
|
this.handleArchId(this.orgs, [this.$refs.orgs.getCurrentKey()]) |
|
|
|
|
this.form.deptArchitectureId = this.archId |
|
|
|
|
} |
|
|
|
|
this.staffVisible = true |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.$refs.form.clearValidate() |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 处理部门id |
|
|
|
|
handleArchId(list, ids, pid = []) { |
|
|
|
|
list.map(e => { |
|
|
|
|
// 把部门id分割成二维数组,[[1, 2], [3, 4]],每个层级的id都要放进去,后端返回的是最后一级的id,无法回显 |
|
|
|
|
if (ids.includes(e.id)) { |
|
|
|
|
this.archId.push([...pid, e.id]) |
|
|
|
|
} else { |
|
|
|
|
e.children && this.handleArchId(e.children, ids, [...pid, e.id]) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 编辑/查看 |
|
|
|
|
queryStaff(row, isDetail) { |
|
|
|
|
const archId = [] |
|
|
|
|
// 处理部门id |
|
|
|
|
const handleArchId = (list, ids, pid = []) => { |
|
|
|
|
list.map(e => { |
|
|
|
|
// 把部门id分割成二维数组,[[1, 2], [3, 4]],每个层级的id都要放进去,后端返回的是最后一级的id,无法回显 |
|
|
|
|
if (ids.includes(e.id)) { |
|
|
|
|
archId.push([...pid, e.id]) |
|
|
|
|
} else { |
|
|
|
|
e.children && handleArchId(e.children, ids, [...pid, e.id]) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.isDetail = isDetail |
|
|
|
|
this.staffVisible = true |
|
|
|
|
this.$get(`${this.api.user}/${row.id}`).then(({ data }) => { |
|
|
|
|
const { deptArchitectureId, roleId } = data |
|
|
|
|
if (roleId) { |
|
|
|
|
const roleIds = roleId.split(',') |
|
|
|
|
const ids = roleId.split(',') |
|
|
|
|
const list = this.roleIds |
|
|
|
|
if (roleIds.length) { |
|
|
|
|
if (ids.length) { |
|
|
|
|
let has = false // 是否在角色列表里有已选择的角色,全部都被删除了,则提示 |
|
|
|
|
for (const i in roleIds) { |
|
|
|
|
if (list.find(n => n.id === roleIds[i])) { |
|
|
|
|
for (const i in ids) { |
|
|
|
|
if (list.find(n => n.id === ids[i])) { |
|
|
|
|
has = true |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
@ -648,14 +630,16 @@ export default { |
|
|
|
|
util.warningMsg('角色被删请重新选择') |
|
|
|
|
data.roleIds = [] |
|
|
|
|
} else { |
|
|
|
|
data.roleIds = roleIds |
|
|
|
|
data.roleIds = ids |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (deptArchitectureId) { |
|
|
|
|
handleArchId(this.orgs, deptArchitectureId.split(',')) |
|
|
|
|
data.deptArchitectureId = archId |
|
|
|
|
this.archId = [] |
|
|
|
|
this.handleArchId(this.orgs, deptArchitectureId.split(',')) |
|
|
|
|
data.deptArchitectureId = this.archId |
|
|
|
|
} |
|
|
|
|
data.groupId = +data.groupId |
|
|
|
|
this.form = data |
|
|
|
|
this.originAccount = data.username |
|
|
|
|
this.originWorkNumber = data.jobNumber |
|
|
|
@ -705,32 +689,6 @@ export default { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 手机号判重 |
|
|
|
|
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) => { |
|
|
|
@ -775,7 +733,7 @@ export default { |
|
|
|
|
// 关闭新增员工对话框 |
|
|
|
|
closeStaff() { |
|
|
|
|
this.form = { |
|
|
|
|
accountId: '', |
|
|
|
|
id: '', |
|
|
|
|
realName: '', |
|
|
|
|
username: '', |
|
|
|
|
phone: '', |
|
|
|
@ -836,7 +794,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
uploadSure() { |
|
|
|
|
this.importVisible = false |
|
|
|
|
this.studentType = 1 |
|
|
|
|
this.staffType = 1 |
|
|
|
|
this.keyword = '' |
|
|
|
|
this.$refs.orgs.setCurrentKey(null) |
|
|
|
|
this.getOrg() |
|
|
|
|