Skip to content

Commit

Permalink
部门设置修改
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Jan 25, 2019
1 parent 56cd922 commit d5569ff
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 34 deletions.
16 changes: 16 additions & 0 deletions src/api/system/dept.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,19 @@ export function GetDeptTree() {
method: 'post',
})
}


export function getObj() {
return fetch({
url: '/dept/getObj',
method: 'post',
})
}

export function save(data) {
return fetch({
url: '/dept/saveOrUpdate',
method: 'post',
data,
})
}
6 changes: 6 additions & 0 deletions src/api/system/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ export function GetUnitTree() {
method: 'post',
})
}
export function getObj() {
return fetch({
url: '/unit/getObj',
method: 'post',
})
}
3 changes: 3 additions & 0 deletions src/styles/element-ui.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
.el-input__inner{

border-radius: 0;
}
.el-select{
width:100%!important;
}
.el-breadcrumb__inner, .el-breadcrumb__inner a{
font-weight: 400!important;
Expand Down
112 changes: 79 additions & 33 deletions src/views/system/dept.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
<template>
<div
id="dept"
class=" widget-box">
class="widget-box">


<el-row>
<el-col :span="8">
<el-tree
ref="tree"
ref="depttree"
:data="deptList"
:props="defaultProps"
show-checkbox
node-key="nodeName"
node-key="id"
highlight-current
check-strictly/>
:default-expanded-keys="['00000000-0000-0001-0000-000000000000']"
@node-click="deptTreeClick"
/>
</el-col>
<el-col :span="16">
<el-form
:model="temp"
class="small-space"
label-position="left"
label-width="70px">

<el-form-item label="部门名称">
<el-form-item label="部门名称">
<el-input
v-model="temp.deptname"
class="filter-item"
placeholder="请输入部门名称"/>
</el-form-item>
<el-form-item label="上级部门">
<el-select
v-model="temp.parentid"
placeholder="请选择"
filterable>
<el-option
v-for="item in deptoptions"
:key="item.id"

:label="item.deptname"
:value="item.id"/>
</el-select>

</el-form-item>

<el-form-item label="排序码">
<el-input
v-model="temp.rank"
Expand All @@ -37,36 +52,45 @@

<el-form-item label="分管单位">
<el-tree
ref="tree"
ref="unittree"
:data="unitList"
:props="defaultProps"
show-checkbox
node-key="nodeName"
node-key="id"
highlight-current
check-strictly/>
check-strictly class="tree"/>

</el-form-item>


</el-form>

<div
class="dialog-footer">
<el-button
type="success"
@click="clearObj">新 增</el-button>
<el-button
type="primary"
@click="save">保 存</el-button>
<el-button v-if="status==='update'" type="danger" @click="Delete">删 除</el-button>

</div>
</el-col>

</el-row>


<el-button>确 定</el-button>

</div>
</template>

<script>
import {
GetDeptTree,
DeleteDept,
DeptList,
GetDeptDetail,
AddDept,
UpdateDept,
getObj,
} from '@/api/system/dept';
import {
Expand All @@ -77,15 +101,11 @@ export default {
name: 'Dept',
data() {
return {
deptoptions: [],
status: 'create',
deptList: null,
unitList: null,
temp: {
id: '',
deptname: '',
rank: '',
isdeleted: false,
},
temp: null,
defaultProps: {
children: 'children',
label: 'nodeName',
Expand All @@ -94,12 +114,23 @@ export default {
},
created() {
getObj().then((res) => {
this.temp = res.data
})
DeptList().then((res) => {
this.deptoptions = res.data.list;
})
this.fetchDept()
this.fetchUnit()
},
methods: {
clearObj() {
Object.keys(this.temp).forEach((key) => {
this.temp[key] = ''
})
this.status = 'create'
},
fetchDept() {
GetDeptTree().then((response) => {
this.deptList = response.data;
Expand All @@ -111,15 +142,19 @@ export default {
this.unitList = response.data;
});
},
deptTreeClick(obj) {
this.status = 'update'
this.Edit(obj.id)
},
Delete(id) {
Delete() {
this.$confirm('确认删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
DeleteDept(id).then(() => {
DeleteDept(this.temp.id).then(() => {
this.fetchDept()
})
})
Expand All @@ -129,17 +164,28 @@ export default {
this.temp = response.data;
});
},
create() {
AddDept(this.temp).then(() => {
this.fetchDept();
});
},
update() {
UpdateDept(this.temp).then(() => {
this.fetchDept();
});
save() {
if (this.status === 'create') {
AddDept(this.temp).then(() => {
this.fetchDept();
})
} else {
UpdateDept(this.temp).then(() => {
this.fetchDept();
})
}
},
},
};
</script>

<style scope>
.tree{
max-height:400px;
overflow: auto;
}
.dialog-footer{
text-align: center;
}
</style>
4 changes: 3 additions & 1 deletion src/views/system/users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@
<el-form-item label="部门">
<el-select
v-model="temp.deptid"
placeholder="请选择">
placeholder="请选择"
filterable>
<el-option
v-for="item in deptoptions"
:key="item.id"

:label="item.deptname"
:value="item.id"/>
</el-select>
Expand Down

0 comments on commit d5569ff

Please sign in to comment.