1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<template>
<div class="oran-wrapper height100">
<div class="org-tree-container">
<div class="org-tree-box">
<div class="org-tree-box-header">组织结构</div>
<div class="org-tree-box-content">
<div class="tree-search party-form">
<el-input placeholder="请输入组织结构名称" v-model="name">
<i
slot="suffix"
class="el-input__icon el-icon-search"
@click="getOrgTree()"
>
</i>
</el-input>
<div class="f0" style="display: flex">
<el-tooltip content="新建" placement="top">
<i class="icon-add party-icon-20" @click="handleAdd('add')" />
</el-tooltip>
<el-tooltip content="导入" placement="top">
<el-upload
action=""
:http-request="handleRequest"
:show-file-list="false"
:before-upload="beforeAvatarUpload"
accept="application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
>
<i class="icon-import party-icon-20" />
</el-upload>
</el-tooltip>
</div>
</div>
<div class="tree-content">
<el-tree
class="org-tree"
:data="data"
:props="defaultProps"
@node-click="handleNodeClick"
>
<div
class="custom-tree-node"
slot-scope="{ node, data }"
:class="'tree-node-level' + data.level"
>
<i class="icon-org" v-if="data.level === 1"></i>
<span>{{ node.label }}</span>
</div>
</el-tree>
</div>
</div>
</div>
</div>
<div class="org-detail">
<div class="org-detail-panel-box">
<span class="title">{{ currentInfo.name }}</span>
<div class="icon-group">
<i class="icon-edit party-icon-24" @click="handleEdit()"> </i>
<i class="icon-del party-icon-24" @click="handleDel()"> </i>
</div>
</div>
<div class="org-detail-panel-box-content">
<div class="page-tip">
<p class="page-tip-title">页面说明:</p>
<p class="page-tip-des">
点击相应的机构名称,可查看该机构的详细信息。可新增机构、删除机构及批量导入机构信息。新增机构中“*”为必填项
</p>
</div>
<el-form label-position="top">
<el-form-item label="上级机构" class="w100">
<span>
{{ currentInfo.parentName || "暂无上级机构" }}
</span>
</el-form-item>
<el-form-item label="下级机构" class="w100">
<span>
{{ currentInfo.childrenName || "暂无下级机构" }}
</span>
</el-form-item>
<el-form-item label="地理位置" class="w100">
<span>
{{ currentInfo.areaName || "暂无地理位置信息" }}
</span>
</el-form-item>
<el-form-item label="备注信息" class="w100">
<span>
{{ currentInfo.remarks || "暂无备注信息" }}
</span>
</el-form-item>
</el-form>
</div>
<org-add
ref="orgAdd"
:parentId="currentInfo.id"
:treeData="data"
@success="getOrgTree()"
/>
<org-edit
ref="orgEdit"
:treeData="data"
:currentInfo="currentInfo"
@success="handleSuccessEdit()"
/>
</div>
</div>
</template>
<script>
import { orgAdd, orgEdit } from "./orgDialog";
export default {
data() {
return {
name: "",
data: [],
defaultProps: {
children: "children",
label: "name",
},
currentId: "",
currentInfo: {},
};
},
components: { orgAdd, orgEdit },
mounted() {
this.getOrgTree();
},
methods: {
handleNodeClick(data) {
this.currentId = data.id;
this.getInfoById();
},
// 获取机构数详情
getInfoById() {
this.$https(
{
method: "get",
url: "organ/getById",
authType: this.backToken,
},
{ id: this.currentId }
)
.then((res) => {
if (res.status == 200) {
if (res.data.resultCode == 200) {
if (res.data.data) {
this.currentInfo = res.data.data;
this.currentInfo.childrenName = this.currentInfo.children
.map((v) => {
return v.name;
})
.join(" 、");
} else {
this.currentInfo = {};
}
} else {
this.currentInfo = {};
}
} else {
this.currentInfo = {};
}
})
.catch((err) => {
console.log(res);
});
},
// 获取机构树
getOrgTree() {
this.$https(
{
method: "get",
url: "organ/getTree",
authType: this.backToken,
},
{ name: this.name }
)
.then((res) => {
if (res.status == 200) {
if (res.data.resultCode == 200) {
this.data = res.data.data;
this.currentId = this.data[0] ? this.data[0].id : "";
this.getInfoById();
} else {
this.data = [];
}
} else {
this.data = [];
}
})
.catch((err) => {
console.log(res);
});
},
// 新增
handleAdd() {
this.$refs.orgAdd.dialogVisible = true;
},
//导入
handleImport() {},
handleEdit() {
this.$refs.orgEdit.dialogVisible = true;
},
// 删除
handleDel() {
let _this = this;
this.$confirm("此操作将永久删除, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
_this.delAction();
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除",
});
});
},
delAction() {
this.$https({
method: "delete",
url: `organ/delete?id=${this.currentId}`,
authType: this.backToken,
})
.then((res) => {
if (res.status == 200) {
if (res.data.resultCode == 200) {
this.$message({
type: "success",
message: res.data.message,
});
this.getOrgTree();
} else {
this.$message.error(res.data.message);
}
} else {
this.$message.error(res.data);
}
})
.catch((err) => {
console.log(err);
});
},
// 编辑成功
handleSuccessEdit() {
this.getOrgTree();
this.getInfoById();
},
beforeAvatarUpload(file) {
const isLt5M = file.size / 1024 / 1024 < 5;
if (!isLt5M) {
this.$message.error("上传文件大小不能超过 5MB!");
}
return isLt5M;
},
handleRequest(file) {
let formData = new FormData();
formData.append("file", file.file);
let _this = this;
_this
.$https(
{
method: "post",
url: "organ/import",
authType: this.backToken,
},
formData
)
.then((res) => {
let resData = res.data;
if (res.status == 200) {
if (resData.resultCode == 200) {
_this.getOrgTree();
} else {
_this.$message.error(resData.msg || resData.message);
}
} else {
_this.$message.error(resData.msg || resData.message);
}
})
.catch((err) => {
console.log(err);
_this.$message.error(err.msg || err.message);
});
},
},
};
</script>
<style lang="less" scoped>
.oran-wrapper {
display: flex;
.org-tree-container {
width: 420px;
padding-right: 20px;
height: 100%;
.org-tree-box {
height: 100%;
background: @party-white;
border: 1px solid @party-white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
border-radius: 8px;
overflow: hidden;
.org-tree-box-header {
height: 56px;
line-height: 56px;
background-color: @party-red;
text-align: center;
font-size: 16px;
color: @party-white;
}
/deep/ .tree-search {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 10px;
.el-input__icon {
width: 40px;
font-size: 20px;
color: @party-btn-color;
}
.icon-import {
margin-left: 10px;
}
}
.org-tree-box-content {
padding: 20px;
height: calc(100% - 56px);
.tree-content {
height: calc(100% - 60px);
overflow-y: auto;
}
}
}
}
.org-detail {
width: calc(100% - 420px);
height: 100%;
background: @party-white;
border: 1px solid @party-white;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.1);
border-radius: 8px;
overflow: hidden;
.org-detail-panel-box {
height: 64px;
border-bottom: 1px solid @party-border-color;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 24px;
.title {
font-size: 20px;
font-weight: bold;
color: @font-color;
}
.icon-del {
margin-left: 30px;
}
}
.org-detail-panel-box-content {
height: calc(100% - 64px);
padding: 20px;
overflow-y: scroll;
.page-tip {
width: 648px;
height: 72px;
background: @party-bg-gray;
border-radius: 8px;
color: @font-color;
display: flex;
padding: 16px 20px;
margin: 0 auto 40px;
.page-tip-title {
width: 100px;
font-weight: bold;
}
}
.el-form {
width: 648px;
margin: 0 auto;
.w50 {
width: calc(50% - 15px);
}
.w100 {
width: 100%;
}
.el-form-item__content {
span {
color: @font-color;
font-weight: bold;
}
}
}
}
}
}
</style>