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
import { getUserScheduleInTime } from '../../api/request.js'
import { throttle } from './../../utils/utils.js'
import pageStore from '../participantsDetail/store';
import create from 'dd-store'
// 传递给组件toast的所有数据
const conToastData = {
showToast: false,
title: '邮箱格式错误'
}
create.Page({
store: pageStore,
useAll: true,
data: {
$data: null,
outlookContact: [],
conflictPeople: [],
scheduleItem: '',
// 传递给组件toast的所有数据
conToastData: conToastData,
currentPeople: '',
value: '',
toPage: ''
},
onLoad(event) {
const _that = this
if (event.scheduleItem) {
event.scheduleItem = decodeURIComponent(event.scheduleItem)
let scheduleItem = JSON.parse(event.scheduleItem)
this.setData({
scheduleItem: scheduleItem
})
}
if (event.toPage) {
this.setData({
toPage: event.toPage
})
}
let outlookContact = []
let userList = []
if (!this.data.scheduleItem || !this.data.toPage) {
userList = this.$store.data.participatorList
} else {
userList = this.store.data.contactPeople
}
for (let value of userList) {
if (value.platform === 'outlook') {
outlookContact.push(value)
}
}
this.setData({
outlookContact: outlookContact,
currentPeople: getApp().globalData.userid
})
this.conflictPeople()
},
onShow() {
},
// input 的输入 事件
onInput(event) {
this.setData({
value: event.detail.value
})
},
// 添加email
addEmail() {
let reg = /^(?!.* )\w+((.\w+)|(-\w+))@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+).[A-Za-z0-9]+$/
if (!!this.data.value) {
if (reg.test(this.data.value)) {
let outlookContact = this.data.outlookContact
outlookContact.push({
userId: this.data.value,
username: this.data.value,
headUrl: '',
platform: 'outlook'
})
outlookContact = this.setArrary(outlookContact)
this.setData({
value: '',
outlookContact: outlookContact
})
this.conflictPeople()
}
else {
this.setData({
'conToastData.showToast': true
})
}
}
},
// 关闭
close(event) {
let outlookContact = this.data.outlookContact
let index = 0
for (let value of this.data.outlookContact) {
if (value.userId === event.currentTarget.dataset.item.userId) {
outlookContact.splice(index, 1)
this.setData({
outlookContact: outlookContact
})
return
}
index++
}
},
// 数组 去重
setArrary(arr) {
let containt = {}
for (let x of arr) {
containt['id' + x.userId] = x
}
return Object.values(containt)
},
// 保存
save() {
let userList = []
let userId = []
userList.push({ userId: getApp().globalData.userid, username: getApp().globalData.name, headUrl: getApp().globalData.avatar, platform: 'dingtalk' })
userId.push(getApp().globalData.userid)
for (let value of this.data.outlookContact) {
userList.push(value)
userId.push(value.userId)
}
userList = this.setArrary(userList)
userId = [...new Set(userId)]
if (!this.data.scheduleItem || !this.data.toPage) {
this.$store.data.participatorList.push(...userList)
this.$store.data.participatorUserId.push(...userId)
this.$store.data.participatorList = this.setArrary(this.$store.data.participatorList)
this.$store.data.participatorUserId = [...new Set(this.$store.data.participatorUserId)]
} else {
this.store.data.contactPeople.push(...userList)
this.store.data.contactPeopleId.push(...userId)
this.store.data.contactPeople = this.setArrary(this.store.data.contactPeople)
this.store.data.contactPeopleId = [...new Set(this.store.data.userId)]
if (this.store.data.contactPeople != this.$store.data.originalData.userList) {
this.$store.data.updateInfo.isUpate = true
this.$store.data.updateInfo.updateType = 'operate_user'
}
}
this.update()
dd.navigateBack({
delta: 1
})
},
// 选择弹窗
onSelectPopup(event) {
this.setData({
'conSelectPopupData.showSelectPopup': false,
'conSelectPopupData.selectPopupId': event.currentTarget.dataset.item.id,
'centerPopup.showCenterPopup': true
})
},
// toast 消失之后的回调
onToastHidden() {
this.setData({
'conToastData.showToast': false
})
},
// 会议冲突
conflictPeople() {
let userIds = []
for (let value of this.data.outlookContact) {
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) {
if (!!this.data.scheduleItem) {
const arr = res.data.data[value].filter(function (item) {
return item.confirmAttendance === 1
})
if (arr.length > 1) {
conflictPeople.push(value)
}
} else {
const arr = res.data.data[value].filter(function (item) {
return item.confirmAttendance === 1
})
if (arr.length > 1) {
conflictPeople.push(value)
}
}
}
this.setData({
conflictPeople: conflictPeople
})
})
},
// onSelectPopupCancel 点击取消
onSelectPopupCancel() {
this.setData({
'conSelectPopupData.showSelectPopup': false,
'centerPopup.showCenterPopup': false
})
this.operateUserE(false)
},
// 页面卸载
onUnload() {
}
});