|
@@ -1,11 +1,17 @@
|
1
|
1
|
import { Component, OnInit, ViewChild } from "@angular/core";
|
2
|
2
|
import { ActivatedRoute } from "@angular/router";
|
3
|
|
-import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
|
3
|
+import {
|
|
4
|
+ FormBuilder,
|
|
5
|
+ Validators,
|
|
6
|
+ FormGroup,
|
|
7
|
+ FormControl,
|
|
8
|
+} from "@angular/forms";
|
4
|
9
|
|
5
|
10
|
import { MainService } from "../../services/main.service";
|
6
|
11
|
import { OverlayScrollbarsComponent } from "overlayscrollbars-ngx";
|
7
|
12
|
import { ToolService } from "../../services/tool.service";
|
8
|
13
|
import { NzMessageService } from "ng-zorro-antd";
|
|
14
|
+import { format } from "date-fns";
|
9
|
15
|
@Component({
|
10
|
16
|
selector: "app-timing-message-sending",
|
11
|
17
|
templateUrl: "./timing-message-sending.component.html",
|
|
@@ -141,6 +147,18 @@ export class TimingMessageSendingComponent implements OnInit {
|
141
|
147
|
if (data.status == 200) {
|
142
|
148
|
this.listOfData = data.list;
|
143
|
149
|
this.listOfData.forEach((item) => {
|
|
150
|
+ if (item.timeStep == "week") {
|
|
151
|
+ let weeks = [
|
|
152
|
+ "周一",
|
|
153
|
+ "周二",
|
|
154
|
+ "周三",
|
|
155
|
+ "周四",
|
|
156
|
+ "周五",
|
|
157
|
+ "周六",
|
|
158
|
+ "周日",
|
|
159
|
+ ];
|
|
160
|
+ item.weekName = weeks[item.extra1 - 1];
|
|
161
|
+ }
|
144
|
162
|
item.usersName = item.users.map((value) => value.name).join();
|
145
|
163
|
});
|
146
|
164
|
this.listLength = data.totalNum;
|
|
@@ -156,12 +174,47 @@ export class TimingMessageSendingComponent implements OnInit {
|
156
|
174
|
initForm() {
|
157
|
175
|
this.validateForm = this.fb.group({
|
158
|
176
|
title: [null, [Validators.required]], //标题
|
159
|
|
- xxx: [1, [Validators.required]], //重复策略
|
|
177
|
+ timeStep: ["day", [Validators.required]], //重复策略
|
160
|
178
|
executeTime: [null, [Validators.required]], //定时发送时间
|
161
|
179
|
active: [false, [Validators.required]], //是否启用
|
162
|
180
|
userIds: [null, [Validators.required]], //接收人
|
163
|
181
|
});
|
164
|
182
|
}
|
|
183
|
+ //修改重复策略
|
|
184
|
+ months = [...Array(32).keys()].slice(1);
|
|
185
|
+ timeStepChange(e) {
|
|
186
|
+ switch (e) {
|
|
187
|
+ case "day":
|
|
188
|
+ this.validateForm.removeControl("doWeek");
|
|
189
|
+ this.validateForm.removeControl("doMonth");
|
|
190
|
+ this.validateForm.removeControl("doYear");
|
|
191
|
+ break;
|
|
192
|
+ case "week":
|
|
193
|
+ this.validateForm.addControl(
|
|
194
|
+ "doWeek",
|
|
195
|
+ new FormControl(null, Validators.required)
|
|
196
|
+ );
|
|
197
|
+ this.validateForm.removeControl("doMonth");
|
|
198
|
+ this.validateForm.removeControl("doYear");
|
|
199
|
+ break;
|
|
200
|
+ case "month":
|
|
201
|
+ this.validateForm.addControl(
|
|
202
|
+ "doMonth",
|
|
203
|
+ new FormControl(null, Validators.required)
|
|
204
|
+ );
|
|
205
|
+ this.validateForm.removeControl("doWeek");
|
|
206
|
+ this.validateForm.removeControl("doYear");
|
|
207
|
+ break;
|
|
208
|
+ case "year":
|
|
209
|
+ this.validateForm.addControl(
|
|
210
|
+ "doYear",
|
|
211
|
+ new FormControl(null, Validators.required)
|
|
212
|
+ );
|
|
213
|
+ this.validateForm.removeControl("doWeek");
|
|
214
|
+ this.validateForm.removeControl("doMonth");
|
|
215
|
+ break;
|
|
216
|
+ }
|
|
217
|
+ }
|
165
|
218
|
|
166
|
219
|
// 表单提交
|
167
|
220
|
submitForm(): void {
|
|
@@ -174,7 +227,7 @@ export class TimingMessageSendingComponent implements OnInit {
|
174
|
227
|
this.btnLoading = false;
|
175
|
228
|
return;
|
176
|
229
|
}
|
177
|
|
- let postData = {
|
|
230
|
+ let postData: any = {
|
178
|
231
|
title: this.validateForm.value.title,
|
179
|
232
|
executeTime: new Date(this.validateForm.value.executeTime).getTime(),
|
180
|
233
|
userIds: this.validateForm.value.userIds.join(),
|
|
@@ -182,7 +235,22 @@ export class TimingMessageSendingComponent implements OnInit {
|
182
|
235
|
content: this.dataContent.content,
|
183
|
236
|
key: this.dataContent.key,
|
184
|
237
|
id: this.dataContent.id,
|
|
238
|
+ timeStep: this.validateForm.value.timeStep,
|
185
|
239
|
};
|
|
240
|
+ if (this.validateForm.value.timeStep == "day") {
|
|
241
|
+ delete postData.extra1;
|
|
242
|
+ } else if (this.validateForm.value.timeStep == "week") {
|
|
243
|
+ postData.extra1 = this.validateForm.value.doWeek;
|
|
244
|
+ } else if (this.validateForm.value.timeStep == "month") {
|
|
245
|
+ postData.extra1 = this.validateForm.value.doMonth;
|
|
246
|
+ } else if (this.validateForm.value.timeStep == "year") {
|
|
247
|
+ delete postData.extra1;
|
|
248
|
+ postData.executeTime = new Date(
|
|
249
|
+ format(this.validateForm.value.doYear, "yyyy-MM-dd") +
|
|
250
|
+ " " +
|
|
251
|
+ format(new Date(this.validateForm.value.executeTime), "HH:mm:ss")
|
|
252
|
+ ).getTime();
|
|
253
|
+ }
|
186
|
254
|
this.mainService
|
187
|
255
|
.simplePost("updData", "messageJob", postData)
|
188
|
256
|
.subscribe((data) => {
|
|
@@ -205,6 +273,17 @@ export class TimingMessageSendingComponent implements OnInit {
|
205
|
273
|
this.validateForm.controls.executeTime.setValue(new Date(data.executeTime)); //定时发送时间
|
206
|
274
|
this.validateForm.controls.title.setValue(data.title); //标题
|
207
|
275
|
this.validateForm.controls.active.setValue(data.active); //是否启用
|
|
276
|
+ this.timeStepChange(data.timeStep);
|
|
277
|
+ this.validateForm.controls.timeStep.setValue(data.timeStep); //重复策略
|
|
278
|
+ if (data.timeStep == "year") {
|
|
279
|
+ this.validateForm.controls.doYear.setValue(
|
|
280
|
+ format(data.executeTime, "yyyy-MM-dd HH:mm:ss")
|
|
281
|
+ );
|
|
282
|
+ } else if (data.timeStep == "month") {
|
|
283
|
+ this.validateForm.controls.doMonth.setValue(data.extra1);
|
|
284
|
+ } else if (data.timeStep == "week") {
|
|
285
|
+ this.validateForm.controls.doWeek.setValue(data.extra1);
|
|
286
|
+ }
|
208
|
287
|
// --------接收人---
|
209
|
288
|
this.maskFlag = this.message.loading("正在加载中..", {
|
210
|
289
|
nzDuration: 0,
|