Blame view

src/views/admin/device/index.vue 13.6 KB
77ebf04d   梁保满   个人版
1
2
3
4
5
6
7
8
9
10
11
12
  <template>
    <div ref="main" class="page-content">
      <back-box>
        <template slot="title">
          <span>设备管理</span>
        </template>
      </back-box>
      <div>
        <div class="tab-box">
          <el-radio-group v-model="type">
            <el-radio-button :label="1">基站管理</el-radio-button>
            <el-radio-button :label="2">答题器管理</el-radio-button>
77ebf04d   梁保满   个人版
13
14
15
16
17
18
19
20
21
22
          </el-radio-group>
        </div>
        <div class="content">
          <div v-show="type == 1">
            <div class="chart-box" v-if="count">
              <div class="device-num">
                <p class="p1">{{ count }}</p>
                <p class="p2">基站数量</p>
              </div>
              <div class="chart">
c2460294   梁保满   平台管理员接口联调
23
                <pie-chart id="pieChart" :params="chartData"></pie-chart>
77ebf04d   梁保满   个人版
24
25
26
27
28
              </div>
            </div>
            <div class="table-box">
              <div class="answer-header">
                <div class="sel-box">
c2460294   梁保满   平台管理员接口联调
29
30
31
32
33
                  <el-input
                    placeholder="请输入租户"
                    v-model="query.schoolName"
                    class="input-with-select"
                    @keyup.enter.native="_QueryData(true)"
77ebf04d   梁保满   个人版
34
                  >
c2460294   梁保满   平台管理员接口联调
35
36
37
38
39
40
                    <el-button
                      slot="append"
                      icon="el-icon-search"
                      @click="_QueryData(true)"
                    ></el-button>
                  </el-input>
77ebf04d   梁保满   个人版
41
                  <el-input
21dfdeae   梁保满   平台管理员
42
                    placeholder="请输入租户"
77ebf04d   梁保满   个人版
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
                    v-model="query.sn"
                    class="input-with-select"
                    @keyup.enter.native="_QueryData(true)"
                  >
                    <el-button
                      slot="append"
                      icon="el-icon-search"
                      @click="_QueryData(true)"
                    ></el-button>
                  </el-input>
                  <el-button class="serach-box" round @click="_QueryData(true)"
                    >筛选</el-button
                  >
                </div>
              </div>
              <el-table :data="tableData" border style="width: 100%">
                <el-table-column
                  prop="sn"
                  label="设备编码"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="frequency"
                  label="频点"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="pairingCode"
                  label="配对码"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="roomName"
                  label="所在教室"
                  align="center"
                ></el-table-column>
                <el-table-column label="关联班级" align="center">
                  <template slot-scope="scoped">
                    <p v-for="(item, index) in scoped.row.classList" :key="index">
                      {{ item.className }}
                    </p>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="otaVersionName"
                  label="固件版本号"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="onlineTime"
                  label="最近上报"
                  align="center"
                ></el-table-column>
                <el-table-column label="状态" align="center"
                  ><template slot-scope="scope">
                    {{
                      scope.row.onlineStatus == 1
                        ? "在线"
                        : scope.row.onlineStatus == 2
                        ? "异常"
                        : "离线"
                    }}
                  </template></el-table-column
                >
                <el-table-column label="操作" align="center"
                  ><template slot-scope="scoped">
                    <el-tooltip effect="dark" content="日志" placement="top">
                      <el-button
                        type="warning"
                        circle
                        size="mini"
                        icon="fa fa-eye"
                        @click="linkTo(scoped.row, 1)"
                      ></el-button>
                    </el-tooltip> </template
                ></el-table-column>
              </el-table>
            </div>
          </div>
          <div v-show="type == 2">
            <div class="chart-box" v-if="count">
              <div class="device-num">
                <p class="p1">{{ count }}</p>
                <p class="p2">答题器数量</p>
              </div>
              <div class="chart">
                <scatter-chart
                  id="scatterChart"
                  :params="chartData2"
77ebf04d   梁保满   个人版
132
133
134
135
136
137
                ></scatter-chart>
              </div>
            </div>
            <div class="table-box">
              <div class="answer-header">
                <div class="sel-box">
c2460294   梁保满   平台管理员接口联调
138
                  <el-select
77ebf04d   梁保满   个人版
139
                    class="sel"
21dfdeae   梁保满   平台管理员
140
141
                    v-model="query.school"
                    placeholder="选择学校"
77ebf04d   梁保满   个人版
142
143
144
                    @change="_QueryData(true)"
                  >
                    <el-option
21dfdeae   梁保满   平台管理员
145
                      v-for="item in schoolList"
77ebf04d   梁保满   个人版
146
147
148
149
150
151
152
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                  <el-input
21dfdeae   梁保满   平台管理员
153
                    placeholder="请输入租户"
77ebf04d   梁保满   个人版
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
                    v-model="query.sn"
                    class="input-with-select"
                    @keyup.enter.native="_QueryData(true)"
                  >
                    <el-button
                      slot="append"
                      icon="el-icon-search"
                      @click="_QueryData(true)"
                    ></el-button>
                  </el-input>
                  <el-button class="serach-box" round @click="_QueryData(true)"
                    >筛选</el-button
                  >
                </div>
              </div>
              <el-table :data="tableData" border style="width: 100%">
                <el-table-column
                  prop="sn"
                  label="设备编码"
                  align="center"
                ></el-table-column>
                <el-table-column label="学生信息" align="center"
                  ><template slot-scope="scoped"
                    ><p
                      v-for="(item, index) in scoped.row.studentList"
                      :key="index"
                    >
                      {{ item.studentName }}
                    </p></template
                  ></el-table-column
                >
                <el-table-column
                  prop="electricity"
                  label="电量"
                  align="center"
                ></el-table-column>
                <el-table-column prop="class" label="关联班级" align="center">
                  <template slot-scope="scoped">
                    <p v-for="(item, index) in scoped.row.classList" :key="index">
                      {{ item.className }}
                    </p>
                  </template></el-table-column
                >
                <el-table-column
                  prop="pairingCode"
                  label="配对码"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="answerTimes"
                  label="答题次数"
                  align="center"
                ></el-table-column>
                <el-table-column
                  prop="latestReportTime"
                  label="最后答题时间"
                  align="center"
                ></el-table-column>
                <el-table-column label="操作" align="center"
                  ><template slot-scope="scoped">
                    <el-tooltip effect="dark" content="日志" placement="top">
                      <el-button
                        type="warning"
                        circle
                        size="mini"
                        icon="fa fa-eye"
                        @click="linkTo(scoped.row, 2)"
                      ></el-button>
                    </el-tooltip> </template
                ></el-table-column>
              </el-table>
            </div>
          </div>
          <div class="pagination-box">
            <el-pagination
              small=""
              layout="total,prev, pager, next"
              :hide-on-single-page="true"
              :total="total"
              @current-change="changePage"
              :current-page="page"
              :page-size="size"
            >
            </el-pagination>
          </div>
        </div>
      </div>
