parent
b5f1687931
commit
f4850af50f
6 changed files with 955 additions and 957 deletions
File diff suppressed because it is too large
Load Diff
@ -1,387 +0,0 @@ |
||||
<template> |
||||
<div> |
||||
<div> |
||||
<div class="flex-between m-b-20"> |
||||
<h6 class="p-title" style="margin-bottom: 0">员工组织架构</h6> |
||||
<el-button type="text" @click="addMajor">添加</el-button> |
||||
</div> |
||||
<org-tree |
||||
:data="orgList" |
||||
show-checkbox |
||||
default-expand-all |
||||
ref="orgTree" |
||||
node-key="id" |
||||
highlight-current |
||||
:expand-on-click-node="false" |
||||
@node-click="getSingle" |
||||
@check="getCheck" |
||||
:props="{children: 'children', label: 'label', isLeaf: 'leaf'}" |
||||
> |
||||
<span class="custom-tree-node" slot-scope="{ node, data }"> |
||||
<span style="display: inline-block; margin-right: 20px">{{ node.label }}</span> |
||||
<span> |
||||
<el-button |
||||
type="text" |
||||
icon="el-icon-edit-outline" |
||||
@click="() => handleEdit(node, data)"> |
||||
</el-button> |
||||
<el-button |
||||
v-if="node.level === 1" |
||||
type="text" |
||||
icon="el-icon-circle-plus-outline" |
||||
@click="() => handleAdd(node, data)"> |
||||
</el-button> |
||||
<el-button |
||||
type="text" |
||||
icon="el-icon-delete" |
||||
@click="() => handleDel(node, data)"> |
||||
</el-button> |
||||
</span> |
||||
</span> |
||||
</org-tree> |
||||
</div> |
||||
|
||||
<el-dialog :title="Form.staffArchitectureId ? '编辑部门' : '新增部门'" :visible.sync="majorVisible" width="24%" center @close="closeAdd" :close-on-click-modal="false"> |
||||
<el-form ref="Form" :model="Form" :rules="rules"> |
||||
<el-form-item prop="staffArchitectureName"> |
||||
<el-input placeholder="请输入专业名称" v-model="Form.staffArchitectureName"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button @click="majorVisible = false">取 消</el-button> |
||||
<el-button type="primary" @click="sure('Form')">确 定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
|
||||
<el-dialog :title="Form.gradeId ? '编辑部门' : '新增部门'" :visible.sync="depVisible" width="24%" center @close="closeAdd" :close-on-click-modal="false"> |
||||
<el-form ref="Form" :model="Form" :rules="rules"> |
||||
<el-form-item prop="gradeName"> |
||||
<el-input placeholder="请输入部门名称" v-model="Form.gradeName"></el-input> |
||||
</el-form-item> |
||||
</el-form> |
||||
<span slot="footer" class="dialog-footer"> |
||||
<el-button @click="depVisible = false">取 消</el-button> |
||||
<el-button type="primary" @click="sureDepartment('Form')">确 定</el-button> |
||||
</span> |
||||
</el-dialog> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import OrgTree from "@/components/org-tree/src/tree"; |
||||
export default { |
||||
props: ["Data"], |
||||
data() { |
||||
return { |
||||
orgList: [], |
||||
firactive: 0, |
||||
twoactive: 0, |
||||
majorVisible: false, |
||||
depVisible: false, |
||||
Form: { |
||||
staffArchitectureId: "", // 专业ID |
||||
staffArchitectureName: "", // // 专业名称 |
||||
gradeId: "", |
||||
gradeName: "" |
||||
}, |
||||
rules: { |
||||
staffArchitectureName: [ |
||||
{ required: true, message: "请输入专业名称", trigger: "blur" } |
||||
], |
||||
gradeName: [ |
||||
{ required: true, message: "请输入部门名称", trigger: "blur" } |
||||
] |
||||
}, |
||||
staffstateProfessId: "", |
||||
staffstateId: "", |
||||
}; |
||||
}, |
||||
components: { |
||||
OrgTree |
||||
}, |
||||
mounted() { |
||||
// this.getStaff() |
||||
}, |
||||
methods: { |
||||
getStaff() { |
||||
this.$get(this.api.professionalList).then(res => { |
||||
if (res.data && res.data.length) { |
||||
res.data.map(e => { |
||||
(e.ifVisible = false), (e.ischeck = false), (e.label = e.staffArchitectureName), (e.id = e.staffArchitectureId); |
||||
let data = { |
||||
staffArchitectureId: e.staffArchitectureId |
||||
} |
||||
this.$get(this.api.staffGradeList, data).then(res => { |
||||
res.data.map(e => { |
||||
(e.ischeck = false), (e.label = e.gradeName), (e.id = e.gradeId) |
||||
}) |
||||
e.children = res.data |
||||
}).catch(res => {}) |
||||
}); |
||||
} |
||||
setTimeout(() => { |
||||
this.orgList = res.data; |
||||
}, 500) |
||||
}).catch(res => {}) |
||||
}, |
||||
closeAdd() { |
||||
this.$refs.Form.resetFields() |
||||
}, |
||||
getSingle(data) { |
||||
this.$emit('getSingle', data) |
||||
}, |
||||
getCheck(data, checked) { |
||||
this.$emit('getCheck', checked.checkedNodes) |
||||
}, |
||||
// 新增编辑专业 |
||||
addMajor() { |
||||
this.Form.staffArchitectureId = '' |
||||
this.Form.staffArchitectureName = '' |
||||
this.majorVisible = true |
||||
}, |
||||
sure(Form) { // 提交新增/修改专业 |
||||
this.$refs[Form].validate((valid) => { |
||||
if (valid) { |
||||
let data = { |
||||
staffArchitectureName: this.Form.staffArchitectureName, |
||||
staffArchitectureId: this.Form.staffArchitectureId, |
||||
isDel: 0 // 是否删除(0、未删除 1、已删除) |
||||
}; |
||||
if (this.Form.staffArchitectureId) { |
||||
this.$post(this.api.updateProfessional, data).then(res => { |
||||
this.$message.success("编辑成功"); |
||||
this.majorVisible = false; |
||||
this.orgList.map(e => { |
||||
if (e.staffArchitectureId == this.Form.staffArchitectureId) { |
||||
e.staffArchitectureName = this.Form.staffArchitectureName; |
||||
e.label = this.Form.staffArchitectureName; |
||||
} |
||||
}); |
||||
this.$emit("getData"); |
||||
}).catch(res => { |
||||
}); |
||||
} else { |
||||
this.$post(this.api.saveProfessional, data).then(res => { |
||||
this.$message.success("添加成功"); |
||||
this.majorVisible = false; |
||||
let newData = { |
||||
staffArchitectureId: res.staffArchitectureId, |
||||
staffArchitectureName: this.Form.staffArchitectureName, |
||||
label: this.Form.staffArchitectureName, |
||||
value: res.staffArchitectureId, |
||||
ifVisible: false, |
||||
ischeck: false, |
||||
children: [] |
||||
}; |
||||
this.orgList.push(newData); |
||||
}).catch(res => { |
||||
}); |
||||
} |
||||
} else { |
||||
return false; |
||||
} |
||||
}); |
||||
}, |
||||
handleAdd(node, data) { // 添加部门 |
||||
this.Form.gradeId = '' |
||||
this.Form.gradeName = '' |
||||
this.depVisible = true |
||||
this.Form.staffArchitectureId = data.staffArchitectureId |
||||
}, |
||||
handleEdit(node, data) { // 编辑部门 |
||||
if (node.level === 1) { |
||||
this.Form.staffArchitectureId = data.staffArchitectureId |
||||
this.Form.staffArchitectureName = data.staffArchitectureName |
||||
this.majorVisible = true |
||||
} else { |
||||
this.Form.gradeId = data.gradeId |
||||
this.Form.gradeName = data.gradeName |
||||
this.depVisible = true |
||||
} |
||||
for (let j = 0; j < this.orgList.length; j++) { |
||||
for (let k = 0; k < this.orgList[j].children.length; k++) { |
||||
if (this.orgList[j].children[k].gradeName == data.gradeName) { |
||||
this.Form.staffArchitectureId = this.orgList[j].staffArchitectureId; |
||||
} |
||||
} |
||||
} |
||||
}, |
||||
sureDepartment(Form) { // 提交新增编辑部门 |
||||
this.$refs[Form].validate((valid) => { |
||||
if (valid) { |
||||
let data = { |
||||
gradeId: this.Form.gradeId, |
||||
gradeName: this.Form.gradeName, |
||||
staffArchitectureId: this.Form.staffArchitectureId |
||||
}; |
||||
if (this.Form.gradeId) { |
||||
this.$post(this.api.updateGrade, data).then(res => { |
||||
this.$message.success("编辑成功"); |
||||
this.depVisible = false; |
||||
this.orgList.map(e => { |
||||
e.children.map(r => { |
||||
if (r.gradeId == this.Form.gradeId) { |
||||
r.gradeName = this.Form.gradeName; |
||||
r.label = this.Form.gradeName; |
||||
} |
||||
}); |
||||
}); |
||||
}).catch(res => { |
||||
}); |
||||
} else { |
||||
this.$post(this.api.saveGrade, data).then(res => { |
||||
this.$message.success("添加成功"); |
||||
this.depVisible = false; |
||||
let newData = { |
||||
gradeId: res.gradeId, |
||||
gradeName: this.Form.gradeName, |
||||
label: this.Form.gradeName, |
||||
value: res.gradeId, |
||||
ifVisible: false, |
||||
ischeck: false |
||||
}; |
||||
this.orgList.map(e => { |
||||
if (e.staffArchitectureId == this.Form.staffArchitectureId) { |
||||
e.ifVisible = true; |
||||
e.children.push(newData); |
||||
} |
||||
}); |
||||
}).catch(res => { |
||||
}); |
||||
} |
||||
} else { |
||||
return false; |
||||
} |
||||
}); |
||||
}, |
||||
handleDel(node, data) { |
||||
node.level === 1 ? this.delMajor(data) : this.delDepartment(data) |
||||
}, |
||||
delMajor(item) { |
||||
this.$confirm("确定要删除该专业吗?该操作将会删除该组织下的用户账号。", "提示", { |
||||
type: "warning" |
||||
}).then(() => { |
||||
this.$post(`${this.api.deleteProfessional}?staffArchitectureId=${item.staffArchitectureId}`).then(res => { |
||||
this.$message.success("删除成功") |
||||
this.$emit("getData") |
||||
this.getStaff() |
||||
}).catch(res => {}) |
||||
}).catch(() => {}) |
||||
}, |
||||
delDepartment(item) { |
||||
this.$confirm("确定要删除该部门吗?该操作将会删除该组织下的用户账号。", "提示", { |
||||
type: "warning" |
||||
}).then(() => { |
||||
this.$post(`${this.api.deleteGrade}?gradeId=${item.gradeId}`).then(res => { |
||||
this.$message.success("删除成功") |
||||
this.getStaff() |
||||
this.$emit("delDep", item, this.orgList) |
||||
this.$emit("getData") |
||||
}).catch(res => {}) |
||||
}).catch(() => {}) |
||||
} |
||||
} |
||||
}; |
||||
</script> |
||||
<style scoped> |
||||
.side_view { |
||||
height: 800px; |
||||
padding: 40px 20px; |
||||
background-color: #fff; |
||||
} |
||||
|
||||
.side_icon { |
||||
text-align: right; |
||||
} |
||||
|
||||
.side_icon i { |
||||
cursor: pointer; |
||||
font-size: 20px; |
||||
color: #9278FF; |
||||
} |
||||
|
||||
.side_tree { |
||||
width: 100%; |
||||
font-size: 14px; |
||||
color: #333; |
||||
} |
||||
|
||||
.side_tree i { |
||||
color: #9278FF; |
||||
margin-left: 10px; |
||||
} |
||||
|
||||
.fir_back { |
||||
width: 100%; |
||||
padding: 15px 0; |
||||
background: rgba(255, 255, 255, 1); |
||||
/* box-shadow:1px 14px 29px 0px rgba(138,97,250,0.19); */ |
||||
border-radius: 10px; |
||||
text-align: left; |
||||
} |
||||
|
||||
.fir_back:first-child { |
||||
margin-top: 20px; |
||||
} |
||||
|
||||
.fir_back:hover { |
||||
box-shadow: 1px 14px 29px 0px rgba(138, 97, 250, 0.19); |
||||
cursor: pointer; |
||||
} |
||||
|
||||
.fir_back span { |
||||
margin-left: 10px; |
||||
} |
||||
|
||||
.two_active { |
||||
color: #9278FF; |
||||
} |
||||
|
||||
/* .two_active:hover{ |
||||
color: #9278FF; |
||||
cursor:pointer; |
||||
} */ |
||||
.two_back:hover { |
||||
cursor: pointer; |
||||
color: #9278FF; |
||||
} |
||||
|
||||
.mar_top { |
||||
margin-top: 20px; |
||||
} |
||||
|
||||
.back_active { |
||||
box-shadow: 1px 14px 29px 0px rgba(138, 97, 250, 0.19); |
||||
} |
||||
|
||||
.bor_lef { |
||||
padding: 20px 0 0 0; |
||||
margin-left: 40px; |
||||
} |
||||
|
||||
.three_lef { |
||||
margin-left: 60px; |
||||
padding: 20px 0; |
||||
} |
||||
|
||||
.three_text { |
||||
font-size: 14px; |
||||
margin-top: 10px; |
||||
} |
||||
|
||||
.teacher_tab { |
||||
margin-left: 20px; |
||||
} |
||||
|
||||
.icon_select:before { |
||||
transform: rotate(180deg); |
||||
} |
||||
|
||||
.list-enter-active, .list-leave-active { |
||||
transition: all 1s; |
||||
} |
||||
|
||||
.list-enter, .list-leave-to { |
||||
opacity: 0; |
||||
transform: translateY(-30px); |
||||
} |
||||
</style> |
Loading…
Reference in new issue