张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
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
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
<template>
  <div class="main">
    <div class="main_header">
      <div class="header_item">
        <span class="header_label">选择设备:</span>
        <el-select v-model="deviceId" clearable placeholder="请选择设备">
          <el-option
            v-for="item in deviceData"
            :key="item.deviceId"
            :label="item.deviceName"
            :value="item.deviceId">
          </el-option>
        </el-select>
      </div>
      <div class="header_item">
        <el-button icon="el-icon-search" @click="searchCisternMonitoringList(true)">查询</el-button>
      </div>
    </div>
    <div class="main_content">
      <el-table
        v-loading="loading"
        :data="monitoringList"
        height="100%" >
        <el-table-column label="序号" width="60" align="center">
          <template #default="scope">
            <span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="releaseTime" label="采集时间" align="center"></el-table-column>
        <el-table-column prop="deviceName" label="采集设备" align="center"></el-table-column>
        <el-table-column prop="temperature" width="300" label="温度(℃)" align="center"></el-table-column>
        <el-table-column prop="phValue" label="PH值" width="300" align="center"></el-table-column>
      </el-table>
    </div>
    <div class="main_footer">
      <el-pagination
        background
        @current-change="changePageNum"
        @size-change="changePageSize"
        :current-page="pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>
 
<script>
  export default {
    name: 'MonitoringIndex',
    props: {
      waterId: {
        type: String
      }
    },
    data() {
      return {
        deviceId: '',
        deviceData: [],
        pageNum: 1,
        pageSize: 10,
        total: 0,
        loading: false,
        monitoringList: [],
      }
    },
    mounted() {
      this.getAllDeviceData();
      this.searchCisternMonitoringList(true);
    },
    methods: {
      // 获取全部采集设备信息
      async getAllDeviceData() {
        const { data } = await this.$api.DuctpiecePLM.getAllDeviceInfo({
          deviceType: '02195c7bba9a8b59dbc66452'
        });
        this.deviceData = data;
      },
      // 查询水养池实时监控信息
      searchCisternMonitoringList(bol) {
        if(bol) {
          this.pageNum = 1;
        }
        this.loading = true;
        this.monitoringList = [];
        this.$api.DuctpiecePLM.searchCisternMonitoringList({
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          waterCultivatedId: this.waterId,
          deviceId: this.deviceId
        }).then((res) => {
          if(res.success) {
            this.total = res.data.total;
            this.monitoringList = res.data.list
          }
          this.loading = false;
        }).catch(() => {
          this.loading = false;
        })
      },
      // 切换页数
      changePageNum(page) {
        this.pageNum = page;
        this.searchCisternMonitoringList();
      },
      // 切换每页条数
      changePageSize(size) {
        this.pageSize = size;
        this.searchCisternMonitoringList();
      },
    }
  }
</script>
 
<style lang="scss" scoped>
@import '@/style/layout-main.scss';
 
.main {
  height: 100% !important;
  background: none !important;
}
 
::v-deep .el-table tr {
  &:nth-of-type(even) {
    background: #082E56 !important;
  }
}
</style>