he wei
2024-04-15 c94f1afa786f297be86b01b49a641b2c0ad98b6e
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
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
467
<template>
  <div class="p-main flex-c">
    <!-- 筛选 -->
    <div class="filter">
      <div class="filter-item">
        <div class="label">类型</div>
        <div class="value">
          <el-radio-group
            v-model="acTab"
            size="mini"
            @input="typeChange"
          >
            <el-radio-button label="YC">遥测量</el-radio-button>
            <el-radio-button label="YX">遥信量</el-radio-button>
          </el-radio-group>
        </div>
      </div>
      <div class="filter-item">
        <div class="label">参数名称</div>
        <div class="value">
          <el-cascader
            class="cascader"
            v-model="param"
            :options="paramList"
            @change="search1"
            filterable
            size="mini"
          ></el-cascader>
        </div>
      </div>
      <div class="filter-item">
        <div class="label">动作日期</div>
        <div class="value">
          <el-date-picker
            v-model="date"
            type="date"
            size="mini"
            @change="search1"
            value-format="yyyy-MM-dd"
            placeholder="选择日期"
          >
          </el-date-picker>
        </div>
      </div>
      <div class="filter-item">
        <gradient-btn size="sm" @click="search">查询</gradient-btn>
      </div>
    </div>
    <!-- 状态栏 -->
    <div class="info flex-r">
      <div class="info-item">
        <div class="label">设备名称</div>
        <div class="value">{{ param[0] }}</div>
      </div>
      <div class="info-item">
        <div class="label">参数类型</div>
        <div class="value">{{ "YC" == acTab ? "遥测量" : "遥信量" }}</div>
      </div>
      <div class="info-item">
        <div class="label">参数名称</div>
        <div class="value">{{ paramCn }}</div>
      </div>
      <div class="info-item">
        <div class="label">模拟日期</div>
        <div class="value">{{ date }}</div>
      </div>
      <div class="info-item">
        <div class="label">第一次模拟时间</div>
        <div class="value">{{ firstRec["time"] }}</div>
      </div>
      <div class="info-item">
        <div class="label">第一次模拟数值</div>
        <div class="value">{{ firstRec["fake"] }}</div>
      </div>
      <div class="info-item">
        <div class="label">最后一次模拟时间</div>
        <div class="value">{{ lastRec["time"] }}</div>
      </div>
      <div class="info-item">
        <div class="label">最后一次模拟数值</div>
        <div class="value">{{ lastRec["fake"] }}</div>
      </div>
    </div>
    <!-- 图表 -->
    <div class="chart-contain flex-r">
      <div class="name-panel">
        <div class="row">
          <div class="">{{ "YC" == acTab ? "遥测量" : "遥信量" }}名称</div>
          <div class="switch-name">{{ paramCn }}</div>
        </div>
        <div class="row">
          <div class="">模拟次数</div>
          <div class="num">{{ len }}</div>
        </div>
      </div>
      <div class="chart-wrap">
        <bar ref="bar" v-if="'YC' == acTab" unit="V"></bar>
        <step-line :is-swith="false" ref="stepLine" v-else></step-line>
      </div>
    </div>
    <!-- 表格 -->
    <panel class="panel p-content">
      <div class="panel-content flex-c">
        <div class="search">
          <!-- <div class="s-item">
            <div class="label">操作终端</div>
            <div class="value">
              <el-select
                v-model="operateDev"
                class="dark"
                size="mini"
                @change="getList"
                placeholder="请选择"
              >
                <el-option
                  v-for="(item, idx) in []"
                  :key="'level_' + idx"
                  :label="item"
                  :value="idx"
                >
                </el-option>
              </el-select>
            </div>
          </div> -->
          <div class="s-item">
            <gradient-btn size="sm" @click="exportFile">导出</gradient-btn>
          </div>
        </div>
        <div class="table-wrap">
          <el-table
            id="batteryrTimequeryTable"
            stripe
            size="small"
            :data="list"
            height="100%"
            class="table-dark"
            tooltip-effect="light"
          >
            <el-table-column
              label="序号"
              type="index"
              width="80"
            ></el-table-column>
            <el-table-column
              v-for="header in table.headers"
              :key="header.prop"
              :prop="header.prop"
              :label="header.label"
              :width="header.width"
              :min-width="header.minWidth"
              show-overflow-tooltip
              align="center"
            ></el-table-column>
          </el-table>
        </div>
      </div>
    </panel>
  </div>
</template>
 
<script>
import Panel from "@/components/panel.vue";
import gradientBtn from "@/components/gradientBtn.vue";
import bar from "@/components/bar";
import stepLine from "@/components/stepLine";
 
import { getYXListLogs, getYCListLogs } from "./js/apis";
 
import props_const from "@/views/powerCabinetControl/js/const_props";
const { getYXParamsObj, getYCParamsObj } = props_const;
 
// 引入导出表格
import { export_json_to_excel, formatJson } from "@/assets/js/exportFile";
 
export default {
  name: "powerTestDetails",
 
  components: {
    Panel,
    gradientBtn,
    bar,
    stepLine,
  },
  data() {
    return {
      operateDev: "",
      list: [],
      acTab: "YC",
      param: [],
      date: "",
      table: {
        headers: [
          {
            prop: "paramCn",
            label: "参数名",
            minWidth: 180,
          },
          {
            prop: "time",
            label: "模拟时间",
            minWidth: 180,
          },
          {
            prop: "fake",
            label: "模拟值",
            width: 180,
          },
        ],
      },
    };
  },
  computed: {
    paramList() {
      let type = this.acTab;
      let list = [
        { label: "交流配电柜", value: "ac" },
        { label: "直流配电柜", value: "dc" },
        { label: "高频开关电源柜", value: "gp" },
      ];
      let FN = "YC" == type ? getYCParamsObj : getYXParamsObj;
      return list.map((v) => {
        return {
          value: v.label,
          label: v.label,
          children: FN(v.value).map((vv) => ({
            value: vv.flag,
            label: vv.label,
          })),
        };
      });
    },
    firstRec() {
      return this.list[0] || {};
    },
    lastRec() {
      return this.list[this.len - 1] || {};
    },
    len() {
      return this.list.length;
    },
    paramCn() {
      let [type, key] = this.param;
      if (!key) {
        return "";
      }
      let list = this.paramList.filter((v) => v.label == type)[0]["children"];
      return list.filter((v) => v.value == key)[0]["label"];
    },
  },
  methods: {
    search1() {
      if (this.date && this.param[1]) {
        this.search();
      }
    },
    search() {
      let searchFn = "YC" == this.acTab ? getYCListLogs : getYXListLogs;
      let params = {
        param: this.param[1],
        dayTime: this.date,
      };
      if (!params.param) {
        this.$message.error("请选择参数名称");
        return false;
      }
      if (!params.dayTime) {
        this.$message.error("请选择动作日期");
        return false;
      }
      let loading = this.$layer.loading();
      searchFn(params)
        .then((res) => {
          let { code, data } = res.data;
          let list = [];
          if (code && data) {
            list = data.map((v) => {
              v.time = v.createTime.split(" ")[1] || "00:00:00";
              return v;
            });
          }
          this.$layer.close(loading);
          this.list = list;
          this.update();
        })
        .catch((err) => {
          this.$layer.close(loading);
          console.log(err);
        });
    },
    update() {
      let list = this.list;
      let data = [];
      if ("YC" == this.acTab) {
        data = list.map((v) => {
          return {
            time: v.time,
            value: v.fake,
          };
        });
        this.$refs.bar.setData(data);
      } else {
        data = list.map((v) => {
          return {
            time: v.time,
            flag: v.fake,
          };
        });
        this.$refs.stepLine.setData(data);
      }
    },
    refreshFN() {
      // let pageFlag = this.$route.query.pageFlag
      //     ? Number(this.$route.query.pageFlag)
      //     : 0;
      // 断路器名称
      let type = this.$route.query.type;
      let devName = this.$route.query.devName;
      let param = this.$route.query.param;
      let date = this.$route.query.date;
      if (type) {
        this.acTab = type;
      }
      if (param) {
        this.param = [devName, param];
      }
      if (date) {
        this.date = date;
      }
      this.search();
    },
    typeChange() {
      this.param = [];
      this.reset();
    },
    reset() {
      this.list = [];
    },
    // 导出表格
    exportFile() {
      let list = this.list;
      if (!list.length) {
        this.$message.error('没有数据可导出');
        return false;
      }
      let tHeader = [];
      let filterVal = [];
      this.table.headers.map((item, index) => {
        tHeader.push(item.label);
        filterVal.push(item.prop);
      });
      let excelData = formatJson(filterVal, list);
      let type = "YC" == this.acTab ? '遥测量' : '遥信量';
      let date = this.date;
      let paramCn = this.paramCn;
      let fileName = `${type}_${paramCn}_${date}`;
      export_json_to_excel(tHeader, excelData, fileName);
    },
  },
 
  mounted() {
    
  },
};
</script>
 
<style scoped lang="less">
.p-main {
  height: 100%;
  .filter {
    padding: 10px;
    display: flex;
    .filter-item {
      margin-right: 2em;
      display: flex;
      align-items: center;
      .label {
        margin-right: 0.4em;
        &::after {
          content: ":";
        }
      }
    }
  }
  .info {
    background: #00253f;
    padding: 10px;
    justify-content: space-between;
  }
  .info-item {
    display: flex;
    .label {
      margin-right: 0.4em;
      &::after {
        content: ":";
      }
    }
  }
  .chart-contain {
    margin-top: 8px;
    height: 220px;
    .name-panel {
      background: #00253f;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
      width: 180px;
      padding: 10px;
      margin-right: 10px;
      .row {
        display: flex;
        flex-direction: column;
        align-items: center;
      }
      .switch-name {
        color: #78eef8;
        font-size: 24px;
        font-weight: 700;
        text-align: center;
      }
      .num {
        color: #78eef8;
        font-size: 16px;
        font-weight: 700;
      }
    }
    .chart-wrap {
      flex: 1;
      background: #00253f;
    }
  }
  .p-content {
    flex: 1;
    margin-top: 4px;
    :deep(.content) {
      background: #011f39;
    }
    .panel-content {
      height: 100%;
      padding: 10px;
    }
    .search {
      display: flex;
      justify-content: space-between;
      .s-item {
        display: flex;
        align-items: center;
        .label {
          color: #78eef8;
          &::after {
            content: ":";
          }
          margin-right: 0.4em;
        }
      }
    }
    .table-wrap {
      flex: 1;
      margin-top: 6px;
      margin-bottom: 6px;
    }
  }
  .cascader {
    width: 300px;
  }
}
</style>