Authored by dongjunjie

tj

... ... @@ -4,7 +4,7 @@ Vue.use(require('vue-resource'));
new Vue({
el: 'body',
components: {
app:require("./app.vue")
app:require("./info.vue")
}
});
... ...
... ... @@ -5,7 +5,7 @@
<div class="panel">
<div class="chooseShop">
<div class="shopSelect">
<com-selection :url="selectUrl" :placeholder="'请选择店铺'"></com-selection>
<com-selection :disabled="true" :selected-data="currentShop"></com-selection>
</div>
<div class="shopInfo">
<span>店铺ID:<b>{{showShopId}}</b></span>
... ... @@ -26,6 +26,14 @@
import selection from '../../../../components/selection/index';
export default{
components: {
comPageheader: pageheader,
comSelection: selection
},
data() {
return {
currentShop:{id:10,text:"淋淋店"}
}
},
}
</script>
... ...
<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;
... ...