|
|
|
@ -1,11 +1,10 @@ |
|
|
|
|
<template> |
|
|
|
|
<div> |
|
|
|
|
<el-row :gutter="20"> |
|
|
|
|
<el-col :span="4"> |
|
|
|
|
<div class="page"> |
|
|
|
|
<div class="wrap"> |
|
|
|
|
<!-- 左边的组织 --> |
|
|
|
|
<div class="side"> |
|
|
|
|
<div class="m-b-20"> |
|
|
|
|
<h6 class="p-title">后台员工账号</h6> |
|
|
|
|
<el-radio-group v-model="studentType" @change="initData"> |
|
|
|
|
<el-radio-group v-model="studentType" @change="changeType"> |
|
|
|
|
<div class="m-b-20"> |
|
|
|
|
<el-radio :label="1">所有员工</el-radio> |
|
|
|
|
</div> |
|
|
|
@ -35,6 +34,11 @@ |
|
|
|
|
<span class="custom-tree-node" slot-scope="{ node, data }"> |
|
|
|
|
<span class="org-name">{{ node.label }}</span> |
|
|
|
|
<span> |
|
|
|
|
<el-button |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-circle-plus-outline" |
|
|
|
|
@click="() => addOrg(node, data)"> |
|
|
|
|
</el-button> |
|
|
|
|
<el-button |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-edit-outline" |
|
|
|
@ -42,8 +46,8 @@ |
|
|
|
|
</el-button> |
|
|
|
|
<el-button |
|
|
|
|
type="text" |
|
|
|
|
icon="el-icon-circle-plus-outline" |
|
|
|
|
@click="() => addOrg(node, data)"> |
|
|
|
|
icon="el-icon-delete" |
|
|
|
|
@click="() => delOrg(node, data)"> |
|
|
|
|
</el-button> |
|
|
|
|
</span> |
|
|
|
|
</span> |
|
|
|
@ -57,7 +61,7 @@ |
|
|
|
|
:close-on-click-modal="false" |
|
|
|
|
width="50%" |
|
|
|
|
> |
|
|
|
|
<el-form v-if="orgVisible" ref="orgForm" :model="orgForm" :rules="rules" label-width="100px"> |
|
|
|
|
<el-form v-if="orgVisible" ref="orgForm" :model="orgForm" :rules="orgRules" label-width="100px"> |
|
|
|
|
<el-form-item label="部门名称" prop="organizationName"> |
|
|
|
|
<el-input v-model.trim="orgForm.organizationName" placeholder="请输入"></el-input> |
|
|
|
|
</el-form-item> |
|
|
|
@ -75,16 +79,13 @@ |
|
|
|
|
</el-form-item> |
|
|
|
|
</el-form> |
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
<el-button v-if="!orgForm.id" @click="closeOrg">取 消</el-button> |
|
|
|
|
<el-button v-else type="danger" plain @click="delOrg">删除</el-button> |
|
|
|
|
<el-button @click="closeOrg">取 消</el-button> |
|
|
|
|
<el-button type="primary" @click="orgSubmit">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
|
</el-col> |
|
|
|
|
<el-col :span="20"> |
|
|
|
|
<div class="page"> |
|
|
|
|
<!-- 右边的员工 --> |
|
|
|
|
<div class="right"> |
|
|
|
|
<h6 class="p-title">筛选</h6> |
|
|
|
|
<div class="tool"> |
|
|
|
|
<ul class="filter"> |
|
|
|
@ -178,7 +179,7 @@ |
|
|
|
|
:before-remove="beforeRemove" |
|
|
|
|
:limit="1" |
|
|
|
|
:on-exceed="handleExceed" |
|
|
|
|
:action="this.api.importStudent" |
|
|
|
|
:action="this.api.importStaff" |
|
|
|
|
:file-list="uploadList" |
|
|
|
|
:headers="headers" |
|
|
|
|
> |
|
|
|
@ -192,8 +193,6 @@ |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
</div> |
|
|
|
|
</el-col> |
|
|
|
|
</el-row> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
@ -288,6 +287,11 @@ export default { |
|
|
|
|
account: '', |
|
|
|
|
staffArchitectureId: [] |
|
|
|
|
}, |
|
|
|
|
orgRules: { |
|
|
|
|
organizationName: [ |
|
|
|
|
{ required: true, message: "请输入部门名称", trigger: "blur" } |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
rules: { |
|
|
|
|
account: [ |
|
|
|
|
{ required: true,validator: accountPass, trigger: 'blur' } |
|
|
|
@ -325,7 +329,8 @@ export default { |
|
|
|
|
multiple: true, |
|
|
|
|
checkStrictly: true, |
|
|
|
|
label: 'organizationName', |
|
|
|
|
value: 'id' |
|
|
|
|
value: 'id', |
|
|
|
|
isLeaf: 'leaf' |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
importVisible: false, |
|
|
|
@ -354,6 +359,17 @@ export default { |
|
|
|
|
async getOrg() { |
|
|
|
|
const res = await this.$post(this.api.treeListArch) |
|
|
|
|
const list = res.treeList |
|
|
|
|
// 没有子级,删除children属性 |
|
|
|
|
const handleLeaf = list => { |
|
|
|
|
list.map(e => { |
|
|
|
|
if (e.children.length) { |
|
|
|
|
handleLeaf(e.children) |
|
|
|
|
} else { |
|
|
|
|
delete e.children |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
handleLeaf(list) |
|
|
|
|
this.orgList = list |
|
|
|
|
this.handleOrgId(list) |
|
|
|
|
this.getStaff() |
|
|
|
@ -362,9 +378,13 @@ export default { |
|
|
|
|
handleOrgId(list, ids) { |
|
|
|
|
list.forEach(e => { |
|
|
|
|
e.ids = ids ? [...ids, e.id] : [e.id] |
|
|
|
|
this.handleOrgId(e.children, e.ids) |
|
|
|
|
e.children && this.handleOrgId(e.children, e.ids) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 组织类别筛选回调 |
|
|
|
|
changeType() { |
|
|
|
|
this.initData(true) |
|
|
|
|
}, |
|
|
|
|
// 添加部门 |
|
|
|
|
addOrg(node, data) { |
|
|
|
|
this.orgForm = { |
|
|
|
@ -397,25 +417,25 @@ export default { |
|
|
|
|
// 如果是已经找到了要禁选的层级,则直接改变disabled,并递归 |
|
|
|
|
if (disabled) { |
|
|
|
|
e.disabled = true |
|
|
|
|
this.handleOrg(e.children, id, 1) |
|
|
|
|
e.children && this.handleOrg(e.children, id, 1) |
|
|
|
|
} else { |
|
|
|
|
if (e.id === id) { |
|
|
|
|
e.disabled = true |
|
|
|
|
this.handleOrg(e.children, id, 1) |
|
|
|
|
e.children && this.handleOrg(e.children, id, 1) |
|
|
|
|
} else { |
|
|
|
|
this.handleOrg(e.children, id, 0) |
|
|
|
|
e.children && this.handleOrg(e.children, id, 0) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 删除部门 |
|
|
|
|
delOrg() { |
|
|
|
|
delOrg(node, data) { |
|
|
|
|
this.$confirm("确定要删除吗?", "提示", { |
|
|
|
|
type: "warning" |
|
|
|
|
}).then(() => { |
|
|
|
|
this.$post(`${this.api.deleteArch}?id=${this.orgForm.id}`).then(res => { |
|
|
|
|
this.$post(`${this.api.deleteArch}?id=${data.id}`).then(res => { |
|
|
|
|
util.successMsg("删除成功") |
|
|
|
|
this.closeOrg() |
|
|
|
|
this.getOrg() |
|
|
|
|
}).catch(res => {}) |
|
|
|
|
}).catch(() => {}) |
|
|
|
|
}, |
|
|
|
@ -459,10 +479,11 @@ export default { |
|
|
|
|
this.getOrg() |
|
|
|
|
}, |
|
|
|
|
// 员工列表 |
|
|
|
|
getStaff() { |
|
|
|
|
getStaff(fromType) { |
|
|
|
|
const orgId = this.$refs.orgTree.getCurrentKey() || '' |
|
|
|
|
this.$post(this.api.staffList, { |
|
|
|
|
type: this.studentType || 1, |
|
|
|
|
staffArchitectureId: this.$refs.orgTree.getCurrentKey() || '', |
|
|
|
|
staffArchitectureId: fromType ? '' : orgId, |
|
|
|
|
keyWord: this.keyWord, |
|
|
|
|
pageNum: this.page, |
|
|
|
|
pageSize: this.pageSize |
|
|
|
@ -479,10 +500,10 @@ export default { |
|
|
|
|
handleSelectionChange(val) { // 多选 |
|
|
|
|
this.multipleSelection = val |
|
|
|
|
}, |
|
|
|
|
initData() { |
|
|
|
|
initData(fromType) { |
|
|
|
|
this.$refs.table.clearSelection() |
|
|
|
|
this.page = 1 |
|
|
|
|
this.getStaff() |
|
|
|
|
this.getStaff(fromType) |
|
|
|
|
}, |
|
|
|
|
// 删除 |
|
|
|
|
delStaff(row) { |
|
|
|
@ -506,14 +527,34 @@ export default { |
|
|
|
|
// 添加员工 |
|
|
|
|
addStaff() { |
|
|
|
|
this.staffVisible = true |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
this.$refs.form.clearValidate() |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 编辑/查看 |
|
|
|
|
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.staffVisible = true |
|
|
|
|
this.$get(`${this.api.staffDetail}?accountId=${row.accountId}`).then(res => { |
|
|
|
|
const { data } = res |
|
|
|
|
data.staffArchitectureId = data.staffArchitectureId.split(',') |
|
|
|
|
const { staffArchitectureId, roleId } = data |
|
|
|
|
if (roleId) data.roleList = roleId.split(',').map(e => Number(e)) |
|
|
|
|
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 |
|
|
|
@ -521,7 +562,6 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 获取角色数据 |
|
|
|
|
getRole() { |
|
|
|
|
this.roleList =[] |
|
|
|
|
this.$get(`${this.api.roleList}?page=1&size=1000&name=&platformId=${Setting.platformId}`).then(res => { |
|
|
|
|
this.roleList = res.rolePage.records |
|
|
|
|
}).catch(res => {}) |
|
|
|
@ -586,16 +626,16 @@ export default { |
|
|
|
|
submitStaff() { |
|
|
|
|
this.$refs.form.validate((valid) => { |
|
|
|
|
if (valid) { |
|
|
|
|
debugger |
|
|
|
|
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 = this.form |
|
|
|
|
const form = JSON.parse(JSON.stringify(this.form)) |
|
|
|
|
const ids = form.staffArchitectureId |
|
|
|
|
form.staffArchitectureId = ids.map(e => e[e.length - 1]) |
|
|
|
|
console.log("🚀 ~ file: staff.vue ~ line 622 ~ this.$refs.form.validate ~ form", form) |
|
|
|
|
if (form.accountId) { |
|
|
|
|
this.$post(this.api.modifyStaff, form).then(res => { |
|
|
|
|
util.successMsg("编辑成功!") |
|
|
|
@ -651,7 +691,7 @@ export default { |
|
|
|
|
}, |
|
|
|
|
// 模板下载 |
|
|
|
|
downLoad() { |
|
|
|
|
location.href = this.api.studentTemplate |
|
|
|
|
location.href = this.api.staffTemplate |
|
|
|
|
}, |
|
|
|
|
// 上传文件 |
|
|
|
|
handleExceed(files, fileList) { |
|
|
|
@ -710,4 +750,19 @@ export default { |
|
|
|
|
.w-100 { |
|
|
|
|
width: 100%; |
|
|
|
|
} |
|
|
|
|
.wrap { |
|
|
|
|
display: flex; |
|
|
|
|
height: calc(100vh - 223px); |
|
|
|
|
padding: 0 24px; |
|
|
|
|
.side { |
|
|
|
|
width: 300px; |
|
|
|
|
padding: 24px 10px 24px 0; |
|
|
|
|
margin-right: 24px; |
|
|
|
|
border-right: 1px solid rgba(0, 0, 0, 0.06); |
|
|
|
|
} |
|
|
|
|
.right { |
|
|
|
|
width: calc(100% - 374px); |
|
|
|
|
padding: 24px 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |