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
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="120px">
      <el-form-item label="生效时间" prop="effectiveName">
        <el-select v-model="queryParams.effectiveDate" placeholder="请选择生效时间" clearable size="small">
          <el-option
            v-for="dict in list"
            :key="changeTime(parseTime(dict.effectiveDate))"
            :label="changeTime(parseTime(dict.effectiveDate))"
            :value="changeTime(parseTime(dict.effectiveDate))"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="electricityList">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="时段名称" align="center" prop="effectiveName" :formatter="effectiveNameFormat" />
      <el-table-column label="单价" align="center" prop="price"/>
      <el-table-column label="时段开始时间" align="center" prop="beginDate" width="180"/>
      <el-table-column label="时段结束时间" align="center" prop="endDate" width="180"/>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
 
<script>
  import { listHistory, listDate } from "@/api/electricityPrice/electricity";
  export default {
    data() {
      return {
        // 总条数
        total: 0,
        // electricityPrice表格数据
        electricityList: [],
        list:[],
        // 时段名称字典
        effectiveNameOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          effectiveDate: undefined,
        },
      };
    },
    created() {
      this.getList();
      this.getLists();
      this.getDicts("electricity_price").then(response => {
        this.effectiveNameOptions = response.data;
      });
    },
    methods: {
      /** 查询electricityPrice列表 */
      getList() {
        this.loading = true;
        listHistory(this.queryParams).then(response => {
          this.electricityList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      getLists() {
        this.loading = true;
        listDate(this.queryParams).then(response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 时段名称字典翻译
      effectiveNameFormat(row, column) {
        return this.selectDictLabel(this.effectiveNameOptions, row.effectiveName);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.time = false;
        this.openPrice = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: undefined,
          effectiveDate: undefined,
          priceId: undefined,
          beginDate: undefined,
          endDate: undefined,
          effectiveName: undefined
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
    changeTime(time) {
      if (time !== null && time !== undefined && time !== "") {
        return time.substring(0, 10);
      } else {
        return "";
      }
    }
    }
  };
</script>