|
|
<template>
|
|
|
<div class="selection-container">
|
|
|
<span class="selection-main" @click="openCloseDropdown()">
|
|
|
<span class="selection-main-text">{{showShopName}}</span>
|
|
|
<span class="selection-main-text {{disabled?'selection-disabled':''}}">{{showSelectedData}}</span>
|
|
|
<span class="selection-main-arrow"><b class="{{isOpen?'up':''}}"></b></span>
|
|
|
</span>
|
|
|
|
...
|
...
|
@@ -22,6 +22,7 @@ |
|
|
<script>
|
|
|
export default {
|
|
|
props: {
|
|
|
selectedData:{type: Object, default: {id:-1,text:"请选择"}},//默认选中选项
|
|
|
url: {type: String, default: ""},
|
|
|
options: {type: Array, default: []},
|
|
|
placeholder: {type: String, default: "请选择"},
|
...
|
...
|
@@ -30,16 +31,15 @@ |
|
|
data() {
|
|
|
return {
|
|
|
isOpen:false,
|
|
|
selectedShopId:'-1',
|
|
|
selectedShopName:'',
|
|
|
searchText:'',
|
|
|
dataList:[],
|
|
|
seachList:[]
|
|
|
}
|
|
|
},
|
|
|
computed:{
|
|
|
showShopName(){
|
|
|
return this.selectedShopName==''?this.placeholder:this.selectedShopName;
|
|
|
showSelectedData(){
|
|
|
console.log(this.selectedData);
|
|
|
return this.selectedData.id < 0 ? this.placeholder : this.selectedData.text;
|
|
|
}
|
|
|
},
|
|
|
ready() {
|
...
|
...
|
@@ -59,16 +59,17 @@ |
|
|
selectOption(data){
|
|
|
this.isOpen = false;
|
|
|
this.searchText = '';
|
|
|
this.selectedShopId = data.id;
|
|
|
this.selectedShopName = data.text;
|
|
|
this.selectedData = data;
|
|
|
this.$dispatch('completeSelect', data);
|
|
|
},
|
|
|
//开关下拉菜单
|
|
|
openCloseDropdown(){
|
|
|
if(this.isOpen){
|
|
|
this.isOpen = false;
|
|
|
}else{
|
|
|
this.isOpen = true;
|
|
|
if(!this.disabled){
|
|
|
if(!this.isOpen){
|
|
|
this.isOpen = true;
|
|
|
}else{
|
|
|
this.isOpen = false;
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
//下拉数据筛选
|
...
|
...
|
@@ -124,7 +125,7 @@ |
|
|
cursor: pointer;
|
|
|
display: block;
|
|
|
height: 39px;
|
|
|
line-height: 39px;
|
|
|
line-height: 37px;
|
|
|
}
|
|
|
.selection-main-text{
|
|
|
display: block;
|
...
|
...
|
@@ -134,6 +135,9 @@ |
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
|
}
|
|
|
.selection-disabled{
|
|
|
background-color: #CCCCCC;
|
|
|
}
|
|
|
.selection-main-arrow{
|
|
|
height: 36px;
|
|
|
position: absolute;
|
...
|
...
|
|