3
3
id =" dept"
4
4
class =" widget-box" >
5
5
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
72
20
:model =" temp"
73
21
class =" small-space"
74
22
label-position =" left"
87
35
placeholder =" 请输入排序码" />
88
36
</el-form-item >
89
37
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
+
90
51
</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 >
105
59
106
60
</div >
107
61
</template >
108
62
109
63
<script >
110
64
import {
111
- DeptList ,
65
+ GetDeptTree ,
112
66
DeleteDept ,
113
67
GetDeptDetail ,
114
68
AddDept ,
115
69
UpdateDept ,
116
70
} from ' @/api/system/dept' ;
117
71
72
+ import {
73
+ GetUnitTree ,
74
+ } from ' @/api/system/unit' ;
75
+
118
76
export default {
119
77
name: ' Dept' ,
120
78
data () {
121
79
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 ,
130
83
temp: {
131
84
id: ' ' ,
132
85
deptname: ' ' ,
133
86
rank: ' ' ,
134
87
isdeleted: false ,
135
88
},
136
- listQuery: {
137
- totalCount: 0 ,
138
- pageSize: 10 ,
139
- pageNumber: 1 ,
140
- },
141
- depttree: [],
142
89
defaultProps: {
143
90
children: ' children' ,
144
- label: ' text ' ,
91
+ label: ' nodeName ' ,
145
92
},
146
93
}
147
94
},
148
95
149
96
created () {
150
- // GetDeptTree().then(response => {
151
- // this.depttree = JSON.parse(response.data);
152
- // });
153
- this .fetchData (this .listQuery )
97
+ this .fetchDept ()
98
+ this .fetchUnit ()
154
99
},
155
100
methods: {
156
101
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
- },
165
102
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 ;
172
106
});
173
107
},
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
+ }) ;
179
113
},
114
+
180
115
Delete (id ) {
181
116
this .$confirm (' 确认删除?' , ' 提示' , {
182
117
confirmButtonText: ' 确定' ,
@@ -185,33 +120,23 @@ export default {
185
120
})
186
121
.then (() => {
187
122
DeleteDept (id).then (() => {
188
- this .fetchData ()
123
+ this .fetchDept ()
189
124
})
190
125
})
191
126
},
192
127
Edit (id ) {
193
- this .dialogStatus = ' update' ;
194
-
195
128
GetDeptDetail (id).then ((response ) => {
196
- this .dialogStatus = ' update' ;
197
129
this .temp = response .data ;
198
- console .log (this .temp )
199
- this .dialogFormVisible = true ;
200
130
});
201
131
},
202
-
203
-
204
132
create () {
205
133
AddDept (this .temp ).then (() => {
206
- this .dialogFormVisible = false ;
207
- this .fetchData ();
134
+ this .fetchDept ();
208
135
});
209
136
},
210
137
update () {
211
138
UpdateDept (this .temp ).then (() => {
212
- this .dialogFormVisible = false ;
213
-
214
- this .fetchData ();
139
+ this .fetchDept ();
215
140
});
216
141
},
217
142
},
0 commit comments