|
|
@@ -51,6 +51,22 @@ Page({
|
|
51
|
51
|
// 判断是上班打卡还是下班打卡(true为上班打卡,false为下班打卡)
|
|
52
|
52
|
startOrenDFlag: 0,
|
|
53
|
53
|
showBtnFlag: true, // 判断是否是中心人员(是否需要打卡)
|
|
|
54
|
+ // 批量操作相关
|
|
|
55
|
+ showBatchModal: false, // 是否显示批量操作弹窗
|
|
|
56
|
+ batchSignType: 0, // 批量操作类型:0-签到,1-签退
|
|
|
57
|
+ batchModalTitle: '', // 弹窗标题
|
|
|
58
|
+ batchModalButtonText: '', // 弹窗按钮文本
|
|
|
59
|
+ // 部门和人员选择
|
|
|
60
|
+ departments: [], // 部门列表
|
|
|
61
|
+ departmentNames: [], // 部门名称列表
|
|
|
62
|
+ selectedDepartmentIndex: '', // 选中的部门索引
|
|
|
63
|
+ selectedDepartmentId: '', // 选中的部门ID
|
|
|
64
|
+ users: [], // 人员列表
|
|
|
65
|
+ userList: [], // 人员名称列表
|
|
|
66
|
+ selectedUserId: [], // 选中的人员ID数组
|
|
|
67
|
+ selectedUserNames: [], // 选中的人员姓名数组
|
|
|
68
|
+ // 权限控制
|
|
|
69
|
+ buttonNodes: [], // 按钮权限节点
|
|
54
|
70
|
},
|
|
55
|
71
|
//页面跳转
|
|
56
|
72
|
nav(e) {
|
|
|
@@ -60,6 +76,249 @@ Page({
|
|
60
|
76
|
url: url,
|
|
61
|
77
|
});
|
|
62
|
78
|
},
|
|
|
79
|
+ // 显示批量操作弹窗
|
|
|
80
|
+ showBatchModal(e) {
|
|
|
81
|
+ this.setData({
|
|
|
82
|
+ showBatchModal: true,
|
|
|
83
|
+ batchSignType: 0, // 默认批量上班签到
|
|
|
84
|
+ batchModalTitle: '批量上班签到',
|
|
|
85
|
+ batchModalButtonText: '签到',
|
|
|
86
|
+ selectedDepartmentIndex: '',
|
|
|
87
|
+ selectedDepartmentId: '',
|
|
|
88
|
+ selectedUserId: [],
|
|
|
89
|
+ selectedUserNames: [],
|
|
|
90
|
+ users: [],
|
|
|
91
|
+ userList: []
|
|
|
92
|
+ });
|
|
|
93
|
+ // 获取部门列表
|
|
|
94
|
+ this.getDepartments();
|
|
|
95
|
+ },
|
|
|
96
|
+ // 批量签到类型选择事件
|
|
|
97
|
+ bindBatchTypeChange(e) {
|
|
|
98
|
+ const type = parseInt(e.detail.value); // 将字符串转换为数字
|
|
|
99
|
+ this.setData({
|
|
|
100
|
+ batchSignType: type,
|
|
|
101
|
+ batchModalTitle: type === 0 ? '批量上班签到' : '批量下班签到',
|
|
|
102
|
+ batchModalButtonText: type === 0 ? '签到' : '签退'
|
|
|
103
|
+ });
|
|
|
104
|
+ },
|
|
|
105
|
+ // 隐藏批量操作弹窗
|
|
|
106
|
+ hideBatchModal() {
|
|
|
107
|
+ this.setData({
|
|
|
108
|
+ showBatchModal: false
|
|
|
109
|
+ });
|
|
|
110
|
+ },
|
|
|
111
|
+ // 获取部门列表
|
|
|
112
|
+ getDepartments() {
|
|
|
113
|
+ var that = this;
|
|
|
114
|
+ var token = wx.getStorageSync('token');
|
|
|
115
|
+
|
|
|
116
|
+ wx.showLoading({
|
|
|
117
|
+ title: '加载部门中...',
|
|
|
118
|
+ mask: true
|
|
|
119
|
+ });
|
|
|
120
|
+
|
|
|
121
|
+ wx.request({
|
|
|
122
|
+ url: app.globalData.httpsUrlServer + '/sysdepartment/selectDepartmentByPageListpara?stateid=2',
|
|
|
123
|
+ method: 'post',
|
|
|
124
|
+ data: {data: {
|
|
|
125
|
+ current: 1,
|
|
|
126
|
+ fDeptname: "",
|
|
|
127
|
+ size: 1000
|
|
|
128
|
+ }},
|
|
|
129
|
+ dataType: 'json',
|
|
|
130
|
+ header: {
|
|
|
131
|
+ 'Content-Type': 'application/json;charset=UTF-8',
|
|
|
132
|
+ token: token,
|
|
|
133
|
+ fSource: 1,
|
|
|
134
|
+ },
|
|
|
135
|
+ success: function (res) {
|
|
|
136
|
+ wx.hideLoading();
|
|
|
137
|
+ if (res.statusCode == 200 && res.data.status == 200) {
|
|
|
138
|
+ console.log('部门列表:', res.data.data.data);
|
|
|
139
|
+ var departments = res.data.data.data || [];
|
|
|
140
|
+ // 注意:work_order_info中的字段名是fDeptname和fDeptid,需要检查实际API返回的字段名
|
|
|
141
|
+ var formattedDepartments = departments.map(dept => ({
|
|
|
142
|
+ fDepartmentid: dept.fDeptid || dept.fDepartmentid,
|
|
|
143
|
+ fDepartmentname: dept.fDeptname || dept.fDepartmentname
|
|
|
144
|
+ }));
|
|
|
145
|
+ var departmentNames = formattedDepartments.map(dept => dept.fDepartmentname);
|
|
|
146
|
+ that.setData({
|
|
|
147
|
+ departments: formattedDepartments,
|
|
|
148
|
+ departmentNames: departmentNames
|
|
|
149
|
+ });
|
|
|
150
|
+ }
|
|
|
151
|
+ },
|
|
|
152
|
+ fail: function (err) {
|
|
|
153
|
+ wx.hideLoading();
|
|
|
154
|
+ console.error('获取部门列表失败:', err);
|
|
|
155
|
+ wx.showToast({
|
|
|
156
|
+ title: '获取部门失败',
|
|
|
157
|
+ icon: 'none'
|
|
|
158
|
+ });
|
|
|
159
|
+ }
|
|
|
160
|
+ });
|
|
|
161
|
+ },
|
|
|
162
|
+ // 获取人员列表
|
|
|
163
|
+ getUsers(departmentId) {
|
|
|
164
|
+ if (!departmentId) return;
|
|
|
165
|
+
|
|
|
166
|
+ var that = this;
|
|
|
167
|
+ var token = wx.getStorageSync('token');
|
|
|
168
|
+
|
|
|
169
|
+ wx.showLoading({
|
|
|
170
|
+ title: '加载人员中...',
|
|
|
171
|
+ mask: true
|
|
|
172
|
+ });
|
|
|
173
|
+
|
|
|
174
|
+ wx.request({
|
|
|
175
|
+ url: app.globalData.httpsUrlServer + '/sysuseraccount/selectUserAccountAppByPageList',
|
|
|
176
|
+ method: 'post',
|
|
|
177
|
+ data: {data: {
|
|
|
178
|
+ current: 1,
|
|
|
179
|
+ size: 9999,
|
|
|
180
|
+ fDeptid: departmentId
|
|
|
181
|
+ }},
|
|
|
182
|
+ dataType: 'json',
|
|
|
183
|
+ header: {
|
|
|
184
|
+ 'Content-Type': 'application/json;charset=UTF-8',
|
|
|
185
|
+ token: token,
|
|
|
186
|
+ fSource: 1,
|
|
|
187
|
+ },
|
|
|
188
|
+ success: function (res) {
|
|
|
189
|
+ wx.hideLoading();
|
|
|
190
|
+ if (res.statusCode == 200 && res.data.status == 200) {
|
|
|
191
|
+ var users = res.data.data.data || [];
|
|
|
192
|
+ console.log('人员列表:', users);
|
|
|
193
|
+ // 注意:需要检查实际API返回的字段名是否与预期一致
|
|
|
194
|
+ var formattedUsers = users.map(user => ({
|
|
|
195
|
+ fExpandint1: user.fUserid || user.fExpandint1,
|
|
|
196
|
+ fRealname: user.fUsername || user.fRealname,
|
|
|
197
|
+ fDepartmentid: user.fDeptid || user.fDepartmentid
|
|
|
198
|
+ }));
|
|
|
199
|
+ console.log('格式化后的人员列表:', formattedUsers);
|
|
|
200
|
+ that.setData({
|
|
|
201
|
+ users: formattedUsers,
|
|
|
202
|
+ userList: formattedUsers
|
|
|
203
|
+ });
|
|
|
204
|
+ }
|
|
|
205
|
+ },
|
|
|
206
|
+ fail: function (err) {
|
|
|
207
|
+ wx.hideLoading();
|
|
|
208
|
+ console.error('获取人员列表失败:', err);
|
|
|
209
|
+ wx.showToast({
|
|
|
210
|
+ title: '获取人员失败',
|
|
|
211
|
+ icon: 'none'
|
|
|
212
|
+ });
|
|
|
213
|
+ }
|
|
|
214
|
+ });
|
|
|
215
|
+ },
|
|
|
216
|
+ // 部门选择事件
|
|
|
217
|
+ bindDepartmentChange(e) {
|
|
|
218
|
+ const index = e.detail.value;
|
|
|
219
|
+ const departmentId = this.data.departments[index].fDepartmentid;
|
|
|
220
|
+ this.setData({
|
|
|
221
|
+ selectedDepartmentIndex: index,
|
|
|
222
|
+ selectedDepartmentId: departmentId,
|
|
|
223
|
+ // 重置人员选择
|
|
|
224
|
+ selectedUserId: [],
|
|
|
225
|
+ selectedUserNames: []
|
|
|
226
|
+ });
|
|
|
227
|
+ // 获取该部门下的人员列表
|
|
|
228
|
+ this.getUsers(departmentId);
|
|
|
229
|
+ },
|
|
|
230
|
+ // 人员选择事件
|
|
|
231
|
+ bindUserCheckboxChange(e) {
|
|
|
232
|
+ // 注意:e.detail.value返回的是字符串数组
|
|
|
233
|
+ console.log('选中的用户ID字符串数组:', e.detail.value);
|
|
|
234
|
+ const selectedUserIdsStr = e.detail.value;
|
|
|
235
|
+ // 根据用户ID字符串找到对应的用户信息
|
|
|
236
|
+ const selectedUsers = this.data.users.filter(user =>
|
|
|
237
|
+ selectedUserIdsStr.includes(user.fExpandint1.toString())
|
|
|
238
|
+ );
|
|
|
239
|
+ console.log('选中的用户信息:', selectedUsers);
|
|
|
240
|
+ const selectedUserIds = selectedUsers.map(user => user.fExpandint1);
|
|
|
241
|
+ const selectedUserNames = selectedUsers.map(user => user.fRealname);
|
|
|
242
|
+ console.log('选中的用户ID数组:', selectedUserIds);
|
|
|
243
|
+ console.log('选中的用户姓名数组:', selectedUserNames);
|
|
|
244
|
+ this.setData({
|
|
|
245
|
+ selectedUserId: selectedUserIds,
|
|
|
246
|
+ selectedUserNames: selectedUserNames
|
|
|
247
|
+ });
|
|
|
248
|
+ },
|
|
|
249
|
+ // 确认批量签到/签退
|
|
|
250
|
+ confirmBatchSign() {
|
|
|
251
|
+ const that = this;
|
|
|
252
|
+ const { batchSignType, selectedUserId, selectedUserNames, markers, posObj } = this.data;
|
|
|
253
|
+
|
|
|
254
|
+ if (selectedUserId.length === 0) {
|
|
|
255
|
+ wx.showToast({
|
|
|
256
|
+ title: '请选择人员',
|
|
|
257
|
+ icon: 'none',
|
|
|
258
|
+ duration: 2000
|
|
|
259
|
+ });
|
|
|
260
|
+ return;
|
|
|
261
|
+ }
|
|
|
262
|
+
|
|
|
263
|
+ wx.showLoading({
|
|
|
264
|
+ title: '处理中...',
|
|
|
265
|
+ mask: true
|
|
|
266
|
+ });
|
|
|
267
|
+
|
|
|
268
|
+ const timeStamp = new Date().getTime();
|
|
|
269
|
+ // 构造请求数据 - 根据selectedUserId的长度创建数组
|
|
|
270
|
+ const data = [];
|
|
|
271
|
+ const positionName = markers[0].name;
|
|
|
272
|
+ const latitude = posObj.latitude;
|
|
|
273
|
+ const longitude = posObj.longitude;
|
|
|
274
|
+
|
|
|
275
|
+ // 遍历selectedUserId数组,为每个用户创建一个数据对象
|
|
|
276
|
+ for (let i = 0; i < selectedUserId.length; i++) {
|
|
|
277
|
+ data.push({
|
|
|
278
|
+ fExpand1: positionName, // 当前位置名称
|
|
|
279
|
+ fWorktime: timeStamp, // 当前时间戳
|
|
|
280
|
+ fX: latitude, // 当前纬度
|
|
|
281
|
+ fY: longitude, // 当前经度
|
|
|
282
|
+ fExpandint1: selectedUserId[i], // 单个用户ID
|
|
|
283
|
+ fRealname: selectedUserNames[i] // 单个用户姓名
|
|
|
284
|
+ });
|
|
|
285
|
+ }
|
|
|
286
|
+
|
|
|
287
|
+ // 根据操作类型选择API接口
|
|
|
288
|
+ const url = batchSignType === 0
|
|
|
289
|
+ ? app.globalData.httpsUrlServer + '/tbaseemployeeworkrecords/batchSignIn'
|
|
|
290
|
+ : app.globalData.httpsUrlServer + '/tbaseemployeeworkrecords/batchSignOut';
|
|
|
291
|
+
|
|
|
292
|
+ // 调用API
|
|
|
293
|
+ console.log(url, data)
|
|
|
294
|
+
|
|
|
295
|
+ app.postReq(url, data, (res) => {
|
|
|
296
|
+ wx.hideLoading();
|
|
|
297
|
+ if (res.message === '请求成功') {
|
|
|
298
|
+ wx.showToast({
|
|
|
299
|
+ title: batchSignType === 0 ? '批量签到成功' : '批量签退成功',
|
|
|
300
|
+ icon: 'success',
|
|
|
301
|
+ duration: 2000
|
|
|
302
|
+ });
|
|
|
303
|
+ // 隐藏弹窗
|
|
|
304
|
+ that.hideBatchModal();
|
|
|
305
|
+ } else {
|
|
|
306
|
+ wx.showToast({
|
|
|
307
|
+ title: res.message || '操作失败',
|
|
|
308
|
+ icon: 'none',
|
|
|
309
|
+ duration: 2000
|
|
|
310
|
+ });
|
|
|
311
|
+ }
|
|
|
312
|
+ }, (err) => {
|
|
|
313
|
+ wx.hideLoading();
|
|
|
314
|
+ wx.showToast({
|
|
|
315
|
+ title: '网络错误',
|
|
|
316
|
+ icon: 'none',
|
|
|
317
|
+ duration: 2000
|
|
|
318
|
+ });
|
|
|
319
|
+ console.error('批量操作失败:', err);
|
|
|
320
|
+ });
|
|
|
321
|
+ },
|
|
63
|
322
|
// 签到事件
|
|
64
|
323
|
openSetting() {
|
|
65
|
324
|
var that = this;
|
|
|
@@ -241,9 +500,23 @@ Page({
|
|
241
|
500
|
that.getLocation();
|
|
242
|
501
|
// 查询当前登录人员是否有上班打卡记录
|
|
243
|
502
|
that.getSelectCurrentUserIsSgin();
|
|
|
503
|
+ // 获取权限控制按钮节点
|
|
|
504
|
+ this.getButtonNodes();
|
|
244
|
505
|
|
|
245
|
506
|
wx.hideLoading();
|
|
246
|
507
|
},
|
|
|
508
|
+ // 获取权限控制按钮节点
|
|
|
509
|
+ getButtonNodes() {
|
|
|
510
|
+ // 获取缓存中的按钮节点数据
|
|
|
511
|
+ const buttonNodes = wx.getStorageSync('buttonNodes') || [];
|
|
|
512
|
+ // 筛选出与考勤相关的数据并提取fFunctioncode
|
|
|
513
|
+ const attendanceButtons = buttonNodes
|
|
|
514
|
+ .filter(node => node.parentFFunctioncode === 'attendanceManagement' && node.fFunctioncode)
|
|
|
515
|
+ .map(node => node.fFunctioncode);
|
|
|
516
|
+ this.setData({
|
|
|
517
|
+ buttonNodes: attendanceButtons
|
|
|
518
|
+ });
|
|
|
519
|
+ },
|
|
247
|
520
|
|
|
248
|
521
|
/**
|
|
249
|
522
|
* 生命周期函数--监听页面初次渲染完成
|