Repository navigation
Expand file tree
/
Copy pathselect.vue
More file actions
83 lines (77 loc) · 2.11 KB
/
Copy pathselect.vue
File metadata and controls
83 lines (77 loc) · 2.11 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
<template>
<div :class="$parent.block ? 'layui-input-block' : 'layui-input-inline'">
<div class="layui-unselect layui-form-select"
:class="{'layui-form-selected layui-form-selectup': isOpen}"
@click="handleClick">
<div class="layui-select-title">
<input type="text" :placeholder="placeholder" v-model="selectText" readonly=""
class="layui-input layui-unselect"
:class="{
'layui-disabled': disabled
}">
<i class="layui-edge"></i>
</div>
<dl class="layui-anim layui-anim-upbit" :class="{
'layui-select-group': group
}" style="">
<dd lay-value="" class="layui-select-tips">{{placeholder}}</dd>
<span v-for="g in datas">
<dt v-if="group">{{g.title}}</dt>
<dd v-for="item in g.data"
@click.stop="selectOption(item)"
:value="item[prop.value || 'value']"
:class="item[prop.value || 'value'] == value ? 'layui-this' : ''">{{item[prop.lable || 'lable']}}
</dd>
</span>
</dl>
</div>
</div>
</template>
<script>
export default {
name: 'LaySelect',
props: {
disabled: Boolean,
value: [String, Number],
data: Array,
prop: Object,
placeholder: String,
group: Boolean
},
data: function () {
return {
isOpen: false,
selected: false,
selectText: ''
}
},
methods: {
handleClick: function () {
if (!this.disabled) {
this.isOpen = !this.isOpen
} else {
this.isOpen = false
}
},
selectOption: function (item) {
if (!this.disabled) {
this.selectText = item[this.prop.lable]
this.$emit('input', item[this.prop.value])
this.$emit('change', this.value)
}
this.handleClick()
}
},
created: function () {
if (!this.group) {
this.datas = [{
data: this.data
}]
} else {
this.datas = this.data
}
}
}
</script>
<style>
</style>