zhangzengfei
2022-04-01 ba9ecfcb806236b0c544f52c0851ad50a9bcee79
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
import { getAllTimeRule, saveTimeRule } from "@/api/timeRule";
import { findDictionaryByType } from "@/api/dictionary";
import { findBaseByRuleEditor } from "@/api/es";
 
const AllDayRule = [
  { day: 1, time_range: [{ start: "00:00", end: "24:00" }] },
  { day: 2, time_range: [{ start: "00:00", end: "24:00" }] },
  { day: 3, time_range: [{ start: "00:00", end: "24:00" }] },
  { day: 4, time_range: [{ start: "00:00", end: "24:00" }] },
  { day: 5, time_range: [{ start: "00:00", end: "24:00" }] },
  { day: 6, time_range: [{ start: "00:00", end: "24:00" }] },
  { day: 7, time_range: [{ start: "00:00", end: "24:00" }] }
]
 
export default class VideoManageData {
  public SepTasks: Array<object> = [];
  public TimeRules: Array<object> = [];
  public Dictionary: object = {};
  public TagList: Array<object> = [];
  public TimeRuleSum: number = 0;
 
  public init() {
    // this.getAllSeparateTasks();
    this.getTimeRule();
    this.getDictionary();
    this.getTagList();
  }
 
  public async getTimeRule() {
    let rsp: any = await getAllTimeRule();
    if (rsp && rsp.success) {
      this.TimeRules = rsp.data;
      this.TimeRuleSum = rsp.data.length
    }
 
    // 添加一条默认规则
    if (this.TimeRuleSum < 1) {
      let newRule = {
        id: "",
        name: "全天",
        time_rule: AllDayRule
      };
 
      rsp = await saveTimeRule(newRule)
      if (rsp && rsp.success) {
        this.getTimeRule();
      }
    }
  }
 
  public async getDictionary() {
    const rsp: any = await findDictionaryByType();
    if (rsp && rsp.success) {
      this.Dictionary = rsp.data;
    }
  }
 
  public async getTagList() {
    const rsp: any = await findBaseByRuleEditor();
    if (rsp && rsp.success) {
      this.TagList = rsp.data;
    }
  }
}