he wei
5 天以前 3c3576d5792bfabcef84979757ee344712e71cd3
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
<script setup name="battGood">
    import { ref, reactive, onMounted, computed, nextTick } from "vue";
    import { storeToRefs } from "pinia";
    import { Search, Plus } from "@element-plus/icons-vue";
    import ycCard from "@/components/ycCard/index.vue";
    import addEdit from "../datas/addEdit.vue";
    import { ElMessage } from "element-plus";
    import useElement from "@/hooks/useElement.js";
  import { useUserStore } from '@/store/user';
 
  import useStation from "@/hooks/useStationList.js";
  const { provice, city, country, stationName,
    proviceList, cityList, countryList, stationList,
  } = useStation();
 
  import { useRouter } from "vue-router";
  const router = useRouter();
 
  import { ExportFile } from '@/utils/exportFile.js';
 
 
  import powerTypes from '@/utils/const/const_powerType.js';
  import hrTypes from '@/utils/const/const_hrTestType.js';
  import {
    getBattPerformance,
  } from "@/api/station";
 
  const userStore = useUserStore();
  const { uid, uname } = storeToRefs(userStore);
  import moment from 'moment';
 
  import formatSeconds from '@/utils/formatSeconds';
  import {
    toFixed,
    digits,
  } from '@/utils/toFixed';
 
  import {
    getPerformanceStatistic,
  } from "@/api/statistic.js";
 
    const { $loading, $message, $confirm } = useElement();
 
 
    const headers = [
    {
      prop: "stationName",
      label: "站点名称",
      width: "160",
    },
    {
      prop: "battgroupName",
      label: "电池组名称",
      width: "80",
    },
    {
      prop: "monvolstd",
      label: "标称电体电压",
      width: "100",
    },
    {
      prop: "moncount",
      label: "单体数目",
      width: "100",
    },
    {
      prop: "moncapstd",
      label: "标称容量",
      width: "160",
    },
    {
      prop: "product",
      label: "电池品牌",
      width: "160",
    },
    {
      prop: "inuseYear",
      label: "使用年限",
      width: "80",
    },
    {
      prop: "realCap",
      label: "预估实际容量",
      width: "80",
    },
    {
      prop: "capperformance",
      label: "电池性能评估",
      width: "80",
    },
  ];
 
   const testType = ref('');
  const hrTypeList = computed(() => {
    return Object.keys(hrTypes).map(v => {
      return {
        value: v,
        label: hrTypes[v],
      };
    });
  });
 
  
    const background = ref(true);
    const disabled = ref(false);
    const pageCurr = ref(1);
    const pageSize = ref(10);
    const total = ref(0);
    const addEditVisible = ref(false);
    const dialogTitle = ref("");
    const currentAreaId = ref();
    const currentAreaIds = ref([]);
  const testStartDate = ref('');
  const testEndDate = ref('');
    const datas = reactive({
        tableData: [],
        rowData: {},
    });
 
 
  // 计算属性生成 picker-options(更简洁)
  const startDisabledDate = (time) =>  testEndDate.value ? moment(testEndDate.value).isBefore(time) || moment().isBefore(time) : moment().isBefore(time);
 
  const endDisabledDate = (time) => testStartDate.value ? moment(time).isBefore(testStartDate.value) || moment().isBefore(time) : moment().isBefore(time);
 
  const performance = ref('');
  const performanceList = ref([]);
 
  function getPerformancList() {
    getBattPerformance()
      .then((res) => {
        let { code, data, data2 } = res;
        let list = [];
        if (code && data) {
          // console.log(data);
          list = Object.keys(data2).map((key) => ({ value: key, label: data2[key] }));
        }
        performanceList.value = list;
      })
      .catch((err) => {
        console.log(err);
      });
  }
 
 
    function getList() {
        let loading = $loading();
    let params = {
      provice: provice.value || undefined,
      city: city.value || undefined,
      country: country.value || undefined,
      stationName: stationName.value || undefined,
      pageNum: pageCurr.value,
      pageSize: pageSize.value,
 
      performance: 1,
      testStartTime: testStartDate.value ? testStartDate.value + ' 00:00:00' : undefined,
      testEndTime: testEndDate.value ? testEndDate.value + ' 23:59:59' : undefined,
    };
 
        getPerformanceStatistic(params)
            .then((res) => {
                let { code, data, data2 } = res;
                let list = [];
                let _total = 0;
                if (code && data) {
                    // console.log(data);
                    list = data2.list.map(v => ({
            ...v,
          }));
                    _total = data2.total;
                }
                loading.close();
                // tableData.length = 0;
                // tableData.push(...list);
                datas.tableData = list;
                total.value = _total;
            })
            .catch((err) => {
                console.log(err);
                loading.close();
            });
    }
 
    // 展示数据数量
    function handleSizeChange(val) {
        pageSize.value = val;
        getList();
    }
    // 翻页
    function handleCurrentChange(val) {
        pageCurr.value = val;
        getList();
    }
 
  function filterChange() {
    nextTick(() => {
      pageCurr.value = 1;
      getList();
    });
  }
 
  function goRt (row) {
    router.push({
      path: '/datas/realtime',
      query: {
        stationId: row.stationId || undefined,
        powerId: row.powerId || undefined,
        devId: row.devId || undefined,
        battgroupId: row.battgroupId || undefined,
        pageFlag: Math.random(),
      }
    });
  }
 
  function goHis (row) {
    router.push({
      path: '/datas/history',
      query: {
        stationId: row.stationId || undefined,
        powerId: row.powerId || undefined,
        devId: row.devId || undefined,
        battgroupId: row.battgroupId || undefined,
        pageTab: 'his-real',
        pageFlag: Math.random(),
      }
    });
  }
 
  function exportExcel() {
    ExportFile(headers, datas.tableData, "优良电池组数统计");
  }
 
    onMounted(() => {
    getPerformancList();
        getList();
    });
</script>
 
<template>
  <div class="page-wrapper">
    <!-- <div class="page-header">
    </div> -->
    <div class="page-content">
      <yc-card is-full>
        <div class="page-content-wrapper">
          <div class="page-content-tools page-filter">
            <div class="grid-container" :style="{'--counter': 10}">
              <div class="grid-item">
                <div class="label">省</div>
                <div class="value">
                  <el-select
                    v-model="provice"
                    size="small"
                    clearable
                    @change="filterChange"
                    placeholder="请选择省"
                  >
                    <el-option
                      v-for="item in proviceList"
                      :key="'l0_' + item"
                      :label="item"
                      :value="item"
                    >
                    </el-option>
                  </el-select>
                </div>
              </div>
              <div class="grid-item">
                <div class="label">市</div>
                <div class="value">
                  <el-select
                    v-model="city"
                    size="small"
                    clearable
                    @change="filterChange"
                    placeholder="请选择市"
                  >
                    <el-option
                      v-for="item in cityList"
                      :key="'l1_' + item"
                      :label="item"
                      :value="item"
                    >
                    </el-option>
                  </el-select>
                </div>
              </div>
              <div class="grid-item">
                <div class="label">区县</div>
                <div class="value">
                  <el-select
                    v-model="country"
                    clearable
                    @change="filterChange"
                    size="small"
                    placeholder="请选择区县"
                  >
                    <el-option
                      v-for="item in countryList"
                      :key="'l2_' + item"
                      :label="item"
                      :value="item"
                    >
                    </el-option>
                  </el-select>
                </div>
              </div>
              <div class="grid-item">
                <div class="label">站点</div>
                <div class="value">
                  <el-select
                    v-model="stationName"
                    clearable
                    @change="filterChange"
                    size="small"
                    placeholder="请选择站点"
                  >
                    <el-option
                      v-for="item in stationList"
                      :key="'l3_' + item.stationId"
                      :label="item.stationName"
                      :value="item.stationName"
                    >
                    </el-option>
                  </el-select>
                </div>
              </div>
              <!-- <div class="grid-item">
                <div class="label">电池性能</div>
                <div class="value">
                  <el-select
                    v-model="performance"
                    filterable
                    clearable
                    size="small"
                    @change="filterChange"
                    placeholder="请选择"
                  >
                    <el-option
                      v-for="(item, idx) in performanceList"
                      :key="'list7_' + idx"
                      :label="item.label"
                      :value="item.value"
                    />
                  </el-select>
                </div>
              </div> -->
              <div class="grid-item">
                <div class="label">记录时间段</div>
                <div class="value" style="grid-column: span 7;">
                  <el-date-picker
                    v-model="testStartDate"
                    type="date"
                    size="small"
                    placeholder="选择日期"
                    format="YYYY-MM-DD"
                    value-format="YYYY-MM-DD"
                    :disabled-date="startDisabledDate"
                  />
                  -
                  <el-date-picker
                    v-model="testEndDate"
                    size="small"
                    type="date"
                    placeholder="选择日期"
                    format="YYYY-MM-DD"
                    value-format="YYYY-MM-DD"
                    :disabled-date="endDisabledDate"
                  />
                </div>
              </div>
            </div>
          </div>
          <div class="page-content-table">
            <div class="pos-rel">
              <div class="pos-abs">
                <el-table class="yc-table" stripe height="100%" size="small" :data="datas.tableData" style="width: 100%">
                  <el-table-column type="index" fixed="left" label="序号" width="60"></el-table-column>
                  <el-table-column v-for="header in headers" :key="header.prop" :prop="header.prop" :label="header.label"
                    :min-width="header.width" align="center">
                    <template #default="scope">{{ scope.row[header.prop] }}</template>  
                  </el-table-column>
                  <el-table-column label="操作" fixed="right" width="240" align="center">
                    <template #default="scope">
                      <el-button type="warning" size="small" @click="goRt(scope.row)">实时监测</el-button>
                      <el-button type="primary" size="small" @click="goHis(scope.row)">历史数据</el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </div>
          </div>
          <div class="page-content-page">
            <div class="page-tool">
              <el-button type="primary" round size="small" @click="getList" :icon="Search">查询</el-button>
            </div>
            <div class="el-page-container">
              <el-pagination v-model:current-page="pageCurr" v-model:page-size="pageSize"
                :page-sizes="[20, 40, 60, 80, 100, 200, 300, 400]" size="small" :disabled="disabled"
                :background="background" layout="total, sizes, prev, pager, next, jumper" :total="total"
                @size-change="handleSizeChange" @current-change="handleCurrentChange" />
            </div>
            <div class="page-tool">
              <el-button type="primary" round size="small" @click="exportExcel">导出</el-button>
            </div>
          </div>
        </div>
      </yc-card>
    </div>
    <div class="page-footer"></div>
  </div>
