部门管理修改

master
wanglei 7 months ago
parent e14ceac62a
commit 7991825176

@ -1,5 +1,21 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="company" v-if="!$store.state.user.tenantId">
<el-input
style="width: 200px"
placeholder="公司名称"
prefix-icon="el-icon-search"
v-model="gsInfo.tenantName"
@keyup.enter.native="getGsInfoList">
</el-input>
<div class="cp-content" style="width: 200px">
<div :class="gsInfo.active_id===item.id?'cp-item active':'cp-item'" @click="changCompany(item.id)" v-for="item in gsInfo.list">{{ item.name }}</div>
</div>
</div>
<div :class="$store.state.user.tenantId?'content-all':'content'">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
<el-form-item label="部门名称" prop="deptName"> <el-form-item label="部门名称" prop="deptName">
<el-input <el-input
@ -96,6 +112,8 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</div>
<!-- 添加或修改部门对话框 --> <!-- 添加或修改部门对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
@ -161,6 +179,7 @@
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"; import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { listTenant } from "@/api/pay/tenant";
export default { export default {
name: "Dept", name: "Dept",
@ -168,6 +187,12 @@ export default {
components: { Treeselect }, components: { Treeselect },
data() { data() {
return { return {
//
gsInfo:{
tenantName:'',
active_id:this.$store.state.user.tenantId,
list:[]
},
// //
loading: true, loading: true,
// //
@ -220,12 +245,37 @@ export default {
}; };
}, },
created() { created() {
if (!this.$store.state.user.tenantId) {
this.getGsInfoList()
}else {
this.gsInfo.active_id = this.$store.state.user.tenantId
this.getList(); this.getList();
}
}, },
methods: { methods: {
//
getGsInfoList(){
listTenant({ name: this.gsInfo.tenantName }).then(response => {
if(response.rows.length>0){
this.gsInfo.list = response.rows;
this.gsInfo.active_id = this.gsInfo.list[0].id
this.getList()
}else{
this.$alert(`没有查到相关公司,暂无数据!`, `提示`, {
type: 'warning'
});
}
});
},
//
changCompany(id){
this.gsInfo.active_id = id
this.getList()
},
/** 查询部门列表 */ /** 查询部门列表 */
getList() { getList() {
this.loading = true; this.loading = true;
this.queryParams.tenantId = this.gsInfo.active_id;
listDept(this.queryParams).then(response => { listDept(this.queryParams).then(response => {
this.deptList = this.handleTree(response.data, "deptId"); this.deptList = this.handleTree(response.data, "deptId");
this.loading = false; this.loading = false;
@ -278,7 +328,7 @@ export default {
} }
this.open = true; this.open = true;
this.title = "添加部门"; this.title = "添加部门";
listDept().then(response => { listDept(this.queryParams).then(response => {
this.deptOptions = this.handleTree(response.data, "deptId"); this.deptOptions = this.handleTree(response.data, "deptId");
}); });
}, },
@ -310,6 +360,7 @@ export default {
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
this.form.tenantId = this.gsInfo.active_id;
if (this.form.deptId != undefined) { if (this.form.deptId != undefined) {
updateDept(this.form).then(response => { updateDept(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
@ -338,3 +389,43 @@ export default {
} }
}; };
</script> </script>
<style scoped lang="scss">
.app-container {
display: flex;
.company {
border-radius: 5px;
width: 230px;
height: calc(100vh - 115px);
overflow-y: auto;
.cp-content {
margin-top: 20px;
.cp-item {
cursor: pointer;
padding: 6px 10px 6px 5px;
color: #424242;
font-size: 14px;
&:hover {
background: #f6f6f6;
}
}
.active{
background: #edf6ff;
}
}
}
.content{
padding-left: 15px;
width: calc(100% - 250px);
.el-button--medium {
padding: 2px 0px;
}
}
.content-all{
width: 100%;
.el-button--medium {
padding: 2px 0px;
}
}
}
</style>

Loading…
Cancel
Save