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
import create from 'dd-store'
import exampleStore from '/stores/exampleStore'
import { saveMettingRoom, getUserScheduleInTime } from '../../api/request'
create.Page({
store: exampleStore,
useAll: true,
data: {
timeStaus: '',
isShowModal: false,
title: null,
time1: '',
week1: '',
time2: '',
week2: '',
propsTime: '',
conflictPeople: []
},
onLoad() {
this.store.data.participatorList = []
this.store.data.locationName = ''
this.store.data.participatorUserId = []
this.update()
dd.setNavigationBar({
title: '创建会议'
})
var date = new Date();
var y = date.getFullYear();
var m = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);//获取当前月份的日期,不足10补0
var d = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();//获取当前几号,不足10补0
var weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
var w = weekList[date.getDay()];
var h = date.getHours()
var min = date.getMinutes();
console.log(h, min)
this.setData({
time1: `${y}/${m}/${d} ${h < 10 ? "0" + date.getHours() : date.getHours()}:${min < 30 ? '00' : '30'}`,
time2: `${y}/${m}/${d} ${min < 30 ? h < 10 ? "0" + date.getHours() : date.getHours() : (h + 1) < 10 ? "0" + (date.getHours() + 1) : date.getHours() + 1}:${min < 30 ? '30' : '00'}`,
week1: w,
week2: w,
})
},
// 选择时间
selectTime(event) {
this.setData({
timeStaus: event.target.dataset.timeStaus,
isShowModal: true,
propsTime: event.target.dataset.timeStaus == 0 ? this.data.time1 : this.data.time2
})
},
// 选择时间组件回调
changeSelectTime(e) {
console.log(e)
if (e.status === 1) {
var date1 = new Date(e.time);
var weekList = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
var w1 = weekList[date1.getDay()];
if (this.data.timeStaus == 0) {
if (new Date(e.time).getTime() > new Date(this.data.time2).getTime()) {
var date = new Date(e.time);
date.setMinutes(date.getMinutes() + 30)
var y = date.getFullYear();
var m = (date.getMonth() + 1) < 10 ? "0" + (date.getMonth() + 1) : (date.getMonth() + 1);//获取当前月份的日期,不足10补0
var d = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();//获取当前几号,不足10补0
var w2 = weekList[date.getDay()];
var h = date.getHours()
var min = date.getMinutes();
this.setData({
time1: e.time,
time2: `${y}/${m}/${d} ${h < 10 ? "0" + date.getHours() : date.getHours()}:${min < 10 ? "0" + min : min}`,
isShowModal: false,
week1: w1,
week2: w2
})
} else {
this.setData({
time1: e.time,
isShowModal: false,
week1: w1
})
}
} else {
if (new Date(e.time).getTime() < new Date(this.data.time1).getTime()) {
dd.alert({
title: '提示',
content: '会议结束时间不能小于开始时间',
buttonText: '我知道了',
success: () => {
},
});
} else {
this.setData({
time2: e.time,
isShowModal: false,
week2: w1
})
}
}
} else {
this.setData({
isShowModal: false
})
}
},
// input 输入事件
getTitle(event) {
this.setData({
title: event.detail.value
})
},
// 添加参会人
addParticipants() {
const _that = this
dd.complexChoose({
title: "选择参会人", //标题
multiple: true, //是否多选
limitTips: "超出了", //超过限定人数返回提示
maxUsers: 1000, //最大可选人数
pickedUsers: _that.store.data.participatorUserId, //已选用户
requiredUsers: [], //必选用户(不可取消选中状态)
requiredDepartments: [], //必选部门(不可取消选中状态)
permissionType: "xxx", //可添加权限校验,选人权限,目前只有GLOBAL这个参数
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()
_that.conflict()
},
fail: function (err) {
}
})
},
// 跳转下一页
nextPage(event) {
switch (event.target.dataset.nextPage) {
case 'participantsDetail':
dd.navigateTo({ url: './../participantsDetail/participantsDetail' })
break;
case 'place':
dd.navigateTo({ url: './../place/place' })
break;
}
},
// 数组去重
setArrary(arr, userId) {
let containt = {}
for (let x of arr) {
containt['id' + x.userId] = x
}
return Object.values(containt)
},
// 保存
saveCreate() {
let data = {
title: this.data.title || '无主题',
location: {
longitude: '10',
latitude: '10',
locationName: this.store.data.locationName || ''
},
startTime: `${this.data.time1.replace(/\//g,"-")}:00`,
endTime: `${this.data.time2.replace(/\//g,'-')} :00`,
scheduleType: 'common',
noticeType: 'dd_notice',
participatorList: this.store.participatorList,
repeatable: 0,
aheadTimes: [],
recurrenceModel: {
model: 'no_repeat'
},
meetingRoomId: 222 || null
}
saveMettingRoom(data).then(res => {
dd.navigateBack({
delta: 1
})
})
},
// 清除地点
closePlace() {
this.store.data.place = ""
this.update()
},
// 会议冲突
conflict() {
let data = {
startTime: `${this.data.time1.replace(/\//g,"-")}:00`,
endTime: `${this.data.time2.replace(/\//g,"-")}:00`,
userIds: this.store.data.participatorUserId
}
getUserScheduleInTime(data).then(res => {
for(let value in res.data.data) {
if(res.data.data[value] === []) {
conflictPeople.push(value)
}
}
})
}
});