</template>
 
<style scoped lang="less">
.page-wrapper {
  display: flex;
  flex-direction: row;
  // padding: 8px;
  height: 100%;
 
  .page-content {
    flex: 1;
  }
}
 
.page-content-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
 
  .page-content-tools {
    padding-bottom: 8px;
  }
 
  .page-content-table {
    // border-top: 1px solid var(--border-light-color);
    box-sizing: border-box;
    flex: 1;
    margin-left: 26px;
    margin-right: 26px;
  }
 
  .page-content-page {
    padding: 8px 8px 0 8px;
    text-align: center;
 
    .el-page-container {
      display: inline-block;
      padding: 0 16px;
    }
 
    .page-tool {
      display: inline-block;
    }
  }
}
 
.hdw-card-container {
  width: 240px;
  padding-right: 8px;
  height: 100%;
}
 
.pos-rel {
  position: relative;
  width: 100%;
  height: 100%;
 
  .pos-abs {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
  }
}
 
.tools-filter {
  display: inline-block;
  font-size: 14px;
 
  .tools-filter-item {
    display: inline-block;
    margin-right: 8px;
 
    .filter-label {
      display: inline-block;
    }
 
    .filter-content {
      display: inline-block;
    }
  }
}
.max-width {
  max-width: 200px;
}
</style>