Skip to content

Commit 56cd922

Browse files
committed
修改部门设置 加入单位配置
1 parent 3d2c8da commit 56cd922

File tree

3 files changed

+106
-133
lines changed

3 files changed

+106
-133
lines changed

src/api/system/dept.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function UpdateDept(data) {
4242

4343
export function GetDeptTree() {
4444
return fetch({
45-
url: '/dept/pulldeptree',
45+
url: '/dept/treelist',
4646
method: 'post',
4747
})
4848
}

src/api/system/unit.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import fetch from '@/utils/fetch'
2+
3+
export function UnitList(params) {
4+
return fetch({
5+
url: '/unit/list',
6+
method: 'post',
7+
params,
8+
})
9+
}
10+
11+
export function DeleteUnit(id) {
12+
return fetch({
13+
url: '/unit/delete',
14+
method: 'post',
15+
params: { id },
16+
})
17+
}
18+
19+
export function GetUnitDetail(id) {
20+
return fetch({
21+
url: '/unit/detail',
22+
method: 'post',
23+
params: { id },
24+
})
25+
}
26+
27+
export function AddUnit(data) {
28+
return fetch({
29+
url: '/unit/add',
30+
method: 'post',
31+
data,
32+
})
33+
}
34+
35+
export function UpdateUnit(data) {
36+
return fetch({
37+
url: '/unit/update',
38+
method: 'post',
39+
data,
40+
})
41+
}
42+
43+
export function GetUnitTree() {
44+
return fetch({
45+
url: '/unit/treelist',
46+
method: 'post',
47+
})
48+
}

src/views/system/dept.vue

Lines changed: 57 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -3,72 +3,20 @@
33
id="dept"
44
class=" widget-box">
55

6-
<el-button
7-
type="primary"
8-
size="small"
9-
style="margin:10px 0px"
10-
@click="New()">新增</el-button>
11-
12-
<el-table
13-
v-loading.body="listLoading"
14-
:data="list"
15-
element-loading-text="拼命加载中"
16-
border
17-
fit
18-
highlight-current-row>
19-
<el-table-column
20-
align="center"
21-
label="序号"
22-
width="95">
23-
<template slot-scope="scope">
24-
{{ scope.$index+1 }}
25-
</template>
26-
</el-table-column>
27-
<el-table-column label="部门名称">
28-
<template slot-scope="scope">
29-
{{ scope.row.deptname }}
30-
</template>
31-
</el-table-column>
32-
<el-table-column label="排序码">
33-
<template slot-scope="scope">
34-
{{ scope.row.rank }}
35-
</template>
36-
</el-table-column>
37-
38-
<el-table-column
39-
label="操作"
40-
align="center"
41-
min-width="110px">
42-
<template slot-scope="scope">
43-
<el-button
44-
type="success"
45-
size="small"
46-
@click="Edit(scope.row.id)">编辑</el-button>
47-
48-
<el-button
49-
type="danger"
50-
size="small"
51-
@click="Delete(scope.row.id)">删除</el-button>
52-
</template>
53-
</el-table-column>
54-
</el-table>
55-
<el-pagination
56-
:current-page="listQuery.pageNumber"
57-
:page-sizes="[10, 20, 30]"
58-
:page-size="listQuery.pageSize"
59-
60-
:total="listQuery.totalCount"
61-
layout="total,sizes, prev, pager, next"
62-
style="margin-top:5px"
63-
@size-change="handleSizeChange"
64-
@current-change="handleCurrentChange"/>
65-
66-
<el-dialog
67-
:title="textMap[dialogStatus]"
68-
:visible.sync="dialogFormVisible"
69-
:modal-append-to-body="false"
70-
width="50%">
71-
<el-form
6+
7+
<el-row>
8+
<el-col :span="8">
9+
<el-tree
10+
ref="tree"
11+
:data="deptList"
12+
:props="defaultProps"
13+
show-checkbox
14+
node-key="nodeName"
15+
highlight-current
16+
check-strictly/>
17+
</el-col>
18+
<el-col :span="16">
19+
<el-form
7220
:model="temp"
7321
class="small-space"
7422
label-position="left"
@@ -87,96 +35,83 @@
8735
placeholder="请输入排序码"/>
8836
</el-form-item>
8937

38+
<el-form-item label="分管单位">
39+
<el-tree
40+
ref="tree"
41+
:data="unitList"
42+
:props="defaultProps"
43+
show-checkbox
44+
node-key="nodeName"
45+
highlight-current
46+
check-strictly/>
47+
48+
</el-form-item>
49+
50+
9051
</el-form>
91-
<div
92-
slot="footer"
93-
class="dialog-footer">
94-
<el-button @click="dialogFormVisible = false">取 消</el-button>
95-
<el-button
96-
v-if="dialogStatus=='create'"
97-
type="primary"
98-
@click="create">确 定</el-button>
99-
<el-button
100-
v-else
101-
type="primary"
102-
@click="update">确 定</el-button>
103-
</div>
104-
</el-dialog>
52+
53+
</el-col>
54+
55+
</el-row>
56+
57+
58+
<el-button>确 定</el-button>
10559

10660
</div>
10761
</template>
10862

10963
<script>
11064
import {
111-
DeptList,
65+
GetDeptTree,
11266
DeleteDept,
11367
GetDeptDetail,
11468
AddDept,
11569
UpdateDept,
11670
} from '@/api/system/dept';
11771
72+
import {
73+
GetUnitTree,
74+
} from '@/api/system/unit';
75+
11876
export default {
11977
name: 'Dept',
12078
data() {
12179
return {
122-
textMap: {
123-
update: '编辑',
124-
create: '新增',
125-
},
126-
dialogFormVisible: false,
127-
dialogStatus: '',
128-
list: null,
129-
listLoading: true,
80+
81+
deptList: null,
82+
unitList: null,
13083
temp: {
13184
id: '',
13285
deptname: '',
13386
rank: '',
13487
isdeleted: false,
13588
},
136-
listQuery: {
137-
totalCount: 0,
138-
pageSize: 10,
139-
pageNumber: 1,
140-
},
141-
depttree: [],
14289
defaultProps: {
14390
children: 'children',
144-
label: 'text',
91+
label: 'nodeName',
14592
},
14693
}
14794
},
14895
14996
created() {
150-
// GetDeptTree().then(response => {
151-
// this.depttree = JSON.parse(response.data);
152-
// });
153-
this.fetchData(this.listQuery)
97+
this.fetchDept()
98+
this.fetchUnit()
15499
},
155100
methods: {
156101
157-
handleSizeChange(val) {
158-
this.listQuery.pageSize = val
159-
this.fetchData(this.listQuery)
160-
},
161-
handleCurrentChange(val) {
162-
this.listQuery.pageNumber = val
163-
this.fetchData(this.listQuery)
164-
},
165102
166-
fetchData(params) {
167-
this.listLoading = true;
168-
DeptList(params).then((response) => {
169-
this.list = response.data.list
170-
this.listQuery.totalCount = parseInt(response.data.total, 10)
171-
this.listLoading = false
103+
fetchDept() {
104+
GetDeptTree().then((response) => {
105+
this.deptList = response.data;
172106
});
173107
},
174-
New() {
175-
this.dialogFormVisible = true;
176-
this.temp.deptname = '';
177-
this.temp.rank = '';
178-
this.dialogStatus = 'create';
108+
109+
fetchUnit() {
110+
GetUnitTree().then((response) => {
111+
this.unitList = response.data;
112+
});
179113
},
114+
180115
Delete(id) {
181116
this.$confirm('确认删除?', '提示', {
182117
confirmButtonText: '确定',
@@ -185,33 +120,23 @@ export default {
185120
})
186121
.then(() => {
187122
DeleteDept(id).then(() => {
188-
this.fetchData()
123+
this.fetchDept()
189124
})
190125
})
191126
},
192127
Edit(id) {
193-
this.dialogStatus = 'update';
194-
195128
GetDeptDetail(id).then((response) => {
196-
this.dialogStatus = 'update';
197129
this.temp = response.data;
198-
console.log(this.temp)
199-
this.dialogFormVisible = true;
200130
});
201131
},
202-
203-
204132
create() {
205133
AddDept(this.temp).then(() => {
206-
this.dialogFormVisible = false;
207-
this.fetchData();
134+
this.fetchDept();
208135
});
209136
},
210137
update() {
211138
UpdateDept(this.temp).then(() => {
212-
this.dialogFormVisible = false;
213-
214-
this.fetchData();
139+
this.fetchDept();
215140
});
216141
},
217142
},

0 commit comments

Comments
 (0)