e355dd49
梁灏
add Select Component
|
1
2
3
|
<template>
<div :class="classes" v-clickoutside="handleClose">
<div
|
d6342fe1
jingsam
fixed ie bug
|
4
|
:class="[prefixCls + '-selection']"
|
4aec6a66
梁灏
support Select
|
5
|
ref="reference"
|
e355dd49
梁灏
add Select Component
|
6
|
@click="toggleMenu">
|
4aec6a66
梁灏
support Select
|
7
|
<div class="ivu-tag" v-for="(item, index) in selectedMultiple">
|
e355dd49
梁灏
add Select Component
|
8
|
<span class="ivu-tag-text">{{ item.label }}</span>
|
4aec6a66
梁灏
support Select
|
9
|
<Icon type="ios-close-empty" @click.native.stop="removeTag(index)"></Icon>
|
e355dd49
梁灏
add Select Component
|
10
|
</div>
|
e5337c81
梁灏
fixed some compon...
|
11
|
<span :class="[prefixCls + '-placeholder']" v-show="showPlaceholder && !filterable">{{ localePlaceholder }}</span>
|
d6342fe1
jingsam
fixed ie bug
|
12
|
<span :class="[prefixCls + '-selected-value']" v-show="!showPlaceholder && !multiple && !filterable">{{ selectedSingle }}</span>
|
e355dd49
梁灏
add Select Component
|
13
14
|
<input
type="text"
|
e355dd49
梁灏
add Select Component
|
15
16
|
v-if="filterable"
v-model="query"
|
d6342fe1
jingsam
fixed ie bug
|
17
|
:class="[prefixCls + '-input']"
|
e5337c81
梁灏
fixed some compon...
|
18
|
:placeholder="showPlaceholder ? localePlaceholder : ''"
|
e4ebd304
梁灏
update Select com...
|
19
|
:style="inputStyle"
|
e4ce9917
梁灏
update Select com...
|
20
21
22
|
@blur="handleBlur"
@keydown="resetInputState"
@keydown.delete="handleInputDelete"
|
4aec6a66
梁灏
support Select
|
23
24
|
ref="input">
<Icon type="ios-close" :class="[prefixCls + '-arrow']" v-show="showCloseIcon" @click.native.stop="clearSingleSelect"></Icon>
|
01b54e30
梁灏
Select support re...
|
25
|
<Icon type="arrow-down-b" :class="[prefixCls + '-arrow']" v-if="!remote"></Icon>
|
e355dd49
梁灏
add Select Component
|
26
|
</div>
|
f89dd9c2
梁灏
Paeg、Select add p...
|
27
|
<transition :name="transitionName">
|
ec98f3c3
梁灏
update Select
|
28
|
<Drop v-show="dropVisible" :placement="placement" ref="dropdown">
|
01b54e30
梁灏
Select support re...
|
29
|
<ul v-show="(notFound && !remote) || (remote && !loading && !options.length)" :class="[prefixCls + '-not-found']"><li>{{ localeNotFoundText }}</li></ul>
|
0b916a32
梁灏
update Select
|
30
|
<ul v-show="(!notFound && !remote) || (remote && !loading && !notFound)" :class="[prefixCls + '-dropdown-list']"><slot></slot></ul>
|
01b54e30
梁灏
Select support re...
|
31
|
<ul v-show="loading" :class="[prefixCls + '-loading']">{{ localeLoadingText }}</ul>
|
4aec6a66
梁灏
support Select
|
32
33
|
</Drop>
</transition>
|
e355dd49
梁灏
add Select Component
|
34
35
36
37
|
</div>
</template>
<script>
import Icon from '../icon';
|
4aec6a66
梁灏
support Select
|
38
|
import Drop from './dropdown.vue';
|
e355dd49
梁灏
add Select Component
|
39
|
import clickoutside from '../../directives/clickoutside';
|
ed91d9b0
梁灏
update Select
|
40
|
import { oneOf, findComponentDownward } from '../../utils/assist';
|
4aec6a66
梁灏
support Select
|
41
|
import Emitter from '../../mixins/emitter';
|
e5337c81
梁灏
fixed some compon...
|
42
|
import Locale from '../../mixins/locale';
|
e355dd49
梁灏
add Select Component
|
43
44
45
46
|
const prefixCls = 'ivu-select';
export default {
|
8f5b1686
梁灏
fixed #196
|
47
|
name: 'iSelect',
|
e5337c81
梁灏
fixed some compon...
|
48
|
mixins: [ Emitter, Locale ],
|
4aec6a66
梁灏
support Select
|
49
|
components: { Icon, Drop },
|
e355dd49
梁灏
add Select Component
|
50
51
|
directives: { clickoutside },
props: {
|
4aec6a66
梁灏
support Select
|
52
|
value: {
|
e355dd49
梁灏
add Select Component
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
type: [String, Number, Array],
default: ''
},
multiple: {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
placeholder: {
|
e5337c81
梁灏
fixed some compon...
|
69
|
type: String
|
e355dd49
梁灏
add Select Component
|
70
71
72
73
74
75
76
77
|
},
filterable: {
type: Boolean,
default: false
},
filterMethod: {
type: Function
},
|
01b54e30
梁灏
Select support re...
|
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
remote: {
type: Boolean,
default: false
},
remoteMethod: {
type: Function
},
loading: {
type: Boolean,
default: false
},
loadingText: {
type: String
},
|
e355dd49
梁灏
add Select Component
|
92
93
|
size: {
validator (value) {
|
6932b4d7
梁灏
update Page compo...
|
94
|
return oneOf(value, ['small', 'large', 'default']);
|
e355dd49
梁灏
add Select Component
|
95
96
97
98
99
|
}
},
labelInValue: {
type: Boolean,
default: false
|
294e2412
梁灏
update Select com...
|
100
101
|
},
notFoundText: {
|
e5337c81
梁灏
fixed some compon...
|
102
|
type: String
|
f89dd9c2
梁灏
Paeg、Select add p...
|
103
104
105
106
107
108
|
},
placement: {
validator (value) {
return oneOf(value, ['top', 'bottom']);
},
default: 'bottom'
|
e355dd49
梁灏
add Select Component
|
109
110
111
112
113
114
115
116
117
118
119
120
|
}
},
data () {
return {
prefixCls: prefixCls,
visible: false,
options: [],
optionInstances: [],
selectedSingle: '', // label
selectedMultiple: [],
focusIndex: 0,
query: '',
|
01b54e30
梁灏
Select support re...
|
121
|
selectToChangeQuery: false, // when select an option, set this first and set query, because query is watching, it will emit event
|
e4ce9917
梁灏
update Select com...
|
122
|
inputLength: 20,
|
3e855e34
梁灏
fixed #46
|
123
|
notFound: false,
|
4aec6a66
梁灏
support Select
|
124
125
|
slotChangeDuration: false, // if slot change duration and in multiple, set true and after slot change, set false
model: this.value
|
b0893113
jingsam
add eslint
|
126
|
};
|
e355dd49
梁灏
add Select Component
|
127
128
129
130
|
},
computed: {
classes () {
return [
|
4b7138b9
梁灏
fixed some bugs
|
131
|
`${prefixCls}`,
|
e355dd49
梁灏
add Select Component
|
132
|
{
|
4b7138b9
梁灏
fixed some bugs
|
133
134
135
136
137
138
|
[`${prefixCls}-visible`]: this.visible,
[`${prefixCls}-disabled`]: this.disabled,
[`${prefixCls}-multiple`]: this.multiple,
[`${prefixCls}-single`]: !this.multiple,
[`${prefixCls}-show-clear`]: this.showCloseIcon,
[`${prefixCls}-${this.size}`]: !!this.size
|
e355dd49
梁灏
add Select Component
|
139
|
}
|
b0893113
jingsam
add eslint
|
140
|
];
|
e355dd49
梁灏
add Select Component
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
},
showPlaceholder () {
let status = false;
if ((typeof this.model) === 'string') {
if (this.model === '') {
status = true;
}
} else if (Array.isArray(this.model)) {
if (!this.model.length) {
status = true;
}
}
return status;
},
showCloseIcon () {
return !this.multiple && this.clearable && !this.showPlaceholder;
},
inputStyle () {
let style = {};
if (this.multiple) {
|
e4ce9917
梁灏
update Select com...
|
164
165
166
|
if (this.showPlaceholder) {
style.width = '100%';
} else {
|
4b7138b9
梁灏
fixed some bugs
|
167
|
style.width = `${this.inputLength}px`;
|
e4ce9917
梁灏
update Select com...
|
168
|
}
|
e355dd49
梁灏
add Select Component
|
169
170
171
|
}
return style;
|
e5337c81
梁灏
fixed some compon...
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
},
localePlaceholder () {
if (this.placeholder === undefined) {
return this.t('i.select.placeholder');
} else {
return this.placeholder;
}
},
localeNotFoundText () {
if (this.notFoundText === undefined) {
return this.t('i.select.noMatch');
} else {
return this.notFoundText;
}
|
f89dd9c2
梁灏
Paeg、Select add p...
|
186
|
},
|
01b54e30
梁灏
Select support re...
|
187
188
189
190
191
192
193
|
localeLoadingText () {
if (this.loadingText === undefined) {
return this.t('i.select.loading');
} else {
return this.loadingText;
}
},
|
f89dd9c2
梁灏
Paeg、Select add p...
|
194
195
|
transitionName () {
return this.placement === 'bottom' ? 'slide-up' : 'slide-down';
|
ec98f3c3
梁灏
update Select
|
196
197
198
199
200
|
},
dropVisible () {
let status = true;
if (!this.loading && this.remote && this.query === '' && !this.options.length) status = false;
return this.visible && status;
|
e355dd49
梁灏
add Select Component
|
201
202
203
204
205
206
207
|
}
},
methods: {
toggleMenu () {
if (this.disabled) {
return false;
}
|
e355dd49
梁灏
add Select Component
|
208
209
210
211
212
|
this.visible = !this.visible;
},
hideMenu () {
this.visible = false;
this.focusIndex = 0;
|
4aec6a66
梁灏
support Select
|
213
|
this.broadcast('iOption', 'on-select-close');
|
e355dd49
梁灏
add Select Component
|
214
215
216
|
},
// find option component
findChild (cb) {
|
01b54e30
梁灏
Select support re...
|
217
|
const _this = this;
|
e355dd49
梁灏
add Select Component
|
218
219
220
221
222
223
|
const find = function (child) {
const name = child.$options.componentName;
if (name) {
cb(child);
} else if (child.$children.length) {
|
01b54e30
梁灏
Select support re...
|
224
225
226
227
|
_this.$nextTick(() => {
child.$children.forEach((innerChild) => {
find(innerChild, cb);
});
|
ec98f3c3
梁灏
update Select
|
228
|
});
|
e355dd49
梁灏
add Select Component
|
229
230
231
232
233
234
|
}
};
if (this.optionInstances.length) {
this.optionInstances.forEach((child) => {
find(child);
|
b0893113
jingsam
add eslint
|
235
|
});
|
e355dd49
梁灏
add Select Component
|
236
237
238
239
240
241
|
} else {
this.$children.forEach((child) => {
find(child);
});
}
},
|
3e855e34
梁灏
fixed #46
|
242
|
updateOptions (init, slot = false) {
|
e355dd49
梁灏
add Select Component
|
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
let options = [];
let index = 1;
this.findChild((child) => {
options.push({
value: child.value,
label: (child.label === undefined) ? child.$el.innerHTML : child.label
});
child.index = index++;
if (init) {
this.optionInstances.push(child);
}
});
this.options = options;
if (init) {
|
01b54e30
梁灏
Select support re...
|
261
262
263
264
|
if (!this.remote) {
this.updateSingleSelected(true, slot);
this.updateMultipleSelected(true, slot);
}
|
e355dd49
梁灏
add Select Component
|
265
266
|
}
},
|
3e855e34
梁灏
fixed #46
|
267
|
updateSingleSelected (init = false, slot = false) {
|
e355dd49
梁灏
add Select Component
|
268
269
270
|
const type = typeof this.model;
if (type === 'string' || type === 'number') {
|
3e855e34
梁灏
fixed #46
|
271
272
|
let findModel = false;
|
e355dd49
梁灏
add Select Component
|
273
274
275
|
for (let i = 0; i < this.options.length; i++) {
if (this.model === this.options[i].value) {
this.selectedSingle = this.options[i].label;
|
3e855e34
梁灏
fixed #46
|
276
|
findModel = true;
|
e355dd49
梁灏
add Select Component
|
277
278
279
|
break;
}
}
|
3e855e34
梁灏
fixed #46
|
280
281
282
283
284
|
if (slot && !findModel) {
this.model = '';
this.query = '';
}
|
e355dd49
梁灏
add Select Component
|
285
286
287
288
289
290
291
292
293
294
|
}
this.toggleSingleSelected(this.model, init);
},
clearSingleSelect () {
if (this.showCloseIcon) {
this.findChild((child) => {
child.selected = false;
});
this.model = '';
|
e4ebd304
梁灏
update Select com...
|
295
296
297
298
|
if (this.filterable) {
this.query = '';
}
|
e355dd49
梁灏
add Select Component
|
299
300
|
}
},
|
3e855e34
梁灏
fixed #46
|
301
|
updateMultipleSelected (init = false, slot = false) {
|
e355dd49
梁灏
add Select Component
|
302
|
if (this.multiple && Array.isArray(this.model)) {
|
d87ce40a
梁灏
update Select
|
303
|
let selected = this.remote ? this.selectedMultiple : [];
|
e355dd49
梁灏
add Select Component
|
304
305
306
307
308
309
310
311
312
313
314
|
for (let i = 0; i < this.model.length; i++) {
const model = this.model[i];
for (let j = 0; j < this.options.length; j++) {
const option = this.options[j];
if (model === option.value) {
selected.push({
value: option.value,
label: option.label
|
b0893113
jingsam
add eslint
|
315
|
});
|
e355dd49
梁灏
add Select Component
|
316
317
318
319
|
}
}
}
|
d87ce40a
梁灏
update Select
|
320
321
322
323
324
325
326
327
328
329
|
const selectedArray = [];
const selectedObject = {};
selected.forEach(item => {
if (!selectedObject[item.value]) {
selectedArray.push(item);
selectedObject[item.value] = 1;
}
});
this.selectedMultiple = this.remote ? selectedArray : selected;
|
e355dd49
梁灏
add Select Component
|
330
|
|
3e855e34
梁灏
fixed #46
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
if (slot) {
let selectedModel = [];
for (let i = 0; i < selected.length; i++) {
selectedModel.push(selected[i].value);
}
// if slot change and remove a selected option, emit user
if (this.model.length === selectedModel.length) {
this.slotChangeDuration = true;
}
this.model = selectedModel;
}
}
|
e355dd49
梁灏
add Select Component
|
346
347
348
349
350
351
|
this.toggleMultipleSelected(this.model, init);
},
removeTag (index) {
if (this.disabled) {
return false;
}
|
d87ce40a
梁灏
update Select
|
352
353
354
355
356
357
|
if (this.remote) {
const tag = this.model[index];
this.selectedMultiple = this.selectedMultiple.filter(item => item.value !== tag);
}
|
e355dd49
梁灏
add Select Component
|
358
|
this.model.splice(index, 1);
|
e4ce9917
梁灏
update Select com...
|
359
360
|
if (this.filterable && this.visible) {
|
4aec6a66
梁灏
support Select
|
361
|
this.$refs.input.focus();
|
e4ce9917
梁灏
update Select com...
|
362
363
|
}
|
4aec6a66
梁灏
support Select
|
364
|
this.broadcast('Drop', 'on-update-popper');
|
e355dd49
梁灏
add Select Component
|
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
},
// to select option for single
toggleSingleSelected (value, init = false) {
if (!this.multiple) {
let label = '';
this.findChild((child) => {
if (child.value === value) {
child.selected = true;
label = (child.label === undefined) ? child.$el.innerHTML : child.label;
} else {
child.selected = false;
}
});
this.hideMenu();
if (!init) {
if (this.labelInValue) {
this.$emit('on-change', {
value: value,
label: label
});
|
cd78c9c4
梁灏
some comps suppor...
|
388
389
390
391
|
this.dispatch('FormItem', 'on-form-change', {
value: value,
label: label
});
|
e355dd49
梁灏
add Select Component
|
392
393
|
} else {
this.$emit('on-change', value);
|
cd78c9c4
梁灏
some comps suppor...
|
394
|
this.dispatch('FormItem', 'on-form-change', value);
|
e355dd49
梁灏
add Select Component
|
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
|
}
}
}
},
// to select option for multiple
toggleMultipleSelected (value, init = false) {
if (this.multiple) {
let hybridValue = [];
for (let i = 0; i < value.length; i++) {
hybridValue.push({
value: value[i]
});
}
this.findChild((child) => {
const index = value.indexOf(child.value);
if (index >= 0) {
child.selected = true;
hybridValue[index].label = (child.label === undefined) ? child.$el.innerHTML : child.label;
} else {
child.selected = false;
}
});
if (!init) {
if (this.labelInValue) {
this.$emit('on-change', hybridValue);
|
cd78c9c4
梁灏
some comps suppor...
|
423
424
|
this.dispatch('FormItem', 'on-form-change', hybridValue);
} else {
|
e355dd49
梁灏
add Select Component
|
425
|
this.$emit('on-change', value);
|
cd78c9c4
梁灏
some comps suppor...
|
426
|
this.dispatch('FormItem', 'on-form-change', value);
|
e355dd49
梁灏
add Select Component
|
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
|
}
}
}
},
handleClose () {
this.hideMenu();
},
handleKeydown (e) {
if (this.visible) {
const keyCode = e.keyCode;
// Esc slide-up
if (keyCode === 27) {
e.preventDefault();
this.hideMenu();
}
// next
if (keyCode === 40) {
e.preventDefault();
this.navigateOptions('next');
}
// prev
if (keyCode === 38) {
e.preventDefault();
this.navigateOptions('prev');
}
// enter
if (keyCode === 13) {
e.preventDefault();
this.findChild((child) => {
if (child.isFocus) {
child.select();
}
});
}
}
},
navigateOptions (direction) {
if (direction === 'next') {
const next = this.focusIndex + 1;
this.focusIndex = (this.focusIndex === this.options.length) ? 1 : next;
} else if (direction === 'prev') {
const prev = this.focusIndex - 1;
this.focusIndex = (this.focusIndex <= 1) ? this.options.length : prev;
}
let child_status = {
|
e4ebd304
梁灏
update Select com...
|
474
475
|
disabled: false,
hidden: false
|
e355dd49
梁灏
add Select Component
|
476
477
|
};
|
e4ebd304
梁灏
update Select com...
|
478
479
|
let find_deep = false; // can next find allowed
|
e355dd49
梁灏
add Select Component
|
480
481
482
|
this.findChild((child) => {
if (child.index === this.focusIndex) {
child_status.disabled = child.disabled;
|
e4ebd304
梁灏
update Select com...
|
483
|
child_status.hidden = child.hidden;
|
e355dd49
梁灏
add Select Component
|
484
|
|
e4ebd304
梁灏
update Select com...
|
485
|
if (!child.disabled && !child.hidden) {
|
e355dd49
梁灏
add Select Component
|
486
487
488
489
490
|
child.isFocus = true;
}
} else {
child.isFocus = false;
}
|
e4ebd304
梁灏
update Select com...
|
491
492
493
494
|
if (!child.hidden && !child.disabled) {
find_deep = true;
}
|
e355dd49
梁灏
add Select Component
|
495
496
497
498
|
});
this.resetScrollTop();
|
e4ebd304
梁灏
update Select com...
|
499
|
if ((child_status.disabled || child_status.hidden) && find_deep) {
|
e355dd49
梁灏
add Select Component
|
500
501
502
503
504
505
506
507
508
509
510
511
512
513
|
this.navigateOptions(direction);
}
},
resetScrollTop () {
const index = this.focusIndex - 1;
let bottomOverflowDistance = this.optionInstances[index].$el.getBoundingClientRect().bottom - this.$refs.dropdown.$el.getBoundingClientRect().bottom;
let topOverflowDistance = this.optionInstances[index].$el.getBoundingClientRect().top - this.$refs.dropdown.$el.getBoundingClientRect().top;
if (bottomOverflowDistance > 0) {
this.$refs.dropdown.$el.scrollTop += bottomOverflowDistance;
}
if (topOverflowDistance < 0) {
this.$refs.dropdown.$el.scrollTop += topOverflowDistance;
}
|
e4ebd304
梁灏
update Select com...
|
514
515
516
517
518
519
|
},
handleBlur () {
setTimeout(() => {
const model = this.model;
if (this.multiple) {
|
eda30489
huangliangxiang
可搜索下拉菜单 输入无匹配时,移出...
|
520
|
this.query = '';
|
e4ebd304
梁灏
update Select com...
|
521
522
523
524
|
} else {
if (model !== '') {
this.findChild((child) => {
if (child.value === model) {
|
1363abdc
Rijn
fixed #178
|
525
|
this.query = child.label === undefined ? child.searchLabel : child.label;
|
e4ebd304
梁灏
update Select com...
|
526
527
|
}
});
|
0b916a32
梁灏
update Select
|
528
529
530
531
|
// 如果删除了搜索词,下拉列表也情况了,所以强制调用一次remoteMethod
if (this.remote) {
this.$nextTick(() => {
this.query = model;
|
6f8608bb
梁灏
update Select
|
532
|
});
|
0b916a32
梁灏
update Select
|
533
|
}
|
eda30489
huangliangxiang
可搜索下拉菜单 输入无匹配时,移出...
|
534
535
|
} else {
this.query = '';
|
e4ebd304
梁灏
update Select com...
|
536
537
538
|
}
}
}, 300);
|
e4ce9917
梁灏
update Select com...
|
539
540
|
},
resetInputState () {
|
4aec6a66
梁灏
support Select
|
541
|
this.inputLength = this.$refs.input.value.length * 12 + 20;
|
e4ce9917
梁灏
update Select com...
|
542
543
544
545
546
|
},
handleInputDelete () {
if (this.multiple && this.model.length && this.query === '') {
this.removeTag(this.model.length - 1);
}
|
3e855e34
梁灏
fixed #46
|
547
548
549
550
551
|
},
// use when slot changed
slotChange () {
this.options = [];
this.optionInstances = [];
|
2f0b086d
梁灏
fixed #116
|
552
553
554
555
|
},
setQuery (query) {
if (!this.filterable) return;
this.query = query;
|
9c3a3e7d
YikaJ
更新 Select 组件
|
556
557
|
},
modelToQuery() {
|
83b73885
梁灏
fixed #718
|
558
|
if (!this.multiple && this.filterable && this.model !== undefined) {
|
7db4e70d
YikaJ
Update select.vue
|
559
560
561
562
563
564
565
566
567
568
569
570
|
this.findChild((child) => {
if (this.model === child.value) {
if (child.label) {
this.query = child.label;
} else if (child.searchLabel) {
this.query = child.searchLabel;
} else {
this.query = child.value;
}
}
});
}
|
15b72d31
梁灏
fixed #566
|
571
572
573
574
575
576
577
578
|
},
broadcastQuery (val) {
if (findComponentDownward(this, 'OptionGroup')) {
this.broadcast('OptionGroup', 'on-query-change', val);
this.broadcast('iOption', 'on-query-change', val);
} else {
this.broadcast('iOption', 'on-query-change', val);
}
|
e355dd49
梁灏
add Select Component
|
579
580
|
}
},
|
4aec6a66
梁灏
support Select
|
581
|
mounted () {
|
7db4e70d
YikaJ
Update select.vue
|
582
|
this.modelToQuery();
|
83b73885
梁灏
fixed #718
|
583
584
585
|
this.$nextTick(() => {
this.broadcastQuery('');
});
|
e2006187
梁灏
fixed #159
|
586
|
|
e355dd49
梁灏
add Select Component
|
587
588
|
this.updateOptions(true);
document.addEventListener('keydown', this.handleKeydown);
|
3e855e34
梁灏
fixed #46
|
589
|
|
ed91d9b0
梁灏
update Select
|
590
|
this.$on('append', () => {
|
01b54e30
梁灏
Select support re...
|
591
592
593
594
595
596
|
if (!this.remote) {
this.modelToQuery();
this.$nextTick(() => {
this.broadcastQuery('');
});
}
|
ed91d9b0
梁灏
update Select
|
597
598
599
600
|
this.slotChange();
this.updateOptions(true, true);
});
this.$on('remove', () => {
|
01b54e30
梁灏
Select support re...
|
601
602
603
604
605
606
|
if (!this.remote) {
this.modelToQuery();
this.$nextTick(() => {
this.broadcastQuery('');
});
}
|
ed91d9b0
梁灏
update Select
|
607
608
609
|
this.slotChange();
this.updateOptions(true, true);
});
|
4aec6a66
梁灏
support Select
|
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
|
this.$on('on-select-selected', (value) => {
if (this.model === value) {
this.hideMenu();
} else {
if (this.multiple) {
const index = this.model.indexOf(value);
if (index >= 0) {
this.removeTag(index);
} else {
this.model.push(value);
this.broadcast('Drop', 'on-update-popper');
}
if (this.filterable) {
|
01b54e30
梁灏
Select support re...
|
625
|
this.selectToChangeQuery = true;
|
4aec6a66
梁灏
support Select
|
626
627
628
629
630
631
632
633
634
|
this.query = '';
this.$refs.input.focus();
}
} else {
this.model = value;
if (this.filterable) {
this.findChild((child) => {
if (child.value === value) {
|
01b54e30
梁灏
Select support re...
|
635
|
this.selectToChangeQuery = true;
|
4aec6a66
梁灏
support Select
|
636
637
638
639
640
641
642
|
this.query = child.label === undefined ? child.searchLabel : child.label;
}
});
}
}
}
});
|
e355dd49
梁灏
add Select Component
|
643
644
645
|
},
beforeDestroy () {
document.removeEventListener('keydown', this.handleKeydown);
|
e355dd49
梁灏
add Select Component
|
646
647
|
},
watch: {
|
4aec6a66
梁灏
support Select
|
648
649
|
value (val) {
this.model = val;
|
f7674b5b
梁灏
#518
|
650
|
if (val === '') this.query = '';
|
4aec6a66
梁灏
support Select
|
651
|
},
|
e355dd49
梁灏
add Select Component
|
652
|
model () {
|
4aec6a66
梁灏
support Select
|
653
|
this.$emit('input', this.model);
|
7db4e70d
YikaJ
Update select.vue
|
654
|
this.modelToQuery();
|
e355dd49
梁灏
add Select Component
|
655
|
if (this.multiple) {
|
3e855e34
梁灏
fixed #46
|
656
657
658
659
660
|
if (this.slotChangeDuration) {
this.slotChangeDuration = false;
} else {
this.updateMultipleSelected();
}
|
e355dd49
梁灏
add Select Component
|
661
662
663
664
665
666
|
} else {
this.updateSingleSelected();
}
},
visible (val) {
if (val) {
|
15b72d31
梁灏
fixed #566
|
667
668
669
670
671
672
|
if (this.filterable) {
if (this.multiple) {
this.$refs.input.focus();
} else {
this.$refs.input.select();
}
|
e4ce9917
梁灏
update Select com...
|
673
|
}
|
4aec6a66
梁灏
support Select
|
674
|
this.broadcast('Drop', 'on-update-popper');
|
e355dd49
梁灏
add Select Component
|
675
|
} else {
|
b7cf983e
梁灏
update Select com...
|
676
|
if (this.filterable) {
|
4aec6a66
梁灏
support Select
|
677
|
this.$refs.input.blur();
|
15b72d31
梁灏
fixed #566
|
678
679
680
681
|
// #566 reset options visible
setTimeout(() => {
this.broadcastQuery('');
}, 300);
|
b7cf983e
梁灏
update Select com...
|
682
|
}
|
4aec6a66
梁灏
support Select
|
683
|
this.broadcast('Drop', 'on-destroy-popper');
|
e355dd49
梁灏
add Select Component
|
684
|
}
|
e4ebd304
梁灏
update Select com...
|
685
686
|
},
query (val) {
|
01b54e30
梁灏
Select support re...
|
687
688
689
690
691
692
693
694
695
696
|
if (this.remote && this.remoteMethod) {
if (!this.selectToChangeQuery) {
this.$emit('on-query-change', val);
this.remoteMethod(val);
}
} else {
if (!this.selectToChangeQuery) {
this.$emit('on-query-change', val);
}
this.broadcastQuery(val);
|
d8bb1771
windywany
let select compon...
|
697
|
|
01b54e30
梁灏
Select support re...
|
698
|
let is_hidden = true;
|
e4ce9917
梁灏
update Select com...
|
699
|
|
01b54e30
梁灏
Select support re...
|
700
701
702
703
704
705
706
|
this.$nextTick(() => {
this.findChild((child) => {
if (!child.hidden) {
is_hidden = false;
}
});
this.notFound = is_hidden;
|
e4ce9917
梁灏
update Select com...
|
707
|
});
|
01b54e30
梁灏
Select support re...
|
708
709
|
}
this.selectToChangeQuery = false;
|
4aec6a66
梁灏
support Select
|
710
|
this.broadcast('Drop', 'on-update-popper');
|
e355dd49
梁灏
add Select Component
|
711
712
|
}
}
|
b0893113
jingsam
add eslint
|
713
|
};
|
d6342fe1
jingsam
fixed ie bug
|
714
|
</script>
|