index.vue
3.43 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
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
<template>
<el-select
:value="value"
:disabled="disabled"
filterable
remote
clearable
reserve-keyword
placeholder="请输入关平台名称"
v-loadMore="nextList"
@select="onChange"
@blur="onInput"
@clear="clearHandle"
@focus="search"
:loading="loading && !this.options.length"
>
<!-- :remote-method="search" :loading="loading" -->
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</template>
<script>
import { getInfoList } from "@/api/baseData/info";
export default {
name: "SelsctLoad",
props: ['value', 'disabled'],
computed: {
noMore() {
return this.total == this.options.length;
},
},
data() {
return {
loading: false,
searchList: {
pageIndex: 1,
pageSize: 20,
sort: "desc",
sidx: "",
},
total: 0,
options: [],
};
},
mounted() {},
methods: {
selectFocus() {
this.loadList();
},
nextList() {
if (this.loading || this.noMore) return;
this.searchList.pageIndex += 1;
this.$nextTick(() => {
this.loadList();
})
},
search() {
this.options = [];
this.searchList = {
pageIndex: 1,
pageSize: 10,
sort: "desc",
sidx: "",
};
this.loadList();
},
loadList() {
this.loading = true;
getInfoList({ ...this.searchList, keyword: this.value }).then(({ data }) => {
let list = [];
data.list.length &&
data.list.forEach((item) => {
list.push({
label: item.SysytemInfo.SystemName,
value: item.SysytemInfo.Id,
});
});
this.options = [...this.options, ...list];
this.total = data.totalCount;
this.loading = false;
});
},
// 清除选中
clearHandle() {
this.value = "";
this.$emit("input", "");
this.$emit("change", "");
},
onChange(v) {
this.value = v;
this.$emit("input", this.options.map((item) => item.value == v).label);
this.$emit("change", v);
},
onInput(e) {
this.$emit("input", e.target.value);
this.$emit("change", e.target.value);
}
},
watch: {
value(val) {
this.search();
},
},
};
</script>
<style lang="scss" scoped>
.NCC-selectTree {
width: 100%;
}
.el-scrollbar .el-scrollbar__view .el-select-dropdown__item {
height: auto;
max-height: 274px;
padding: 0;
overflow: hidden;
overflow-y: auto;
}
.el-select-dropdown__item.selected {
font-weight: normal;
}
ul li::-webkit-scrollbar-track {
border-radius: 0;
background-color: #fff;
}
ul li >>> .el-tree .el-tree-node__content {
height: auto;
padding: 0 20px;
}
.el-tree-node__label {
font-weight: normal;
}
.el-tree.single >>> .is-current .el-tree-node__label {
color: #409eff;
font-weight: 700;
}
.el-tree.single >>> .is-current .el-tree-node__content .custom-tree-node {
color: #409eff;
font-weight: 700;
}
.el-tree.single >>> .is-current .el-tree-node__children .custom-tree-node {
color: #606266;
font-weight: normal;
}
.el-tree.single >>> .is-current .el-tree-node__children .el-tree-node__label {
color: #606266;
font-weight: normal;
}
.empty-text {
margin: 0;
text-align: center;
color: #999;
font-size: 14px;
background: #fff;
cursor: auto;
padding: 0;
line-height: 24px;
}
</style>