room.js
2.54 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
import App from '../../../utils/api';
import util from '../../../utils/util';
let dur=['morning','noon','night','midnight']
Component({
properties:{
seller:Object,
date:{
type:String,
value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD')
},
section:String,
usecondition:{
type:String,
value:'custom'
},
seletroomlist:{
type:Array,
value:[]
}
},
data:{
roomlist:[],
},
observers: {
'date,section': function(newdate,newsection) {
console.log('room',newdate,newsection)
if(newdate && newsection){
this.getroomtype();
}
}
},
methods:{
getroomtype(){
let parmdata={
sellerid:this.data.seller.id,
day:util.timetouUnix(this.data.date+' 00:00:00'),
interval:dur.indexOf(this.data.section)+1
}
App.Seller.GetSellerTableClass(parmdata).then((json)=>{
console.log('roomlist',json)
if(json.ret==200){
if(json.data.length>0){
if(this.data.usecondition=="custom"){
json.data.forEach((v,i)=>{
v.selectnum=0;
})
}
}
this.setData({
roomlist:json.data
})
if(this.data.seletroomlist.length>0){
this.changestyle();
}
}
})
},
selectroom(e){
let _target=e.currentTarget.dataset;
console.log(typeof _target.selectnum,this.data.usecondition)
if(this.data.usecondition=='custom'){
let setkey='roomlist['+_target.index+'].selectnum';
this.setData({
[setkey]:_target.selectnum+1
})
let obj={
id:_target.id,
name:this.data.roomlist[_target.index].name
}
this.triggerEvent('selectroom',obj)
}else{
//////
console.log('置满')
let parmdata={
classid:_target.id,
day:util.timetouUnix(this.data.date+' 00:00:00'),
interval:dur.indexOf(this.data.section)+1
}
if(_target.fid){
parmdata.id=_target.fid;
}
App.Seller.SetTableClassFull(parmdata).then((json)=>{
console.log(json)
if(json.ret==200){
this.triggerEvent('changeroom',{id:_target.id,action:parmdata.id ? 'cancel' : 'confirm'})
this.getroomtype();
}
})
}
},
cancelroom(id){
let roomlist=this.data.roomlist;
roomlist.forEach((v,i)=>{
if(v.id==id){
let setkey='roomlist['+i+'].selectnum';
this.setData({
[setkey]:v.selectnum-1,
})
}
})
},
changestyle(){
let seletroomlist=this.data.seletroomlist;
let roomlist=this.data.roomlist;
seletroomlist.forEach((v,i)=>{
roomlist.forEach((r,n)=>{
if(v.id==r.id){
r.selectnum+=1;
}
})
})
this.setData({
roomlist:roomlist
})
},
}
})