authorization.vue
3.48 KB
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
<template>
<div class="select_info_page">
<h2 class="title">注:按车辆所属组织层级直接授权数据,包括后续增加的车辆</h2>
<div class="device_box">
<div class="card_box">
<div class="head">请选择组织层级(支持多选)</div>
<div class="info_box">
<div class="search_box">
<el-input v-model="term" placeholder="请输入两位以上组织层级名称" suffix-icon="el-icon-search" @input="onSearch" @keyup.enter.native="onSearch"></el-input>
</div>
<div class="tree_box" v-loading="treeLoading">
<el-scrollbar class="el_scroll">
<el-tree ref="elTree" :key="id" :data="organizationList" default-expand-all :props="treeProps" :default-checked-keys="checkKeys" show-checkbox node-key="id" :filter-node-method="filterNode">
</el-tree>
</el-scrollbar>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { GET_ORIGINIZATION_LIST } from "@/services/orginizaManage";
import { deepClone, showToast, broadcast, received } from "@/utils/util";
export default {
name: "AuthorizationInfo",
props: {
id: {
type: [String, Number],
default: "",
},
},
data() {
return {
term: "",
organizationList: [],
treeLoading: false,
treeProps: {
label: "label",
children: "children",
isLeaf: "leaf",
["node-key"]: "id",
},
checkKeys: ["1837"],
};
},
created() {
this.getList();
},
mounted() {},
methods: {
// 获取组织树列表
getList() {
this.treeLoading = true;
GET_ORIGINIZATION_LIST().then((res) => {
this.treeLoading = false;
this.organizationList = res.data || [];
});
},
// 搜索树
onSearch() {
let term = this.term;
if (term && term.length < 2) {
return false;
}
this.$refs.elTree.filter(term);
},
// 筛选树
filterNode(value, data) {
return data.label.indexOf(value) !== -1;
},
// 保存数据
saveInfo() {
let _keys = this.$refs.elTree.getCheckedKeys();
console.log(_keys);
broadcast("cancel-loading");
},
},
};
</script>
<style lang="scss" scoped>
.select_info_page {
.title {
font-family: PingFangSC-Regular;
font-size: 14px;
color: #666666;
font-weight: 400;
}
.device_box {
display: flex;
justify-content: space-between;
.card_box {
flex: 1;
//width: 380px;
flex-shrink: 0;
box-sizing: border-box;
.head {
height: 54px;
line-height: 54px;
background: #f5f7fa;
padding: 0 16px;
font-family: PingFangSC-Regular;
font-size: 14px;
color: #333333;
font-weight: 400;
}
.info_box {
border: 1px solid #eee;
.search_box {
padding: 10px;
.input_select {
width: 100%;
::v-deep .el-input-group__prepend {
background: #fff !important;
//padding: 0 10px;
padding-left: 10px;
.el-select {
width: 90px;
box-sizing: border-box;
}
}
}
}
.tree_box {
border-top: 1px solid #eee;
.el_scroll {
padding: 10px 0;
height: 340px;
box-sizing: border-box;
overflow-y: auto;
}
}
}
}
}
}
</style>