selectCpn.vue
2.67 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
<template>
<div class='select'>
<span v-show='selectName'>{{ selectName }}</span>
<select v-if='selectArr' class='sel' id='sel' v-model='selStr' :style='widthHeight' @change='selectBtn(selectType)'>
<option v-for='(item,index) in selectArr' :key='index' :value='item[valName]'>
{{ item[labelName] }}
</option>
</select>
</div>
</template>
<script>
export default {
name: 'SelectOptions',
props: {
valName: {
type: String,
default: 'value'
},
labelName: {
type: String,
default: 'label'
},
selectType: {
type: String,
default: ''
},
selectName: {
type: String,
default: ''
},
// showSelect: {
// type: Boolean,
// default: false
// },
selectArr: {
type: Array,
default: () => []
},
widthHeight: {
type: Object,
default: () => {
}
},
getQuery: {
type: String,
default: ''
}
},
data() {
return {
selStr: '',
}
},
watch: {
selectArr: {
handler(newval, oldval) {
this.selStr = this.selectArr[0][this.valName]
// if (newval == true && this.showSelect == true) {
// this.selStr = this.selectArr[0][this.valName]
// console.log(this.selStr)
// }
// if (newval == false && this.showSelect == true) {
// this.selStr = ''
// }
}
}
},
mounted() {
if (this.selectArr.length) {
this.selStr = this.selectArr[0][this.valName]
}
// this.$bus.$on('changeBussiness', data => {
// const { bussinessType } = data
// this.showFirstSelStaus = bussinessType == 'expandedGold' || bussinessType == 'crowdFunding'
// })
},
methods: {
selectBtn(type) {
switch (type) {
case 'business':
// eslint-disable-next-line no-case-declarations
let title
this.selectArr.forEach(item => {
if (item.value == this.selStr) {
title = item.label
}
})
this.$bus.$emit('changeBussiness', { bussinessTitle: title + '业务', bussinessType: this.selStr })
break
// case 'system':
// this.$bus.$emit('changeSystem', { systemType: this.selStr })
// break
case 'months':
this.$bus.$emit('changeMonths', { month: this.selStr })
break
case 'springbudAtion':
this.$bus.$emit('changeSpringbudAtion', { action: this.selStr })
break
}
}
}
}
</script>
<style scoped lang='scss'>
.select {
margin: 1vh;
.sel {
background: #2436b7;
border: none;
color: #ffffff;
border-radius: 5px;
}
}
</style>