|
|
@@ -5,15 +5,24 @@ Page({
|
|
5
|
5
|
* 页面的初始数据
|
|
6
|
6
|
*/
|
|
7
|
7
|
data: {
|
|
8
|
|
- reportType: 'daily', // 填报类型:daily-日报, weekly-周报
|
|
9
|
8
|
id: '', // 编辑时的ID
|
|
10
|
|
- title: '',
|
|
11
|
|
- date: '', // 日报日期
|
|
12
|
|
- weekStartDate: '', // 周报开始日期
|
|
13
|
|
- weekEndDate: '', // 周报结束日期
|
|
14
|
|
- content: '',
|
|
|
9
|
+ team: '', // 管养班组
|
|
|
10
|
+ number: '', // 人数
|
|
|
11
|
+ type: '1', // 类型:1日2周3月
|
|
|
12
|
+ workStartTime: '', // 工作开始时间
|
|
|
13
|
+ workEndTime: '', // 工作结束时间
|
|
|
14
|
+ workContent: [ // 工作内容列表
|
|
|
15
|
+ {
|
|
|
16
|
+ content: '', // 工作内容
|
|
|
17
|
+ location: '', // 工作地点
|
|
|
18
|
+ completion: '', // 完成情况
|
|
|
19
|
+ remark: '' // 备注
|
|
|
20
|
+ }
|
|
|
21
|
+ ],
|
|
|
22
|
+ unfinishedWork: '', // 未完成工作
|
|
15
|
23
|
submitter: '当前用户', // 实际项目中应从登录信息获取
|
|
16
|
|
- isSubmitting: false
|
|
|
24
|
+ isSubmitting: false,
|
|
|
25
|
+ pageMode: 'normal' // 页面模式:normal(正常编辑), view(只读查看)
|
|
17
|
26
|
},
|
|
18
|
27
|
|
|
19
|
28
|
// 标题输入
|
|
|
@@ -23,204 +32,248 @@ Page({
|
|
23
|
32
|
});
|
|
24
|
33
|
},
|
|
25
|
34
|
|
|
26
|
|
- // 选择填报类型
|
|
27
|
|
- selectReportType(e) {
|
|
28
|
|
- const type = e.currentTarget.dataset.type;
|
|
29
|
|
- // 确保值确实发生了变化才执行操作
|
|
30
|
|
- if (type !== this.data.reportType) {
|
|
31
|
|
- this.setData({
|
|
32
|
|
- reportType: type
|
|
33
|
|
- });
|
|
34
|
|
-
|
|
35
|
|
- // 类型切换时可以添加一些重置逻辑(如果需要)
|
|
36
|
|
- // 例如:当从日报切换到周报时,可以根据日报日期计算默认的周日期范围
|
|
37
|
|
- if (type === 'weekly' && this.data.date) {
|
|
38
|
|
- // 这里可以根据日报日期计算周报的开始和结束日期
|
|
39
|
|
- // 这里仅作为示例,实际应用中可能需要更复杂的日期计算逻辑
|
|
40
|
|
- }
|
|
41
|
|
- }
|
|
|
35
|
+ // 管养班组输入
|
|
|
36
|
+ onTeamInput(e) {
|
|
|
37
|
+ this.setData({
|
|
|
38
|
+ team: e.detail.value
|
|
|
39
|
+ });
|
|
42
|
40
|
},
|
|
43
|
41
|
|
|
44
|
|
- // 日报日期选择
|
|
45
|
|
- onDateChange(e) {
|
|
|
42
|
+ // 人数输入
|
|
|
43
|
+ onNumberInput(e) {
|
|
46
|
44
|
this.setData({
|
|
47
|
|
- date: e.detail.value
|
|
|
45
|
+ number: e.detail.value
|
|
48
|
46
|
});
|
|
49
|
47
|
},
|
|
50
|
48
|
|
|
51
|
|
- // 周报开始日期选择
|
|
52
|
|
- onWeekStartDateChange(e) {
|
|
53
|
|
- const startDate = e.detail.value;
|
|
54
|
|
- // 如果结束日期早于开始日期,则清空结束日期
|
|
55
|
|
- if (this.data.weekEndDate && this.data.weekEndDate < startDate) {
|
|
|
49
|
+ // 选择类型
|
|
|
50
|
+ selectType(e) {
|
|
|
51
|
+ const type = e.currentTarget.dataset.type;
|
|
|
52
|
+ this.setData({
|
|
|
53
|
+ type: type
|
|
|
54
|
+ });
|
|
|
55
|
+ },
|
|
|
56
|
+
|
|
|
57
|
+ // 工作开始时间选择
|
|
|
58
|
+ onWorkStartTimeChange(e) {
|
|
|
59
|
+ const startTime = e.detail.value;
|
|
|
60
|
+ // 如果结束时间早于开始时间,则清空结束时间
|
|
|
61
|
+ if (this.data.workEndTime && this.data.workEndTime < startTime) {
|
|
56
|
62
|
this.setData({
|
|
57
|
|
- weekStartDate: startDate,
|
|
58
|
|
- weekEndDate: ''
|
|
|
63
|
+ workStartTime: startTime,
|
|
|
64
|
+ workEndTime: ''
|
|
59
|
65
|
});
|
|
60
|
66
|
} else {
|
|
61
|
67
|
this.setData({
|
|
62
|
|
- weekStartDate: startDate
|
|
|
68
|
+ workStartTime: startTime
|
|
63
|
69
|
});
|
|
64
|
70
|
}
|
|
65
|
71
|
},
|
|
66
|
72
|
|
|
67
|
|
- // 周报结束日期选择
|
|
68
|
|
- onWeekEndDateChange(e) {
|
|
|
73
|
+ // 工作结束时间选择
|
|
|
74
|
+ onWorkEndTimeChange(e) {
|
|
|
75
|
+ this.setData({
|
|
|
76
|
+ workEndTime: e.detail.value
|
|
|
77
|
+ });
|
|
|
78
|
+ },
|
|
|
79
|
+
|
|
|
80
|
+ // 工作内容输入
|
|
|
81
|
+ onWorkContentInput(e) {
|
|
|
82
|
+ const index = e.currentTarget.dataset.index;
|
|
|
83
|
+ const field = e.currentTarget.dataset.field;
|
|
|
84
|
+ const value = e.detail.value;
|
|
|
85
|
+
|
|
|
86
|
+ const workContent = this.data.workContent;
|
|
|
87
|
+ workContent[index][field] = value;
|
|
|
88
|
+
|
|
|
89
|
+ this.setData({
|
|
|
90
|
+ workContent: workContent
|
|
|
91
|
+ });
|
|
|
92
|
+ },
|
|
|
93
|
+
|
|
|
94
|
+ // 添加工作内容
|
|
|
95
|
+ addWorkContent() {
|
|
|
96
|
+ const workContent = this.data.workContent;
|
|
|
97
|
+ workContent.push({
|
|
|
98
|
+ content: '',
|
|
|
99
|
+ location: '',
|
|
|
100
|
+ completion: '',
|
|
|
101
|
+ remark: ''
|
|
|
102
|
+ });
|
|
|
103
|
+
|
|
69
|
104
|
this.setData({
|
|
70
|
|
- weekEndDate: e.detail.value
|
|
|
105
|
+ workContent: workContent
|
|
71
|
106
|
});
|
|
72
|
107
|
},
|
|
73
|
108
|
|
|
74
|
|
- // 内容输入
|
|
75
|
|
- onContentInput(e) {
|
|
|
109
|
+ // 删除工作内容
|
|
|
110
|
+ deleteWorkContent(e) {
|
|
|
111
|
+ const index = e.currentTarget.dataset.index;
|
|
|
112
|
+ const workContent = this.data.workContent;
|
|
|
113
|
+
|
|
|
114
|
+ if (workContent.length > 1) {
|
|
|
115
|
+ workContent.splice(index, 1);
|
|
|
116
|
+ this.setData({
|
|
|
117
|
+ workContent: workContent
|
|
|
118
|
+ });
|
|
|
119
|
+ } else {
|
|
|
120
|
+ wx.showToast({
|
|
|
121
|
+ title: '至少保留一项工作内容',
|
|
|
122
|
+ icon: 'none'
|
|
|
123
|
+ });
|
|
|
124
|
+ }
|
|
|
125
|
+ },
|
|
|
126
|
+
|
|
|
127
|
+ // 未完成工作输入
|
|
|
128
|
+ onUnfinishedWorkInput(e) {
|
|
76
|
129
|
this.setData({
|
|
77
|
|
- content: e.detail.value
|
|
|
130
|
+ unfinishedWork: e.detail.value
|
|
78
|
131
|
});
|
|
79
|
132
|
},
|
|
80
|
133
|
|
|
81
|
134
|
// 提交报表
|
|
82
|
135
|
async submitReport() {
|
|
|
136
|
+ // 如果是查看模式,不允许提交
|
|
|
137
|
+ if (this.data.pageMode === 'view') {
|
|
|
138
|
+ return;
|
|
|
139
|
+ }
|
|
|
140
|
+
|
|
83
|
141
|
// 表单验证
|
|
84
|
|
- if (!this.data.title) {
|
|
85
|
|
- wx.showToast({ title: '请输入标题', icon: 'none' });
|
|
|
142
|
+
|
|
|
143
|
+ if (!this.data.team) {
|
|
|
144
|
+ wx.showToast({ title: '请输入管养班组', icon: 'none' });
|
|
86
|
145
|
return;
|
|
87
|
146
|
}
|
|
88
|
147
|
|
|
89
|
|
- // 根据类型进行日期验证
|
|
90
|
|
- if (this.data.reportType === 'daily') {
|
|
91
|
|
- if (!this.data.date) {
|
|
92
|
|
- wx.showToast({ title: '请选择日期', icon: 'none' });
|
|
93
|
|
- return;
|
|
94
|
|
- }
|
|
95
|
|
- } else if (this.data.reportType === 'weekly') {
|
|
96
|
|
- if (!this.data.weekStartDate) {
|
|
97
|
|
- wx.showToast({ title: '请选择开始日期', icon: 'none' });
|
|
98
|
|
- return;
|
|
99
|
|
- }
|
|
100
|
|
- if (!this.data.weekEndDate) {
|
|
101
|
|
- wx.showToast({ title: '请选择结束日期', icon: 'none' });
|
|
102
|
|
- return;
|
|
103
|
|
- }
|
|
|
148
|
+ if (!this.data.number || parseInt(this.data.number) <= 0) {
|
|
|
149
|
+ wx.showToast({ title: '请输入有效的人数', icon: 'none' });
|
|
|
150
|
+ return;
|
|
104
|
151
|
}
|
|
105
|
152
|
|
|
106
|
|
- if (!this.data.content) {
|
|
107
|
|
- wx.showToast({ title: '请输入内容', icon: 'none' });
|
|
|
153
|
+ if (!this.data.workStartTime) {
|
|
|
154
|
+ wx.showToast({ title: '请选择工作开始时间', icon: 'none' });
|
|
|
155
|
+ return;
|
|
|
156
|
+ }
|
|
|
157
|
+
|
|
|
158
|
+ if (!this.data.workEndTime) {
|
|
|
159
|
+ wx.showToast({ title: '请选择工作结束时间', icon: 'none' });
|
|
|
160
|
+ return;
|
|
|
161
|
+ }
|
|
|
162
|
+
|
|
|
163
|
+ // 验证工作内容
|
|
|
164
|
+ const hasValidWorkContent = this.data.workContent.some(item =>
|
|
|
165
|
+ item.content && item.location && item.completion
|
|
|
166
|
+ );
|
|
|
167
|
+ if (!hasValidWorkContent) {
|
|
|
168
|
+ wx.showToast({ title: '请至少填写一项完整的工作内容', icon: 'none' });
|
|
108
|
169
|
return;
|
|
109
|
170
|
}
|
|
110
|
171
|
|
|
111
|
172
|
this.setData({ isSubmitting: true });
|
|
|
173
|
+
|
|
|
174
|
+
|
|
112
|
175
|
try {
|
|
113
|
|
- // 根据类型构建不同的数据结构
|
|
|
176
|
+ // 构建接口所需的数据结构
|
|
114
|
177
|
let data = {
|
|
115
|
178
|
id: this.data.id,
|
|
116
|
|
- title: this.data.title,
|
|
117
|
|
- content: this.data.content,
|
|
118
|
|
- type: this.data.reportType === 'daily' ? '日报' : '周报',
|
|
119
|
|
- rawType: this.data.reportType,
|
|
|
179
|
+ team: this.data.team,
|
|
|
180
|
+ number: parseInt(this.data.number),
|
|
|
181
|
+ type: parseInt(this.data.type),
|
|
|
182
|
+ workStartTime: this.data.workStartTime + ' 00:00:00',
|
|
|
183
|
+ workEndTime: this.data.workEndTime + ' 23:59:59',
|
|
|
184
|
+ workContent: JSON.stringify(this.data.workContent),
|
|
|
185
|
+ unfinishedWork: this.data.unfinishedWork,
|
|
120
|
186
|
submitter: this.data.submitter
|
|
121
|
187
|
};
|
|
|
188
|
+ console.log('提交数据', data);
|
|
122
|
189
|
|
|
123
|
|
- // 根据类型设置日期相关字段
|
|
124
|
|
- if (this.data.reportType === 'daily') {
|
|
125
|
|
- data.date = this.data.date;
|
|
126
|
|
- data.displayDate = this.data.date;
|
|
127
|
|
- } else if (this.data.reportType === 'weekly') {
|
|
128
|
|
- data.date = this.data.weekStartDate + '至' + this.data.weekEndDate;
|
|
129
|
|
- data.weekStartDate = this.data.weekStartDate;
|
|
130
|
|
- data.weekEndDate = this.data.weekEndDate;
|
|
131
|
|
- data.displayDate = this.data.weekStartDate + '至' + this.data.weekEndDate;
|
|
|
190
|
+ let res;
|
|
|
191
|
+ // 根据是否有id判断是新增还是编辑
|
|
|
192
|
+ if (this.data.id) {
|
|
|
193
|
+ // 编辑模式 - 使用update接口
|
|
|
194
|
+ res = await app.sendRequest('put', '/t-work-report/updateWorkReportBase', data);
|
|
|
195
|
+ } else {
|
|
|
196
|
+ // 新增模式 - 使用save接口
|
|
|
197
|
+ res = await app.sendRequest('post', '/t-work-report/saveWorkReportBase', data);
|
|
132
|
198
|
}
|
|
133
|
199
|
|
|
134
|
|
- // 这里模拟请求,实际需要替换为真实接口
|
|
135
|
|
- // let url = this.data.id ? '/report/updateReport' : '/report/createReport';
|
|
136
|
|
- // let res = await app.sendRequest('post', url, { data });
|
|
137
|
|
- // if (res.status == 200) {
|
|
138
|
|
- // wx.showToast({ title: '保存成功' });
|
|
139
|
|
- // setTimeout(() => {
|
|
140
|
|
- // wx.navigateBack();
|
|
141
|
|
- // }, 1500);
|
|
142
|
|
- // }
|
|
143
|
|
-
|
|
144
|
|
- // 模拟保存成功
|
|
145
|
|
- setTimeout(() => {
|
|
146
|
|
- wx.showToast({ title: '保存成功' });
|
|
|
200
|
+ if (res.status == 200) {
|
|
|
201
|
+ wx.showToast({ title: this.data.id ? '更新成功' : '保存成功' });
|
|
147
|
202
|
setTimeout(() => {
|
|
148
|
203
|
wx.navigateBack();
|
|
149
|
204
|
}, 1500);
|
|
150
|
|
- }, 1000);
|
|
|
205
|
+ } else {
|
|
|
206
|
+ wx.showToast({ title: res.message || '操作失败', icon: 'none' });
|
|
|
207
|
+ }
|
|
151
|
208
|
} catch (error) {
|
|
152
|
|
- console.log('保存失败', error);
|
|
153
|
|
- wx.showToast({ title: '保存失败', icon: 'none' });
|
|
|
209
|
+ console.log('操作失败', error);
|
|
|
210
|
+ wx.showToast({ title: '操作失败', icon: 'none' });
|
|
154
|
211
|
} finally {
|
|
155
|
212
|
this.setData({ isSubmitting: false });
|
|
156
|
213
|
}
|
|
157
|
214
|
},
|
|
|
215
|
+
|
|
158
|
216
|
|
|
159
|
|
- // 获取报表详情(编辑时使用)
|
|
|
217
|
+ // 获取报表详情(编辑或查看时使用)
|
|
160
|
218
|
async getReportDetail() {
|
|
161
|
219
|
if (!this.data.id) return;
|
|
162
|
220
|
|
|
163
|
221
|
try {
|
|
164
|
|
- let data = { id: this.data.id };
|
|
165
|
|
- // 这里模拟请求,实际需要替换为真实接口
|
|
166
|
|
- // let res = await app.sendRequest('post', '/report/selectReportDetail', { data });
|
|
167
|
|
- // if (res.status == 200) {
|
|
168
|
|
- // // 根据类型设置不同的日期字段
|
|
169
|
|
- // if (res.data.rawType === 'daily' || res.data.type === '日报') {
|
|
170
|
|
- // this.setData({
|
|
171
|
|
- // title: res.data.title,
|
|
172
|
|
- // date: res.data.date,
|
|
173
|
|
- // content: res.data.content,
|
|
174
|
|
- // submitter: res.data.submitter,
|
|
175
|
|
- // reportType: 'daily'
|
|
176
|
|
- // });
|
|
177
|
|
- // } else if (res.data.rawType === 'weekly' || res.data.type === '周报') {
|
|
178
|
|
- // // 处理周报的日期范围
|
|
179
|
|
- // let weekStartDate = '';
|
|
180
|
|
- // let weekEndDate = '';
|
|
181
|
|
- // if (res.data.weekStartDate && res.data.weekEndDate) {
|
|
182
|
|
- // weekStartDate = res.data.weekStartDate;
|
|
183
|
|
- // weekEndDate = res.data.weekEndDate;
|
|
184
|
|
- // } else if (res.data.date && res.data.date.includes('至')) {
|
|
185
|
|
- // const dateParts = res.data.date.split('至');
|
|
186
|
|
- // weekStartDate = dateParts[0];
|
|
187
|
|
- // weekEndDate = dateParts[1];
|
|
188
|
|
- // }
|
|
189
|
|
- // this.setData({
|
|
190
|
|
- // title: res.data.title,
|
|
191
|
|
- // weekStartDate: weekStartDate,
|
|
192
|
|
- // weekEndDate: weekEndDate,
|
|
193
|
|
- // content: res.data.content,
|
|
194
|
|
- // submitter: res.data.submitter,
|
|
195
|
|
- // reportType: 'weekly'
|
|
196
|
|
- // });
|
|
197
|
|
- // }
|
|
198
|
|
- // }
|
|
199
|
|
-
|
|
200
|
|
- // 模拟数据 - 处理类型数据
|
|
201
|
|
- setTimeout(() => {
|
|
202
|
|
- const isDaily = this.data.type === 0;
|
|
203
|
|
- const reportDetail = {
|
|
204
|
|
- id: this.data.id,
|
|
205
|
|
- title: isDaily ? '编辑日报标题' : '编辑周报标题',
|
|
206
|
|
- content: '这是编辑中的内容...',
|
|
207
|
|
- date: isDaily ? '2024-01-20' : '2024-01-15至2024-01-21',
|
|
208
|
|
- submitter: '张三',
|
|
209
|
|
- type: isDaily ? 'daily' : 'weekly', // 原始类型标识
|
|
210
|
|
- displayDate: isDaily ? '2024-01-20' : '2024-01-15至2024-01-21'
|
|
211
|
|
- };
|
|
|
222
|
+ // 对接获取详情接口 - GET请求
|
|
|
223
|
+ let res = await app.sendRequest('get', `/t-work-report/${this.data.id}`, {});
|
|
|
224
|
+
|
|
|
225
|
+ if (res.status == 200) {
|
|
|
226
|
+ const reportDetail = res.data;
|
|
|
227
|
+
|
|
|
228
|
+ // 处理工作内容(可能是JSON字符串)
|
|
|
229
|
+ let workContent = reportDetail.workContent;
|
|
|
230
|
+ try {
|
|
|
231
|
+ if (typeof workContent === 'string') {
|
|
|
232
|
+ workContent = JSON.parse(workContent);
|
|
|
233
|
+ }
|
|
|
234
|
+ if (!Array.isArray(workContent)) {
|
|
|
235
|
+ workContent = [{
|
|
|
236
|
+ content: '',
|
|
|
237
|
+ location: '',
|
|
|
238
|
+ completion: '',
|
|
|
239
|
+ remark: ''
|
|
|
240
|
+ }];
|
|
|
241
|
+ }
|
|
|
242
|
+ } catch (error) {
|
|
|
243
|
+ console.log('解析工作内容失败', error);
|
|
|
244
|
+ workContent = [{
|
|
|
245
|
+ content: '',
|
|
|
246
|
+ location: '',
|
|
|
247
|
+ completion: '',
|
|
|
248
|
+ remark: ''
|
|
|
249
|
+ }];
|
|
|
250
|
+ }
|
|
|
251
|
+
|
|
|
252
|
+ // 处理日期格式
|
|
|
253
|
+ let workStartTime = reportDetail.workStartTime;
|
|
|
254
|
+ let workEndTime = reportDetail.workEndTime;
|
|
|
255
|
+ if (workStartTime && workStartTime.includes(' ')) {
|
|
|
256
|
+ workStartTime = workStartTime.split(' ')[0];
|
|
|
257
|
+ }
|
|
|
258
|
+ if (workEndTime && workEndTime.includes(' ')) {
|
|
|
259
|
+ workEndTime = workEndTime.split(' ')[0];
|
|
|
260
|
+ }
|
|
212
|
261
|
|
|
213
|
262
|
this.setData({
|
|
214
|
263
|
title: reportDetail.title,
|
|
215
|
|
- content: reportDetail.content,
|
|
216
|
|
- date: reportDetail.date,
|
|
217
|
|
- submitter: reportDetail.submitter,
|
|
218
|
|
- // 添加类型标识
|
|
219
|
|
- rawType: reportDetail.type
|
|
|
264
|
+ team: reportDetail.team || '',
|
|
|
265
|
+ number: reportDetail.number ? String(reportDetail.number) : '',
|
|
|
266
|
+ type: reportDetail.type ? String(reportDetail.type) : '1',
|
|
|
267
|
+ workStartTime: workStartTime || '',
|
|
|
268
|
+ workEndTime: workEndTime || '',
|
|
|
269
|
+ workContent: workContent,
|
|
|
270
|
+ unfinishedWork: reportDetail.unfinishedWork || '',
|
|
|
271
|
+ submitter: reportDetail.submitter || '当前用户'
|
|
220
|
272
|
});
|
|
221
|
|
- }, 500);
|
|
|
273
|
+ }
|
|
222
|
274
|
} catch (error) {
|
|
223
|
275
|
console.log('获取详情失败', error);
|
|
|
276
|
+ wx.showToast({ title: '获取详情失败', icon: 'none' });
|
|
224
|
277
|
}
|
|
225
|
278
|
},
|
|
226
|
279
|
|
|
|
@@ -228,30 +281,41 @@ Page({
|
|
228
|
281
|
* 生命周期函数--监听页面加载
|
|
229
|
282
|
*/
|
|
230
|
283
|
onLoad: function(options) {
|
|
|
284
|
+ // 判断页面模式
|
|
|
285
|
+ if (options.view === 'true') {
|
|
|
286
|
+ this.setData({ pageMode: 'view' });
|
|
|
287
|
+ // 设置导航栏标题为查看模式
|
|
|
288
|
+ wx.setNavigationBarTitle({
|
|
|
289
|
+ title: '报表详情'
|
|
|
290
|
+ });
|
|
|
291
|
+ }
|
|
|
292
|
+
|
|
231
|
293
|
// 如果从列表页传入了类型参数,使用传入的类型
|
|
232
|
294
|
if (options.type !== undefined) {
|
|
233
|
|
- // 设置报表类型(daily或weekly)
|
|
234
|
295
|
this.setData({
|
|
235
|
|
- reportType: options.type === '1' || options.type === 'weekly' ? 'weekly' : 'daily'
|
|
|
296
|
+ type: options.type
|
|
236
|
297
|
});
|
|
237
|
|
- // 设置页面标题
|
|
238
|
|
- wx.setNavigationBarTitle({
|
|
239
|
|
- title: this.data.reportType === 'daily' ? '新增日报' : '新增周报'
|
|
240
|
|
- });
|
|
241
|
|
- } else {
|
|
242
|
|
- // 默认设置为日报
|
|
243
|
|
- this.setData({ reportType: 'daily' });
|
|
244
|
298
|
}
|
|
245
|
299
|
|
|
246
|
300
|
if (options.id) {
|
|
247
|
301
|
this.setData({
|
|
248
|
302
|
id: options.id
|
|
249
|
303
|
});
|
|
250
|
|
- wx.setNavigationBarTitle({
|
|
251
|
|
- title: '编辑报表'
|
|
252
|
|
- });
|
|
|
304
|
+
|
|
|
305
|
+ // 如果不是查看模式,则设置为编辑模式
|
|
|
306
|
+ if (this.data.pageMode !== 'view') {
|
|
|
307
|
+ wx.setNavigationBarTitle({
|
|
|
308
|
+ title: '编辑报表'
|
|
|
309
|
+ });
|
|
|
310
|
+ }
|
|
|
311
|
+
|
|
253
|
312
|
this.getReportDetail();
|
|
254
|
313
|
} else {
|
|
|
314
|
+ // 设置页面标题
|
|
|
315
|
+ wx.setNavigationBarTitle({
|
|
|
316
|
+ title: '新增工作报表'
|
|
|
317
|
+ });
|
|
|
318
|
+
|
|
255
|
319
|
// 新增时自动设置当前日期
|
|
256
|
320
|
const now = new Date();
|
|
257
|
321
|
const year = now.getFullYear();
|
|
|
@@ -259,17 +323,10 @@ Page({
|
|
259
|
323
|
const day = now.getDate().toString().padStart(2, '0');
|
|
260
|
324
|
const today = `${year}-${month}-${day}`;
|
|
261
|
325
|
|
|
262
|
|
- // 根据类型设置不同的日期字段
|
|
263
|
|
- if (this.data.reportType === 'daily') {
|
|
264
|
|
- this.setData({ date: today });
|
|
265
|
|
- } else {
|
|
266
|
|
- // 计算本周结束日期
|
|
267
|
|
- const endDay = Math.min(day + 6, new Date(year, month, 0).getDate());
|
|
268
|
|
- this.setData({
|
|
269
|
|
- weekStartDate: today,
|
|
270
|
|
- weekEndDate: `${year}-${month}-${endDay.toString().padStart(2, '0')}`
|
|
271
|
|
- });
|
|
272
|
|
- }
|
|
|
326
|
+ this.setData({
|
|
|
327
|
+ workStartTime: today,
|
|
|
328
|
+ workEndTime: today
|
|
|
329
|
+ });
|
|
273
|
330
|
}
|
|
274
|
331
|
}
|
|
275
|
332
|
});
|