77ebf04d   梁保满   个人版
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
    </div>
  </template>
  
  <script>
  import pieChart from "@/components/charts/pieChart";
  import scatterChart from "@/components/charts/scatterChart";
  import _ from "lodash";
  import { downloadFile, getBlob, formatGradeNameClass } from "@/utils";
  import api from "@/api/apis/apis";
  import BusEvent from "@/utils/busEvent";
  export default {
    components: { pieChart, scatterChart },
    watch: {
      type: function (val) {
        this.page = 1;
        this.total = 0;
        this.count = 0;
77ebf04d   梁保满   个人版
258
        this.query.onlineStatus = "";
c2460294   梁保满   平台管理员接口联调
259
260
        this.query.schoolName = "";
        this.query.loginName = "";
77ebf04d   梁保满   个人版
261
262
263
264
265
266
267
268
269
270
271
272
        if (val == 1) {
          this.stationReport();
        } else if (val == 2) {
          this.keyboardReport();
        }
        this._QueryData();
      },
    },
    data() {
      return {
        code: "",
        loading: false,
21dfdeae   梁保满   平台管理员
273
        schoolList: [],
77ebf04d   梁保满   个人版
274
275
        type: 1,
        query: {
c2460294   梁保满   平台管理员接口联调
276
277
278
          schoolName: "",
          loginName: "",
          onlineStatus: "",
77ebf04d   梁保满   个人版
279
        },
77ebf04d   梁保满   个人版
280
281
282
283
284
285
286
287
288
289
290
        tableData: [],
        total: 0,
        count: 0,
        chartData: [],
        chartData2: [],
        page: 1,
        size: 20,
      };
    },
    created() {
      this.code = localStorage.getItem("csCode") || "";
c2460294   梁保满   平台管理员接口联调
291
292
      this.stationReport();
      this._QueryData();
77ebf04d   梁保满   个人版
293
294
295
296
297
298
299
300
    },
    activated() {
      const that = this;
      BusEvent.$on("keepAlive", async function () {
        that.type = 1;
        that.page = 1;
        that.total = 0;
        that.count = 0;
c2460294   梁保满   平台管理员接口联调
301
302
303
304
        that.query.schoolName = "";
        that.query.loginName = "";
        that.stationReport();
        that._QueryData();
77ebf04d   梁保满   个人版
305
306
307
      });
    },
    methods: {
77ebf04d   梁保满   个人版
308
309
310
311
312
313
314
315
316
      linkTo(obj, type) {
        this.$router.push({
          path: "/deviceLog",
          query: {
            id: obj.id,
            type: type,
          },
        });
      },
77ebf04d   梁保满   个人版
317
318
319
320
      changePage(page) {
        this.page = page;
        this._QueryData(false);
      },
77ebf04d   梁保满   个人版
321
322
      // 基站统计数据
      async stationReport() {
c2460294   梁保满   平台管理员接口联调
323
        const { data, status, info } = await this.$request.pStationReport();
77ebf04d   梁保满   个人版
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
        if (status === 0) {
          this.chartData =
            data.list?.map((item) => {
              return {
                name:
                  item.onlineStatus == "1"
                    ? "在线"
                    : item.onlineStatus == 0
                    ? "离线"
                    : "异常",
                value: item.total,
                rate: item.rate,
              };
            }) || [];
          this.count = data.total || 0;
        } else {
          this.$message.error(info);
        }
      },
      // 答题器统计数据
      async keyboardReport() {
c2460294   梁保满   平台管理员接口联调
345
        const { data, status, info } = await this.$request.pKeyboardReport();
77ebf04d   梁保满   个人版
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
        if (status === 0) {
          this.chartData2 =
            data.list?.map((item) => {
              return {
                name:
                  item.type == 1
                    ? "1日内"
                    : item.type == 2
                    ? "3日内"
                    : item.type == 3
                    ? "7日内"
                    : item.type == 4
                    ? "1月内"
                    : item.type == 5
                    ? "3月内"
                    : "3月以上",
                count: item.total,
                value: item.rate * 100,
              };
            }) || [];
          this.count = data.total || 0;
        } else {
          this.$message.error(info);
        }
      },
77ebf04d   梁保满   个人版
371
372
373
      // 设备列表信息
      async _QueryData(isRef) {
        this.loading = true;
c2460294   梁保满   平台管理员接口联调
374
375
376
377
378
379
380
381
382
383
384
385
        let query = {};
        for (let key in this.query) {
          if (this.query[key]) {
            query[key] = this.query[key];
          }
        }
        if (query.loginName) {
          delete query.schoolName;
          delete query.onlineStatus;
        } else if (query.schoolName) {
          delete query.loginName;
          delete query.onlineStatus;
21dfdeae   梁保满   平台管理员
386
        }
77ebf04d   梁保满   个人版
387
388
389
390
391
        if (isRef) {
          this.page = 1;
        }
        this.loading = true;
        this.tableData = [];
21dfdeae   梁保满   平台管理员
392
        const { data, status, info } = await this.$request.pDeviceList({
77ebf04d   梁保满   个人版
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
          ...query,
          deviceType: this.type,
          page: this.page,
          size: this.size,
        });
        this.loading = false;
        if (status == 0) {
          this.tableData =
            (data?.list &&
              data?.list.map((item) => {
                item.upgradeFlag = item.upgradeFlag == 1 ? true : false;
                return item;
              })) ||
            [];
  
          this.total = data.count;
          this.$nextTick(function () {
            this.$refs.main.scrollTop = 0;
77ebf04d   梁保满   个人版
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
          });
        } else {
          this.$message.error(info);
        }
      },
    },
  };
  </script>
  
  <style lang="scss" scoped>
  .page-content {
    padding: 0 20px;
    height: 100%;
    overflow-y: auto;
  }
  .tab-box {
    padding: 20px 0 12px;
  }
  .content {
    background: #f8f8f8;
77ebf04d   梁保满   个人版
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
    border-radius: 10px;
    overflow: hidden;
    :deep(.fa-edit) {
      width: 12px;
      height: 12px;
      &::before {
        margin-left: 2px;
      }
    }
    :deep(.fa-eye) {
      width: 12px;
      height: 12px;
      &::before {
        margin-left: 1px;
      }
    }
    .chart-box {
      display: flex;
      overflow: hidden;
      height: 240px;
      border-bottom: 0.5px solid #e2e2e2;
      .device-num {
        width: 280px;
        border-right: 0.5px solid #e2e2e2;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        .p1 {
          font-size: 28px;
        }
      }
      .chart {
        flex: 1;
        height: 100%;
      }
    }
    .table-box {
      padding: 20px;
      .answer-header {
        padding: 0;
        margin-bottom: 12px;
      }
    }
  }
  </style>