hv_behavior.js
1.35 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
// components/reserve/search/how/hv.js
import util from '../../../../utils/util'
module.exports = Behavior({
properties: {
ckdata:{
type:Object,
val:null,
},
},
data: {
spi:-1
},
observers: {
'ckdata': function() {
this.checkedDefEvent()
}
},
methods: {
checked(e,hasCurrent=false){
let index=util.attr(e,'index')
let val=util.attr(e,'val')
let type=util.attr(e,'type')
let obj={
spi:index,
}
if(hasCurrent){
let current=index-2
if(type=='date'){
current=current>10?10:current
}else if(type=='pnum'){
current=current>26?26:current
}
obj.current=current>-1?current:0
}
this.setData(obj)
this.triggerEvent('event',{index,val,type})
},
checkedDefEvent(){
console.log('this.type',this.type)
let type=this.type
let ckdata = {}
if (!this.data.ckdata) {//初始化值
if(type == 'dur') return;
let index, val
if (type == 'pnum') {
index = 3
val = this.data.items[index]
} else if (type == 'date') {
index = 0
val = this.data.items[index]
}
ckdata = {index, val, type}
}else{
ckdata = this.data.ckdata
}
this.checked({currentTarget:{dataset:ckdata}},true)
},
}
})