Skip to content

Commit

Permalink
增加单位设置
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Jan 28, 2019
1 parent d5569ff commit 9163126
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/api/system/dept.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,3 @@ export function getObj() {
method: 'post',
})
}

export function save(data) {
return fetch({
url: '/dept/saveOrUpdate',
method: 'post',
data,
})
}
10 changes: 10 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,16 @@ export const asyncRouterMap = [{
title: '部门设置',
},
},
{
path: 'unit',
name: 'unit',
noDropdown: false,
hidden: false,
component: () => import('@/views/system/unit'),
meta: {
title: '单位设置',
},
},
{
path: 'role',
name: 'role',
Expand Down
169 changes: 169 additions & 0 deletions src/views/system/unit.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<template>
<div
id="unit"
class="widget-box">


<el-row>
<el-col :span="8">
<el-tree
ref="unittree"
:data="unitList"
:props="defaultProps"
node-key="id"
highlight-current
:default-expanded-keys="['00000000-0000-0001-0000-000000000000']"
@node-click="unitTreeClick"
/>
</el-col>
<el-col :span="16">
<el-form
:model="temp"
class="small-space"
label-position="left"
label-width="70px">
<el-form-item label="单位名称">
<el-input
v-model="temp.unitname"
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 unitoptions"
:key="item.id"

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

</el-form-item>

<el-form-item label="排序码">
<el-input
v-model="temp.rank"
class="filter-item"
placeholder="请输入排序码"/>
</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>

</div>
</template>

<script>
import {
GetUnitTree,
DeleteUnit,
UnitList,
GetUnitDetail,
AddUnit,
UpdateUnit,
getObj,
} from '@/api/system/unit';
export default {
name: 'Unit',
data() {
return {
unitoptions: [],
status: 'create',
unitList: null,
temp: null,
defaultProps: {
children: 'children',
label: 'nodeName',
},
}
},
created() {
getObj().then((res) => {
this.temp = res.data
})
UnitList().then((res) => {
this.unitoptions = res.data.list;
})
this.fetchUnit()
this.fetchUnit()
},
methods: {
clearObj() {
Object.keys(this.temp).forEach((key) => {
this.temp[key] = ''
})
this.status = 'create'
},
fetchUnit() {
GetUnitTree().then((response) => {
this.unitList = response.data;
});
},
unitTreeClick(obj) {
this.status = 'update'
this.Edit(obj.id)
},
Delete() {
this.$confirm('确认删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
DeleteUnit(this.temp.id).then(() => {
this.fetchUnit()
})
})
},
Edit(id) {
GetUnitDetail(id).then((response) => {
this.temp = response.data;
});
},
save() {
if (this.status === 'create') {
AddUnit(this.temp).then(() => {
this.fetchUnit();
})
} else {
UpdateUnit(this.temp).then(() => {
this.fetchUnit();
})
}
},
},
};
</script>

<style scope>
.tree{
max-height:400px;
overflow: auto;
}
.dialog-footer{
text-align: center;
}
</style>

0 comments on commit 9163126

Please sign in to comment.