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
                  <el-input
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
30
                    placeholder="请输入学校"
c2460294   梁保满   平台管理员接口联调
31
32
                    v-model="query.schoolName"
                    class="input-with-select"
34b574e0   梁保满   细节优化
33
                    @keyup.enter.native="query.loginName='',query.realName='',QueryData(true)"
77ebf04d   梁保满   个人版
34
                  >
c2460294   梁保满   平台管理员接口联调
35
36
37
                    <el-button
                      slot="append"
                      icon="el-icon-search"
34b574e0   梁保满   细节优化
38
                      @click="query.loginName='',query.realName='',_QueryData(true)"
c2460294   梁保满   平台管理员接口联调
39
40
                    ></el-button>
                  </el-input>
77ebf04d   梁保满   个人版
41
                  <el-input
34b574e0   梁保满   细节优化
42
                    placeholder="请输入租户账号"
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
43
                    v-model="query.loginName"
77ebf04d   梁保满   个人版
44
                    class="input-with-select"
34b574e0   梁保满   细节优化
45
                    @keyup.enter.native="query.schoolName='',query.realName='',_QueryData(true)"
77ebf04d   梁保满   个人版
46
47
48
49
                  >
                    <el-button
                      slot="append"
                      icon="el-icon-search"
34b574e0   梁保满   细节优化
50
51
52
53
54
55
56
57
58
59
60
61
62
                      @click="query.schoolName='',query.realName='',_QueryData(true)"
                    ></el-button>
                  </el-input>
                  <el-input
                    placeholder="请输入租户名称"
                    v-model="query.realName"
                    class="input-with-select"
                    @keyup.enter.native="query.schoolName='',query.loginName='',_QueryData(true)"
                  >
                    <el-button
                      slot="append"
                      icon="el-icon-search"
                      @click="query.schoolName='',query.loginName='',_QueryData(true)"
77ebf04d   梁保满   个人版
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
                    ></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
34b574e0   梁保满   细节优化
87
88
                  prop="tenantName"
                  label="所在学校"
77ebf04d   梁保满   个人版
89
90
                  align="center"
                ></el-table-column>
77ebf04d   梁保满   个人版
91
92
93
94
95
96
                <el-table-column
                  prop="otaVersionName"
                  label="固件版本号"
                  align="center"
                ></el-table-column>
                <el-table-column
34b574e0   梁保满   细节优化
97
98
                  prop="contactPerson"
                  label="联系人"
77ebf04d   梁保满   个人版
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
                  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   梁保满   个人版
137
138
139
140
141
142
                ></scatter-chart>
              </div>
            </div>
            <div class="table-box">
              <div class="answer-header">
                <div class="sel-box">
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
143
144
145
146
147
                  <el-input
                    placeholder="请输入学校"
                    v-model="query.schoolName"
                    class="input-with-select"
                    @keyup.enter.native="query.loginName='',_QueryData(true)"
77ebf04d   梁保满   个人版
148
                  >
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
149
150
151
152
153
154
                    <el-button
                      slot="append"
                      icon="el-icon-search"
                      @click="query.loginName='',_QueryData(true)"
                    ></el-button>
                  </el-input>
77ebf04d   梁保满   个人版
155
                  <el-input
21dfdeae   梁保满   平台管理员
156
                    placeholder="请输入租户"
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
157
                    v-model="query.loginName"
77ebf04d   梁保满   个人版
158
                    class="input-with-select"
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
159
                    @keyup.enter.native="query.schoolName='',_QueryData(true)"
77ebf04d   梁保满   个人版
160
161
162
163
                  >
                    <el-button
                      slot="append"
                      icon="el-icon-search"
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
164
                      @click="query.schoolName='',_QueryData(true)"
77ebf04d   梁保满   个人版
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
                    ></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
                >
77ebf04d   梁保满   个人版
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
                <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   梁保满   个人版
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
    </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;
c2460294   梁保满   平台管理员接口联调
256
257
        this.query.schoolName = "";
        this.query.loginName = "";
77ebf04d   梁保满   个人版
258
259
260
261
262
263
264
265
266
267
268
269
        if (val == 1) {
          this.stationReport();
        } else if (val == 2) {
          this.keyboardReport();
        }
        this._QueryData();
      },
    },
    data() {
      return {
        code: "",
        loading: false,
21dfdeae   梁保满   平台管理员
270
        schoolList: [],
77ebf04d   梁保满   个人版
271
272
        type: 1,
        query: {
c2460294   梁保满   平台管理员接口联调
273
274
          schoolName: "",
          loginName: "",
34b574e0   梁保满   细节优化
275
  
77ebf04d   梁保满   个人版
276
        },
77ebf04d   梁保满   个人版
277
278
279
280
281
282
283
284
285
286
287
        tableData: [],
        total: 0,
        count: 0,
        chartData: [],
        chartData2: [],
        page: 1,
        size: 20,
      };
    },
    created() {
      this.code = localStorage.getItem("csCode") || "";
c2460294   梁保满   平台管理员接口联调
288
289
      this.stationReport();
      this._QueryData();
77ebf04d   梁保满   个人版
290
291
292
293
294
295
296
297
    },
    activated() {
      const that = this;
      BusEvent.$on("keepAlive", async function () {
        that.type = 1;
        that.page = 1;
        that.total = 0;
        that.count = 0;
c2460294   梁保满   平台管理员接口联调
298
299
300
301
        that.query.schoolName = "";
        that.query.loginName = "";
        that.stationReport();
        that._QueryData();
77ebf04d   梁保满   个人版
302
303
304
      });
    },
    methods: {
77ebf04d   梁保满   个人版
305
306
307
308
309
310
311
312
313
      linkTo(obj, type) {
        this.$router.push({
          path: "/deviceLog",
          query: {
            id: obj.id,
            type: type,
          },
        });
      },
77ebf04d   梁保满   个人版
314
315
316
317
      changePage(page) {
        this.page = page;
        this._QueryData(false);
      },
77ebf04d   梁保满   个人版
318
319
      // 基站统计数据
      async stationReport() {
c2460294   梁保满   平台管理员接口联调
320
        const { data, status, info } = await this.$request.pStationReport();
77ebf04d   梁保满   个人版
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
        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   梁保满   平台管理员接口联调
342
        const { data, status, info } = await this.$request.pKeyboardReport();
77ebf04d   梁保满   个人版
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
        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   梁保满   个人版
368
369
370
      // 设备列表信息
      async _QueryData(isRef) {
        this.loading = true;
c2460294   梁保满   平台管理员接口联调
371
372
373
374
375
376
        let query = {};
        for (let key in this.query) {
          if (this.query[key]) {
            query[key] = this.query[key];
          }
        }
77ebf04d   梁保满   个人版
377
378
379
380
381
        if (isRef) {
          this.page = 1;
        }
        this.loading = true;
        this.tableData = [];
21dfdeae   梁保满   平台管理员
382
        const { data, status, info } = await this.$request.pDeviceList({
77ebf04d   梁保满   个人版
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
          ...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   梁保满   个人版
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
          });
        } 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   梁保满   个人版
421
422
423
424
425
426
427
428
429
430
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
    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>