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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import create from 'dd-store'
import { queryAvailableMeetingRoomByTime, modifySchedule } from './../../api/request'
import { throttle } from './../../utils/utils.js'
import { observer } from '/utils/observer.js'
create.Page({
data: {
$data: null,
place: '',
availableMeetingRoom: [],
scheduleItem: '',
repeatable: 0,
// 传递给组件selectPopup 的数据
conSelectPopupData: {
selectPopupId: '',
showSelectPopup: false,
selectType: 'common',
editSaveList: [{ text: '仅保存此会议', id: 'only' }, { text: '保存此次及以后会议', id: 'future' }]
},
// 传递给组件centerPopup 的数据
centerPopup: {
showCenterPopup: false,
centerPopupList: [
{ id: 0, text: '不发送通知' },
{ id: 1, text: '发送通知' },
{ id: -1, text: '取消编辑' }
],
centerPopupId: ''
},
// 传递给组件toast的所有数据
conToastData: {
showToast: false,
title: '保存成功'
},
},
onLoad(e) {
if (e.scheduleItem) {
const _that = this
observer.register({
notice(scheduleItem) {
_that.setData({
'scheduleItem.scheduleTemplateId': scheduleItem
})
console.log(scheduleItem);
}
})
this.setData({
repeatable: e.repeatable,
scheduleItem: JSON.parse(e.scheduleItem)
})
}
dd.setNavigationBar({
title: '会议地点'
})
let that = this
let data = {
startTime: this.$store.data.startTime.replace(/\//g, "-"),
endTime: this.$store.data.endTime.replace(/\//g, "-")
}
queryAvailableMeetingRoomByTime(data).then(res => {
that.setData({
availableMeetingRoom: res.data.data
})
})
},
selectPlace(event) {
this.$store.data.locationName = event.target.dataset.locationName
this.$store.data.roomId = ''
this.update()
if (!!this.data.scheduleItem) {
if (this.data.repeatable != 0) {
this.setData({
'conSelectPopupData.showSelectPopup': true
})
} else {
let data = {
location: {
longitude: -999,
latitude: -999,
locationName: this.$store.data.locationName
},
meetingRoomId: this.$store.data.roomId,
modifyModel: 'only',
modifyContent: 'modify_location'
}
this.modifySchedule(data, 0).then(res => {
this.editLocationS()
}).catch(err => {
this.editLocationE()
})
}
} else {
dd.navigateBack({
delta: 1
})
}
},
onSelectPopup(event) {
this.setData({
'conSelectPopupData.showSelectPopup': false,
'conSelectPopupData.selectPopupId': event.currentTarget.dataset.item.id,
'centerPopup.showCenterPopup': true
})
},
// 选择发不发通知
onSelectSend(event) {
this.setData({
'centerPopup.showCenterPopup': false
})
if (event.currentTarget.dataset.item.id > -1) {
let data = {
location: {
longitude: -999,
latitude: -999,
locationName: this.$store.data.locationName
},
meetingRoomId: this.$store.data.roomId,
modifyModel: this.data.conSelectPopupData.selectPopupId,
modifyContent: 'modify_location'
}
this.modifySchedule(data, event.currentTarget.dataset.item.id).then(res => {
this.editLocationS()
}).catch(err => {
this.editLocationE(true)
})
} else {
this.editLocationE(false)
}
},
// 修改地点成功
editLocationS() {
this.$store.data.originalData.location.locationName = this.$store.data.locationName
this.$store.data.originalData.meetingRoomId = this.$store.data.roomId
this.update()
dd.navigateBack({
delta: 1
})
},
// 修改地点失败
editLocationE(lock = true) {
this.$store.data.locationName = this.$store.data.originalData.location.locationName
this.$store.data.roomId = this.$store.data.originalData.meetingRoomId
this.update()
if (lock) {
this.setData({
'conToastData.showToast': true,
'conToastData.title': '网络异常'
})
}
},
// 保存编辑
modifySchedule(data, needNotice = 0) {
let obj = {
needNotice: needNotice,
scheduleId: this.data.scheduleItem.id,
templateId: this.data.scheduleItem.scheduleTemplateId,
planDate: this.data.scheduleItem.planDate
}
return new Promise((resolve, rejects) => {
modifySchedule(Object.assign(data, obj)).then(res => {
if (res.data.code === 0) {
this.setData({
'conToastData.showToast': true,
'conToastData.title': '保存成功'
})
if (this.$store.data.originalData.repeatable === 1) {
observer.notice(res.data.data)
}
return resolve(res)
} else {
return rejects(res)
}
}).catch(err => {
return rejects(err)
})
})
},
// onSelectPopupCancel 点击取消
onSelectPopupCancel() {
this.setData({
'conSelectPopupData.showSelectPopup': false,
'centerPopup.showCenterPopup': false
})
this.editLocationE(false)
},
selectMeetingRoom(e) {
this.$store.data.locationName = e.target.dataset.locationName
this.$store.data.roomId = e.target.dataset.locationid
this.update()
if (!!this.data.scheduleItem) {
if (this.data.repeatable != 0) {
this.setData({
'conSelectPopupData.showSelectPopup': true
})
} else {
let data = {
location: {
longitude: -999,
latitude: -999,
locationName: this.$store.data.locationName
},
meetingRoomId: this.$store.data.roomId,
modifyModel: 'only',
modifyContent: 'modify_location'
}
this.modifySchedule(data, 0).then(res => {
this.editLocationS()
}).catch(err => {
this.editLocationE()
})
}
} else {
dd.navigateBack({
delta: 1
})
}
},
inputPlace(event) {
this.setData({
place: event.detail.value
})
},
toRoomList: throttle(function () {
dd.navigateTo({ url: `./../meetingRoomList/meetingRoomList` })
}, 1000)
});