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
import create from 'dd-store'
import exampleStore from '/stores/exampleStore'
import { addSchedule, getUserScheduleInTime, getHomeUserSchedule } from '../../api/request.js'
create.Page({
store: exampleStore,
useAll: true,
time1: '',
time2: '',
data: {
},
onLoad(event) {
this.setData({
time1: event.time1,
time2: event.time1
})
dd.setNavigationBar({
title: `参会人(${this.store.data.participatorList.length}人)`
})
},
// 保存信息
saveInfo() {
this.conflict()
},
// 添加参会人
addParticipants() {
const _that = this
dd.complexChoose({
title: "选择参会人", //标题
multiple: true, //是否多选
limitTips: "超出了", //超过限定人数返回提示
maxUsers: 1000, //最大可选人数
pickedUsers: _that.store.data.participatorUserId, //已选用户
requiredUsers: [], //必选用户(不可取消选中状态
responseUserOnly: true, //返回人,或者返回人和部门
success: function (res) {
res.users.forEach((item, index) => {
_that.store.data.participatorList.push({ userId: item.userId, username: item.name, headUrl: item.headUrl })
_that.store.data.participatorUserId.push(item.userId)
})
_that.store.data.participatorList = _that.setArrary(_that.store.data.participatorList)
_that.store.data.participatorUserId = [...new Set(_that.store.data.participatorUserId)]
_that.update()
dd.setNavigationBar({
title: `参会人(${_that.store.data.participatorList.length}人)`
})
},
fail: function (err) {
}
})
},
// 删除参会人
delParticipants(event) {
let userId = event.target.dataset.userId
this.store.data.participatorList.forEach((item, index) => {
if (userId === item.userId) {
this.store.data.participatorList.splice(index, 1)
this.update()
return
}
})
this.store.data.participatorUserId.forEach((item, index) => {
if (userId === item) {
this.store.data.participatorUserId.splice(index, 1)
this.update()
return
}
})
dd.setNavigationBar({
title: `参会人(${this.store.data.participatorList.length}人)`
})
},
// 数组去重
setArrary(arr, userId) {
console.log(arr)
let containt = {}
for (let x of arr) {
containt['id' + x.userId] = x
}
return Object.values(containt)
},
// 会议冲突
conflict() {
this.store.data.conflictPeople = []
let data = {
startTime: `${this.data.time1}:00`,
endTime: `${this.data.time2}:00`,
userIds: this.store.data.participatorUserId
}
getUserScheduleInTime(data).then(res => {
for (let value in res.data.data) {
if (!!res.data.data[value].length) {
this.store.data.conflictPeople.push(value)
}
}
this.update()
dd.navigateBack({
delta: 1
})
})
}
});