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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
import { addSchedule, getUserScheduleInTime } from '../../api/request.js'
import { throttle, getInterTime } from './../../utils/utils.js'
import create from 'dd-store'
create.Page({
data: {
$data: null,
// 传给组件list 的所有数据 comListData
comListData: {
repeatList: [
{ id: 0, text: '不重复', icon: 'iconicon_cycle', repeatable: 0, recurrenceModel: { model: 'no_repeat' } },
{ id: 1, text: '每天', icon: '', repeatable: 1, recurrenceModel: { model: 'daily', interval: 1, initialTime: `2020-03-23`, terminateTime: `2022-03-23`, weekDayList: null } },
{ id: 2, text: '每周', icon: '', repeatable: 1, recurrenceModel: { model: 'weekly', interval: 1, initialTime: `2020-03-23`, terminateTime: `2022-03-23`, weekDayList: ['MO'] } },
{ id: 3, text: '每周的工作日', icon: '', repeatable: 1, recurrenceModel: { model: 'weekly', interval: 1, initialTime: `2020-03-23`, terminateTime: `2022-03-23`, weekDayList: ['MO', 'TU', 'WE', 'TH', 'FR'] } },
{ id: 4, text: '每月', icon: '', repeatable: 1, recurrenceModel: { model: 'absoluteMonthly', daysOfMonth: ['23'], interval: 1, initialTime: `2020-03-23`, terminateTime: `2022-03-23`, weekDayList: null } }
],
meetingWayList: [
{ id: 0, text: 'Webex meeting', imageUrl: '../../assests/Webex.png', meetingWayModel: { model: 'webex' } },
{ id: 1, text: 'Zoom Meeting', imageUrl: '../../assests/Zoom.png', meetingWayModel: { model: 'zoom' } },
{ id: 2, text: '钉钉', imageUrl: '../../assests/dingding.png', meetingWayModel: { model: 'dingtalk' } }
],
comSelectListId: 0,
meetingWayModelId: null,
iconType: 'icon'
},
// 传给组件 hList 水平排列 所有数据 comHListData
comHListData: {
contactData: [
{ id: 0, text: '钉钉联系人', imageUrl: '../../assests/dingContact.png' },
{ id: 1, text: '手动添加邮箱', imageUrl: '../../assests/emailContact.png' }
]
},
title: ``,
repeatable: 0,
recurrenceModel: { model: 'no_repeat' },
isShowRemark: false,
repeatWeek: ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'],
popupTitle: '会议重复',
popupShow: false,
comType: '',
remark: '',
comTimeType: '',
meetingWayModel: { model: null },
weekList: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
week: '',
isAcrossDay: false,
conflictPeople: [],
placeholder: ''
},
showPop(event) {
this.setData({
show: true
})
},
closePop() {
this.setData({
show: false
})
},
Complete(data) {
this.closePop();
},
onLoad() {
dd.setNavigationBar({
title: `创建会议`
})
this.setData({
placeholder: `${getApp().globalData.name}创建的会议`
})
this.reset()
},
onShow() {
if (this.$store.data.participatorList.length > 1) {
this.conflictPeople()
}
setTimeout(() => {
this.update()
}, 100)
},
// 添加描述
addRemark() {
let isShowRemark = !this.data.isShowRemark
this.setData({
isShowRemark: isShowRemark
})
this.update()
},
// 输入框输入事件
onInput(event) {
switch (event.target.dataset.type) {
case 'title':
this.setData({
title: event.detail.value
})
break
case 'remark':
this.setData({
remark: event.detail.value
})
break
}
},
// 初始化
reset() {
this.$store.data.roomId = ''
this.$store.data.participatorList = []
this.$store.data.participatorUserId = []
this.$store.data.originUsers = []
this.$store.data.originUsersId = []
this.$store.data.locationName = ''
this.$store.data.startTime = this.getTimes()
this.$store.data.endTime = this.getTimes(new Date().setMinutes(new Date().getMinutes() + 30))
this.update()
this.resetRepeatList()
this.acrossDay(this.$store.data.startTime, this.$store.data.endTime)
},
// 跳转下一页
nextPage(event) {
switch (event.target.dataset.nextPage) {
case 'location':
dd.navigateTo({ url: './../place/place' })
break
case 'participantsDetail':
dd.navigateTo({ url: './../participantsDetail/participantsDetail' })
break
}
},
// 所有的关闭操作
close(event) {
switch (event.target.dataset.close) {
case 'location':
this.$store.data.locationName = ''
this.$store.data.roomId = ''
this.update()
break
case 'meetingWayModel':
this.setData({
'comListData.meetingWayModelId': null,
meetingWayModel: null
})
}
},
// 关闭popup 点击mark
closePopup() {
this.setData({
popupShow: false
})
},
// 选择循环机制 选择会议方式 选择时间 出现popup弹窗
showPopup(event) {
let iconType = ''
let popupTitle = ''
switch (event.currentTarget.dataset.type) {
case 'meetingWayModel':
iconType = 'image'
popupTitle = '选择会议方式'
break
case 'repeat':
iconType = 'icon'
popupTitle = '会议重复'
break
case 'participator':
popupTitle = '选择参会人'
break
case 'time':
popupTitle = '选择会议时间'
break
}
this.setData({
popupTitle: popupTitle,
popupShow: true,
comType: event.currentTarget.dataset.type,
'comListData.iconType': iconType
})
},
resetRepeatList() {
let index = 0
let repeatList = []
for (let value of this.data.comListData.repeatList) {
if (index) {
value.recurrenceModel.initialTime = this.$store.data.startTime.replace(/\//g, "-").substring(0, 10)
value.recurrenceModel.terminateTime = this.getTwoYearToday(this.$store.data.startTime)
if (index === 2) {
value.recurrenceModel.weekDayList = [this.data.repeatWeek[new Date().getDay()]]
} else if (index === 4) {
value.recurrenceModel.daysOfMonth = [this.$store.data.startTime.replace(/\//g, "-").substring(8, 10)]
}
}
repeatList.push(value)
index++
}
this.setData({
'comListData.repeatList': repeatList,
week: this.data.weekList[new Date().getDay()]
})
},
// 选择完comList后的回调
selectComList(event) {
switch (this.data.comType) {
case 'meetingWayModel':
this.setData({
'comListData.meetingWayModelId': event.currentTarget.dataset.item.id,
popupShow: false,
meetingWayModel: this.data.comListData.meetingWayList[event.currentTarget.dataset.item.id].meetingWayModel
})
break;
case 'repeat':
this.resetRepeatList()
this.setData({
popupShow: false,
'comListData.comSelectListId': event.currentTarget.dataset.item.id,
repeatable: event.currentTarget.dataset.item.repeatable,
recurrenceModel: event.currentTarget.dataset.item.recurrenceModel
})
this.conflictPeople()
break;
}
},
// 选择完水平 HList 的回调
selectComHList(event) {
switch (event.currentTarget.dataset.item.id) {
case 0:
this.addParticipator()
this.setData({
popupShow: false
})
break;
case 1:
this.setData({
popupShow: false
})
dd.navigateTo({ url: './../outLookContact/outLookContact' })
break;
}
},
// 获取两年后的今天
getTwoYearToday(startTime) {
let date = new Date(startTime)
date.setYear(date.getFullYear() + 2)
let year = date.getFullYear();
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
return year + '-' + month + '-' + day
},
// 添加参会人
addParticipator: throttle(function () {
const _that = this
let require = []
let select = []
let outLookConcat = []
for (let participator of _that.$store.data.participatorList) {
if (participator.platform === 'outlook') {
outLookConcat.push(participator)
}
}
select = this.$store.data.participatorUserId
require = [getApp().globalData.userid]
select = _that.selectedelRequired(require, select).pickedUsers
dd.complexChoose({
title: "选择参会人", //标题
multiple: true, //是否多选
pickedUsers: select, //已选用户 s
requiredUsers: require, //必选用户(不可取消选中状态)
responseUserOnly: true, //返回人,或者返回人和部门
success: function (res) {
let participatorList = []
let participatorUserId = []
participatorList.push({ userId: getApp().globalData.userid, username: getApp().globalData.name, headUrl: getApp().globalData.avatar, platform: 'dingtalk' })
participatorUserId.push(getApp().globalData.userid)
res.users.forEach((item, index) => {
participatorList.push({ userId: item.userId, username: item.name, headUrl: item.avatar, platform: 'dingtalk' })
participatorUserId.push(item.userId)
})
participatorList = _that.setArrary(participatorList.concat(outLookConcat))
participatorUserId = [...new Set(participatorUserId)]
_that.$store.data.participatorList = participatorList
_that.$store.data.participatorUserId = participatorUserId
_that.update()
_that.conflictPeople()
},
fail: function (err) {
}
})
}),
// 已选用户去中去掉必选用户
selectedelRequired(req, pic) {
for (let i = 0; i < req.length; i++) {
for (let m = 0; m < pic.length; m++) {
if (req[i] == pic[m]) {
pic.splice(m, 1)
m--;
}
}
}
return {
requiredUsers: req,
pickedUsers: pic
}
},
// 数组 去重
setArrary(arr) {
let containt = {}
for (let x of arr) {
containt['id' + x.userId] = x
}
return Object.values(containt)
},
// 点击完成
onComplete(event) {
this.$store.data.startTime = `${event.startTime}:00`
this.$store.data.endTime = `${event.endTime}:00`
this.update()
this.acrossDay(this.$store.data.startTime, this.$store.data.endTime)
this.setData({
popupShow: false,
week: this.data.weekList[new Date(this.$store.data.startTime).getDay()],
})
this.conflictPeople()
},
addSchedule: throttle(function () {
let data = {
title: this.data.title || `${getApp().globalData.name}创建的会议`,
location: {
longitude: '10',
latitude: '10',
locationName: this.$store.data.locationName
},
startTime: this.$store.data.startTime.replace(/\//g, "-"),
endTime: this.$store.data.endTime.replace(/\//g, "-"),
meetingRoomId: this.$store.data.roomId,
scheduleType: this.$store.data.roomId ? 'meeting' : 'common',
participatorList: !!this.$store.data.participatorList.length ? this.$store.data.participatorList : [{ userId: getApp().globalData.userid, username: getApp().globalData.name, headUrl: getApp().globalData.avatar, platform: 'dingtalk' }],
repeatable: this.data.repeatable,
remark: this.data.remark,
recurrenceModel: this.data.recurrenceModel,
meetingRoomId: this.$store.data.roomId,
meetingWayModel: this.data.meetingWayModel
}
addSchedule(data).then(res => {
if (res.data.code === 0) {
this.$store.data.indexNeedUpdate = true
this.update()
dd.navigateBack({
delta: 1
})
}
})
}),
// 获取时间参数
getTimes(time = new Date()) {
let date = getInterTime(new Date(time))
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
let hour = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
let miunutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
return `${year}/${month}/${day} ${hour}:${miunutes}:00`
},
// 是否跨天
acrossDay(time1, time2) {
let isAcrossDay = ''
if (JSON.stringify(this.getTimes(time1).substring(0, 10)) === JSON.stringify(this.getTimes(time2).substring(0, 10))) {
isAcrossDay = false
} else {
isAcrossDay = true
}
this.setData({
isAcrossDay: isAcrossDay
})
},
// 会议冲突
conflictPeople() {
let userIds = []
for (let value of this.$store.data.participatorList) {
userIds.push(value.userId)
}
let data = {
startTime: this.$store.data.startTime.replace(/\//g, "-"),
endTime: this.$store.data.endTime.replace(/\//g, "-"),
userIds: userIds
}
getUserScheduleInTime(data).then(res => {
let conflictPeople = []
for (let value in res.data.data) {
const arr = res.data.data[value].filter(function (item) {
return item.confirmAttendance === 1
})
if (arr.length > 0) {
conflictPeople.push(value)
}
}
this.setData({
conflictPeople: conflictPeople
})
})
}
});