选煤厂生产管理平台前端代码
dongyukun
2024-12-10 5cc1d92af645c2f8f4f6d1d3777283b70df78ccd
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
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-app">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <span>统计日期:</span>
          <el-date-picker
              v-model="dataForm.rq"
              type="date"
              :clearable="true"
              value-format="yyyy-MM-dd"
              placeholder="日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="openForm()">{{ $t('add') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="exportExcel()">导出</el-button>
        </el-form-item>
        <div style="float: right">
          <el-form-item>
            <span>月初:</span>
            <el-date-picker
                v-model="dataForm.monthStart"
                type="date"
                readonly
                value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <span>年初:</span>
            <el-date-picker
                v-model="dataForm.yearStart"
                type="date"
                readonly
                value-format="yyyy-MM-dd">
            </el-date-picker>
          </el-form-item>
        </div>
      </el-form>
      <el-table
          ref="table"
          v-loading="dataListLoading"
          :data="dataList"
          border
          style="width: 100%;"
          show-summary
          :summary-method="getSummaries">
        <el-table-column type="index" header-align="center" align="center" min-width="50" label="序号"></el-table-column>
        <el-table-column prop="lsh" header-align="center" align="center" label="流水号" min-width="200"></el-table-column>
        <el-table-column prop="rq" header-align="center" align="center" label="日期" min-width="100"></el-table-column>
        <el-table-column prop="bcName" header-align="center" align="center" label="班次" min-width="100"></el-table-column>
        <el-table-column prop="xtName" header-align="center" align="center" label="耗电系统" min-width="200"></el-table-column>
        <el-table-column header-align="center" align="center" label="内报量(kw.h)">
          <el-table-column prop="nbdrl" header-align="center" align="center" label="当日" min-width="150">
            <template slot-scope="scope">
              <span style="color: red">{{scope.row.nbdrl}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="nbtzl" header-align="center" align="center" label="累计调整量" min-width="150"></el-table-column>
        </el-table-column>
        <el-table-column header-align="center" align="center" label="外报量(kw.h)">
          <el-table-column prop="wbdrl" header-align="center" align="center" label="当日" min-width="150">
            <template slot-scope="scope">
              <span style="color: red">{{scope.row.wbdrl}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="wbtzl" header-align="center" align="center" label="累计调整量" min-width="150"></el-table-column>
        </el-table-column>
        <el-table-column show-overflow-tooltip prop="bz" header-align="center" align="center" label="备注" min-width="287"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" min-width="100">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="openForm(scope.row.id)">修改</el-button>
            <el-button type="text" size="small" @click="handleDelete(scope.row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-row style="margin-top: 6px">
        <el-col :span="4">
          <el-button @click="exportStatisticsExcel()">导出</el-button>
        </el-col>
        <el-col :span="20">
          <el-pagination
                  :current-page="page"
                  :page-sizes="[10, 20, 50, 100]"
                  :page-size="limit"
                  :total="total"
                  layout="total, sizes, prev, pager, next, jumper"
                  @size-change="pageSizeChangeHandle"
                  @current-change="pageCurrentChangeHandle">
          </el-pagination>
        </el-col>
      </el-row>
      <el-table
          ref="statisticsTable"
          v-loading="dataListLoading"
          :data="statisticsList"
          border
          show-summary
          :summary-method="getStatisticsSummaries">
        <el-table-column prop="xtName" header-align="center" align="center" label="耗电系统"></el-table-column>
        <el-table-column header-align="center" align="center" label="内报量(kw.h)">
          <el-table-column prop="nbDaySum" header-align="center" align="center" label="当日">
            <template slot-scope="scope">
              <span style="color: red">{{scope.row.nbDaySum}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="nbMonthSum" header-align="center" align="center" label="月累计"></el-table-column>
          <el-table-column prop="nbYearSum" header-align="center" align="center" label="年累计"></el-table-column>
        </el-table-column>
        <el-table-column header-align="center" align="center" label="外报量(kw.h)">
          <el-table-column prop="wbDaySum" header-align="center" align="center" label="当日">
            <template slot-scope="scope">
              <span style="color: red">{{scope.row.wbDaySum}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="wbMonthSum" header-align="center" align="center" label="月累计"></el-table-column>
          <el-table-column prop="wbYearSum" header-align="center" align="center" label="年累计"></el-table-column>
        </el-table-column>
      </el-table>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>
 
<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './list-add-or-update'
import {exportByDom} from "../../../../../utils/exportUtil";
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/iailab-iems-coal-proddisp/consume/power/list',
        getDataListIsPage: true,
        deleteURL: '/iailab-iems-coal-proddisp/consume/power',
        deleteIsBatch: true,
      },
      dataForm: {
        rq: (new Date()).Format('yyyy-MM-dd'),
        monthStart: '',
        yearStart: ''
      },
      statisticsList: []
    }
  },
  components: {
    AddOrUpdate
  },
  created () {
    if (this.mixinViewModuleOptions.createdIsNeed) {
      this.query()
      this.statisticsInit()
    }
  },
  methods: {
    getDataList: function () {
      this.page = 1
      this.query()
      this.statisticsInit()
    },
    statisticsInit () {
      this.$http.get(
          '/iailab-iems-coal-proddisp/consume/power/statistics').then(({ data: res }) => {
        if (res.code !== 0) {
          return this.$message.error(res.msg)
        }
        this.statisticsList = res.list
        this.dataForm.monthStart = res.monthStart
        this.dataForm.yearStart = res.yearStart
      }).catch(() => {})
    },
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计';
          return;
        }
        if (index === 1 || index === 2 || index === 3 || index === 4 || index === 9) {
          sums[index] = '';
          return;
        }
        const values = data.map(item => Number(item[column.property]));
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index] = sums[index].toFixed(2);
        } else {
          sums[index] = '';
        }
      });
 
      return sums;
    },
    getStatisticsSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计';
          return;
        }
        const values = data.map(item => Number(item[column.property]));
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index] = sums[index].toFixed(2);
        } else {
          sums[index] = '';
        }
      });
 
      return sums;
    },
    exportExcel () {
      let dom = this.$refs.table
      exportByDom(dom, undefined, '电耗统计')
    },
    exportStatisticsExcel () {
      let dom = this.$refs.statisticsTable
      exportByDom(dom, undefined, '电耗合计统计')
    }
  }
}
</script>
 
<style scoped>
 
/deep/ .el-table__footer-wrapper tbody td,
.el-table__header-wrapper tbody td {
  background-color: #e3f3ff !important;
}
/deep/ .el-table__footer-wrapper .is-leaf {
  background-color: #e3f3ff !important;
}
/deep/ .el-table__fixed-footer-wrapper tbody td {
  border-top: 1px solid #ebeef5;
  background-color: #e3f3ff;
  font-weight: bold;
  color: #f50b0b;
  text-align: center !important;
}
/deep/ .has-gutter tr td .cell {
  text-align: center;
  font-weight: bold;
  color: blue;
}
</style>