-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpopup-picker.vue
120 lines (115 loc) · 3.64 KB
/
popup-picker.vue
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
119
120
<!--<template>-->
<!--<popup :show="localShow" height="auto" @on-hide="_onHide">-->
<!--<div class="vmc-popup-picker" v-stop.move>-->
<!--<div class="header">-->
<!--<div class="left" @click="_onCancel">{{cancel}}</div>-->
<!--<div class="title">{{title}}</div>-->
<!--<div class="right" @click="_onSubmit">{{confirm}}</div>-->
<!--</div>-->
<!--<picker @on-change="_onChange" v-props></picker>-->
<!--</div>-->
<!--</popup>-->
<!--</template>-->
<script type="text/jsx">
import Popup from '../popup';
import Picker from '../picker';
export default {
components: {
Popup,
Picker
},
props: {
show: Boolean,
title: {
type: String,
default: ''
},
confirm: {
type: String,
default: '确定'
},
cancel: {
type: String,
default: '取消'
},
list: {
type: Array,
default() {
return []
}
},
value: {
type: String,
default: null
},
valueType: {
type: String,
default: 'value'
},
valueSeparator: {
type: String,
default: ' '
}
},
data() {
return {
result: {},
selValue: '',
localShow: this.show
}
},
methods: {
_onCancel() {
this._hide();
this.$emit('on-cancel', this.value);
},
_onSubmit() {
this._hide();
this.$emit('input', this.selValue);
this.$emit('on-submit', this.selValue);
},
_onChange(result, value, target) {
this.result = result;
this.selValue = value;
this.$emit('on-change', result, value, target);
},
_onHide() {
this._hide();
},
_hide() {
this.localShow = false;
this.$emit('on-hide');
this.$emit('on-sync-show', false);
}
},
watch: {
show(show) {
if (this.localShow !== show) {
this.localShow = show;
}
}
},
render(h) {
var props = {};
var exclude = ['show', 'title', 'confirm', 'cancel'];
for (var key in this._props) {
if (!this._props.hasOwnProperty(key)) continue;
if (!~exclude.indexOf(key)) {
props[key] = this._props[key];
}
}
return (
<popup show={this.localShow} height="auto" on-on-hide={this._onHide}>
<div class="vmc-popup-picker" v-stop="{{ move: true }}">
<div class="header">
<div class="left" onClick={this._onCancel}>{this.cancel}</div>
<div class="title">{this.title}</div>
<div class="right" onClick={this._onSubmit}>{this.confirm}</div>
</div>
<picker on-on-change={this._onChange} {...{ props }}></picker>
</div>
</popup>
)
}
}
</script>