liulingling.177216
2024-08-26 349f1cfc5fa77fbc636d542df0d8050fddec48c2
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
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
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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<template>
  <basic-container :bodyStyle="bodyStyle" class="realTimeTrend-right">
    <el-form
      :model="queryParams"
      ref="queryForm"
      label-width="68px"
      class="special-form"
      style="margin-bottom: 20px"
    >
      <el-row :gutter="24">
        <el-col :span="24">
          <el-form-item class="operation" style="text-align: right">
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >查询</el-button
            >
            <el-button
              type="warning"
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              >导出</el-button
            >
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div class="tableStyle">
      <el-table
        :data="tableData"
        ref="dataTable"
        border
        style="width: 100%; margin-top: 20px"
        :max-height="height"
        @selection-change="handleSelectionChange"
      >
        <el-table-column
          type="selection"
          align="center"
          width="50"
        ></el-table-column>
        <!-- <el-table-column label="曲线选择" width="100" align="center">
          <template slot-scope="scope">
            <el-button
              v-if="scope.row.code == queryParams.indexCode"
              icon="el-icon-search"
              circle
              @click="selectChange(scope.row)"
              style="font-size: 10px; color: #fff; background: #478ef7"
            ></el-button>
            <el-button
              v-else
              icon="el-icon-search"
              circle
              @click="selectChange(scope.row)"
              style="font-size: 10px"
            ></el-button>
          </template>
        </el-table-column> -->
        <el-table-column prop="indexName" align="center" label="点位名称" />
        <el-table-column prop="value" align="center" label="当前值" />
        <el-table-column prop="indexUnit" align="center" label="单位" />
        <el-table-column prop="timeString" align="center" label="时间" />
      </el-table>
    </div>
    <real-time-line
      ref="liveLineChart"
      :chart-data="{
        ...liveLineChartData,
        titleList: queryParams.indexName
      }"
      style="margin-top: 20px"
    />
  </basic-container>
</template>
 
<script>
import {
  getTrendSettingIndex,
  getTrendSettingIndexLineData,
  exportRealTimeTrend
} from "@/api/dataMonitoring/realTimeTrend/realTimeTrend";
import realTimeLine from "./LineChart";
import mixins from "@/layout/mixin/getHeight";
import moment from "moment";
 
export default {
  name: "energyIndex",
  components: { realTimeLine },
  mixins: [mixins],
  props: {
    bodyStyle: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      timeArr: [],
      currentNode: "",
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      dateRange: [],
      names: [],
      // 非单个禁用
      single: true,
      // 总条数
      total: 10,
      // 指标信息表格数据
      List: [],
      // 弹出层标题
      title: "历史曲线查询",
      // 是否显示弹出层
      open: false,
      queryParams: {
        indexCode: "",
        nodeId: undefined
      },
      tableData: [],
      lineData: [],
      //选中code
      codes: [],
      // //选中指标名称
      indexNames: [],
      datas: [],
      // 表单参数
      form: {},
      addTableSelect: [],
      liveLineChartData: {
        datas: [],
        timeList: [],
        title: ""
      },
      height: 400,
      rows: [],
      code: "",
      activeName: "",
      multipleSelection: []
    };
  },
  created() {},
  beforeDestroy() {
    //页面销毁时 要停止计时器,否则选项卡切换计时器不停止,会越来越快,多个线程
    if (this.timer) {
      clearInterval(this.timer);
      this.timer = null;
    }
  },
  methods: {
    setCharts() {
      // this.height = window.innerHeight - 220 + "px";
    },
    modelNodeChange(modelNode) {
      // this.$refs.liveLineChart.closeLineChar();
      this.queryParams.nodeId = modelNode.id;
      this.getList();
      this.disabledSetting =
        modelNode === undefined || modelNode === "" || modelNode === null;
      if (modelNode) {
        this.currentNode = modelNode;
      }
    },
    /** 查询指标信息列表 */
    getList() {
      this.loading = true;
      var search = this.queryParams;
      //表格数据
      getTrendSettingIndex(search).then(response => {
        this.tableData = response.data;
        this.total = response.total;
        this.loading = false;
        this.cleanLineData();
        // if (this.tableData && this.tableData.length !== 0) {
        //   this.selectChange(this.tableData[0]);
        // }
      });
    },
 
    selectChange(row) {
      this.queryParams.indexCode = row ? row.code : undefined;
      this.liveLineChartData.title = row ? row.indexName : "";
      this.getLineDataList();
    },
 
    handleSelectionChange(val) {
      this.multipleSelection = val;
      this.queryParams.indexCode = val.map(item => {
        return item.code;
      });
      this.queryParams.indexName = val.map(item => {
        return item.indexName;
      });
      if (val.length) {
        this.getLineDataList();
      } else {
        this.cleanLineData();
      }
    },
 
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
 
    getLineDataList() {
      this.cleanLineData();
      //折线图数据
      getTrendSettingIndexLineData(
        this.queryParams.indexCode,
        this.queryParams.minute || 20,
        this.count || 10
      ).then(response => {
        //数据添加
        this.liveLineChartData.datas = response.data.map(item => {
          return {
            value: item.map(val => {
              return val.value;
            }),
            time: item.map(val => {
              return moment(val.showDataTime).format("HH:mm");
            })
          };
        });
        // x轴时间添加
        this.liveLineChartData.timeList = response.data[0].map(item => {
          return moment(item.showDataTime).format("HH:mm");
        });
      });
    },
 
    cleanLineData() {
      this.liveLineChartData.timeList = [];
      this.liveLineChartData.datas = [];
    },
    closeDialog() {
      this.activeName = "";
    },
    openDialog(e) {
      if (e) {
        this.code = e.code;
        this.open = true;
        this.activeName = "second";
      }
    },
    cancelDialog() {
      this.open = false;
    },
    // 单位字典翻译
    unitFormat(row, column) {
      return this.selectDictLabel(this.unitOptions, row.indexUnit);
    },
    handleExport() {
      exportRealTimeTrend({
        nodeId: this.queryParams.nodeId
      }).then(response => {
        this.download(response.msg);
      });
    }
  }
};
</script>
<style scoped lang="scss">
.realTimeTrend-right {
  height: 100%;
  overflow: hidden;
}
 
.tableStyle .el-table__header-wrapper .el-checkbox {
  display: none;
}
 
.special-form {
  @import "~@/assets/styles/common-table-form.scss";
}
</style>