Skip to content

Commit

Permalink
完善部门单位关联配置
Browse files Browse the repository at this point in the history
新增tree filter查询
guid()方法全局引入
  • Loading branch information
BoBoooooo committed Feb 3, 2019
1 parent fff5557 commit cdc26c1
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/components/FormDesigner/Container.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable no-unused-expressions */
/* eslint-disable no-unused-vars */
/* eslint-disable */
<template>

<el-container class="widget-config-container">
Expand All @@ -23,8 +20,7 @@
style="border:none"
type="text"
size="medium"
icon="el-icon-star-on
"
icon="el-icon-star-on"
@click="save">保存</el-button>
<el-button
style="border:none;"
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ import '@/icons/index' // icon
import '@/permission' // 权限import axios from 'axios';
import '@/styles/index.scss' // global css
import CrudTable from '@/components/CrudTable';
import { newGuid } from '@/utils/index'

Vue.use(ElementUI)
Vue.component('crud-table', CrudTable) // 注册全局增删改查table组件
Vue.config.productionTip = false
Vue.prototype.axios = fetch // 全局基于拦截器配置后的ajax 拦截器在 utils/fetch
Vue.prototype.Guid = newGuid // 全局基于拦截器配置后的ajax 拦截器在 utils/fetch

new Vue({
el: '#app',
router,
Expand Down
13 changes: 13 additions & 0 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,17 @@ code {

.widget-border-top{
border-top:5px solid $primary;
}

.no-boxshadow{
box-shadow:none;
}

.no-padding-top{
padding-top:0px;
}


.no-margin-top{
margin-top:0px;
}
4 changes: 3 additions & 1 deletion src/styles/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@
}
}
}

.el-menu-item{
padding-left:10px!important;
}
.el-menu-item>span{
margin-left:-10px;
}
Expand Down
42 changes: 37 additions & 5 deletions src/views/system/dept.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@

<el-row>
<el-col :span="8">
<el-input
placeholder="输入关键字进行过滤"
v-model="filterText" style="width:80%;">
</el-input>

<el-tree
class="filter-tree"
ref="depttree"
:data="deptList"
:props="defaultProps"
node-key="id"
highlight-current
:filter-node-method="filterNode"

:default-expanded-keys="['00000000-0000-0001-0000-000000000000']"
@node-click="deptTreeClick"
/>
Expand All @@ -23,7 +30,7 @@
:model="temp"
class="small-space"
label-position="left"
label-width="70px">
label-width="70px" v-if="temp">
<el-form-item label="部门名称">
<el-input
v-model="temp.deptname"
Expand Down Expand Up @@ -99,10 +106,12 @@ import {
GetUnitTree,
} from '@/api/system/unit';
export default {
name: 'Dept',
data() {
return {
filterText: '',
deptoptions: [],
status: 'create',
deptList: null,
Expand All @@ -115,23 +124,39 @@ export default {
}
},
watch: {
filterText(val) {
this.$nextTick(() => {
this.$refs.depttree.filter(val);
})
},
},
created() {
getObj().then((res) => {
this.temp = res.data
})
DeptList().then((res) => {
this.deptoptions = res.data.list;
})
this.fetchDept()
this.fetchUnit()
},
methods: {
filterNode(value, data) {
if (!value) return true;
return data.nodeName.includes(value) !== false;
},
clearObj() {
Object.keys(this.temp).forEach((key) => {
this.temp[key] = ''
})
this.status = 'create'
this.$nextTick(() => {
this.$refs.unittree.setCheckedKeys([]);
});
},
fetchDept() {
GetDeptTree().then((response) => {
Expand Down Expand Up @@ -163,16 +188,23 @@ export default {
},
Edit(id) {
GetDeptDetail(id).then((response) => {
this.temp = response.data;
this.temp = response.data.obj;
this.$refs.unittree.setCheckedKeys(response.data.unitlist);
});
},
save() {
const obj = {}
obj.obj = JSON.parse(JSON.stringify(this.temp))
obj.unitlist = this.$refs.unittree.getCheckedKeys()
if (this.status === 'create') {
AddDept(this.temp).then(() => {
obj.obj.id = this.Guid()
AddDept(obj).then(() => {
this.fetchDept();
})
} else {
UpdateDept(this.temp).then(() => {
UpdateDept(obj).then(() => {
this.fetchDept();
})
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/system/dict.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/>
</el-col>
<el-col :span="16">
<crud-table tableName="dict" toolbarButton="add,clear,search" handleButton="edit,delete"></crud-table>
<crud-table tableName="dict" class="no-boxshadow no-padding-top" toolbarButton="add,clear" handleButton="edit,delete"></crud-table>

</el-col>

Expand Down
26 changes: 24 additions & 2 deletions src/views/system/unit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

<el-row>
<el-col :span="8">

<el-input
placeholder="输入关键字进行过滤"
v-model="filterText" style="width:80%;">
</el-input>


<el-tree
ref="unittree"
:data="unitList"
Expand All @@ -21,7 +28,7 @@
:model="temp"
class="small-space"
label-position="left"
label-width="70px">
label-width="70px" v-if="temp">
<el-form-item label="单位名称">
<el-input
v-model="temp.unitname"
Expand Down Expand Up @@ -87,6 +94,8 @@ export default {
data() {
return {
unitoptions: [],
filterText: '',
status: 'create',
unitList: null,
temp: null,
Expand All @@ -106,8 +115,21 @@ export default {
})
this.fetchUnit()
},
methods: {
watch: {
filterText(val) {
this.$nextTick(() => {
this.$refs.depttree.filter(val);
})
},
},
methods: {
filterNode(value, data) {
if (!value) return true;
return data.nodeName.includes(value) !== false;
},
clearObj() {
Object.keys(this.temp).forEach((key) => {
this.temp[key] = ''
Expand Down

0 comments on commit cdc26c1

Please sign in to comment.