Blame view

src/views/device/log.vue 5.35 KB
db11048f   阿宝   设备状态,学校管理
1
2
3
4
5
6
  <template>
    <div>
      <back-box>
        <template slot="title">
          <span>设备日志</span>
        </template>
db11048f   阿宝   设备状态,学校管理
7
      </back-box>
23a6dc5f   阿宝   学校管理相关接口简单对接
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
      <div class="page-content">
        <el-descriptions :column="3" border>
          <el-descriptions-item label="设备编码"
            >kooriookami</el-descriptions-item
          >
          <el-descriptions-item label="电量">18100000000</el-descriptions-item>
          <el-descriptions-item label="配对码">苏州市</el-descriptions-item>
          <el-descriptions-item label="关联班级"
            >江苏省苏州市吴中区</el-descriptions-item
          >
          <el-descriptions-item label="最后答题时间"
            >江苏省苏州市吴中区</el-descriptions-item
          >
          <el-descriptions-item label="答题次数"
            >江苏省苏州市吴中区</el-descriptions-item
          >
        </el-descriptions>
      </div>
      <div class="answer-header">
        <div class="sel-box">
          <div class="d1">
            <el-date-picker
              v-model="query.startDay"
              type="date"
              @change="handleChangeTimeStart"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
            ~
            <el-date-picker
              v-model="query.endDay"
              type="date"
              placeholder="选择日期时间"
              @change="handleChangeTimeEnd"
              value-format="yyyy-MM-dd"
            >
            </el-date-picker>
          </div>
          <p class="p1">
            <span @click="setDate(1)" :class="[date == 1 ? 'active' : '', 's1']"
              >今天</span
            >
            <span @click="setDate(2)" :class="[date == 2 ? 'active' : '', 's1']"
              >本周</span
            >
            <span @click="setDate(3)" :class="[date == 3 ? 'active' : '', 's1']"
              >本月</span
            >
            <span @click="setDate(4)" :class="[date == 4 ? 'active' : '', 's1']"
              >本季度</span
            >
          </p>
        </div>
      </div>
db11048f   阿宝   设备状态,学校管理
63
64
65
66
    </div>
  </template>
  
  <script>
23a6dc5f   阿宝   学校管理相关接口简单对接
67
  import { formatDate } from "utils";
db11048f   阿宝   设备状态,学校管理
68
69
70
  export default {
    data() {
      return {
23a6dc5f   阿宝   学校管理相关接口简单对接
71
72
73
74
75
76
77
78
        id:'',
        date: "", //今天-昨天-本周
        query: {
          //搜索条件
          startDay: "",
          endDay: "",
          day: "",
        },
db11048f   阿宝   设备状态,学校管理
79
80
      };
    },
23a6dc5f   阿宝   学校管理相关接口简单对接
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
    created() {
      this.id = this.$route.query.id
      // await this.setDate(1);
      let startDay = this.query?.startDay;
      if (!startDay) {
        this.query.startDay = new Date();
        this.query.endDay = new Date();
      }
    },
    methods: {
      setDate(index) {
        const that = this;
        this.date = index == this.date ? "" : index;
        let aYear = new Date().getFullYear();
        let aMonth = new Date().getMonth() + 1;
        that.query.day = "";
        that.query.startDay = "";
        that.query.endDay = "";
        switch (index) {
          case 1:
            that.query.day = formatDate(new Date(), "yyyy-MM-dd");
            that.query.startDay = that.query.day;
            that.query.endDay = that.query.day;
            break;
          case 2:
            let day = new Date().getDay();
            if (day == 0) {
              //中国式星期天是一周的最后一天
              day = 7;
            }
            let aTime = new Date().getTime() - 24 * 60 * 60 * 1000 * day;
            that.query.startDay = formatDate(new Date(aTime), "yyyy-MM-dd");
            that.query.endDay = formatDate(new Date(), "yyyy-MM-dd");
            break;
          case 3:
            aMonth = aMonth < 10 ? "0" + aMonth : aMonth;
            that.query.startDay = `${aYear}-${aMonth}-01`;
            that.query.endDay = formatDate(new Date(), "yyyy-MM-dd");
            break;
          case 4:
            if (aMonth > 1 && aMonth < 4) {
              aMonth = "01";
            } else if (aMonth > 3 && aMonth < 7) {
              aMonth = "04";
            } else if (aMonth > 6 && aMonth < 10) {
              aMonth = "07";
            } else {
              aMonth = "10";
            }
  
            aMonth = aMonth < 10 ? "0" + aMonth : aMonth;
            that.query.startDay = `${aYear}-${aMonth}-01`;
            that.query.endDay = formatDate(new Date(), "yyyy-MM-dd");
            break;
        }
        this.page = 1;
        this._QueryData();
      },
      handleChangeTimeStart(val) {
        this.query.day = "";
        this.date = "";
        if (this.query.endDay) {
          if (new Date(val).getTime() > new Date(this.query.endDay).getTime()) {
            this.$message.error("任务结束时间不能任务开始时间前面,请重新设置");
            this.query.startDay = "";
          }
        }
      },
      handleChangeTimeEnd(val) {
        this.query.day = "";
        this.date = "";
        if (this.query.startDay) {
          if (new Date(val).getTime() < new Date(this.query.startDay).getTime()) {
            this.$message.error("任务结束时间不能任务开始时间前面,请重新设置");
            this.query.endDay = "";
          }
        }
      },
      async _QueryData() {
        this.loading = true;
        //多课时对比
        let query = {};
        for (let key in this.query) {
          if (this.query[key] != "") {
            query[key] = this.query[key];
          }
        }
        const { data, status, info } = await this.$request.fetchQuizList({
          ...query,
          id:this.id
        });
        this.loading = false;
        if (status === 0) {
        } else {
          this.$message.error(info);
        }
      },
    },
db11048f   阿宝   设备状态,学校管理
179
180
181
  };
  </script>
  
23a6dc5f   阿宝   学校管理相关接口简单对接
182
183
184
185
  <style lang="scss" scoped>
  .page-content {
    padding: 20px;
  }
db11048f   阿宝   设备状态,学校管理
186
  </style>