123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <template>
- <div class="app-container">
- <el-form
- :model="queryParams"
- ref="queryForm"
- size="small"
- :inline="true"
- v-show="showSearch"
- label-width="68px"
- >
- <el-form-item label="日期">
- <el-date-picker
- v-model="dateRange"
- size="small"
- style="width: 360px"
- type="daterange"
- range-separator="-"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- ></el-date-picker>
- </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-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- @click="handleExport"
- v-hasPermi="['ems:emselectricityday:export']"
- >导出
- </el-button>
- </el-col>
- <right-toolbar
- :showSearch.sync="showSearch"
- @queryTable="getList"
- ></right-toolbar>
- </el-row>
- <el-table
- v-loading="loading"
- :data="emselectricitydayList"
- >
- <el-table-column label="序号" width="55">
- <template slot-scope="scope">
- <span>{{
- (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
- }}</span>
- </template>
- </el-table-column>
- <el-table-column label="设备名称" align="center" prop="equipmentname" />
- <el-table-column label="设备编号" align="center" prop="equipmentcode" />
- <el-table-column label="用电量(kWh)" align="center" prop="electricityvalue" />
- </el-table>
- </div>
- </template>
- <script>
- import { httpAction, getAction } from '@/api/manage'
- export default {
- name: "emselectricityday",
- data() {
- return {
- description: '日用电量',
- // 遮罩层
- loading: false,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 分时电量数据表格数据
- emselectricitydayList: [],
- // 弹出层标题
- title: "",
- // 日期范围
- dateRange: [],
- // 是否显示弹出层
- open: false,
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 1000,
- },
- url: {
- list: "/ems/emselectricityday/liststa",
- },
- };
- },
- created() {
- this.getDate();
- this.getList();
- },
- methods: {
- getDate() {
- var begindate = this.dateformat(new Date()).substring(0, 10);
- var enddate = this.dateformat(new Date()).substring(0, 10);
- this.dateRange = [ begindate, enddate ];
- },
- dateformat(date) {
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- month = month < 10 ? "0" + month : month;
- var strDate = date.getDate();
- strDate = strDate < 10 ? "0" + strDate : strDate;
- var hour = date.getHours();
- hour = hour < 10 ? "0" + hour : hour;
- var minute = date.getMinutes();
- minute = minute < 10 ? "0" + minute : minute;
- var second = date.getSeconds();
- second = second < 10 ? "0" + second : second;
- return year + "-" + month + "-" + strDate + " " + hour + ":" + minute + ":" + second;
- },
- /** 查询分时电量数据列表 */
- getList() {
- if (this.dateRange == null || this.dateRange.length < 2) {
- this.$modal.msgError("请先选择日期!");
- return false;
- }
- this.loading = true;
- this.dateRange[0] = this.dateformat(new Date(this.dateRange[0])).substring(0, 10);
- this.dateRange[1] = this.dateformat(new Date(this.dateRange[1])).substring(0, 10);
- getAction(this.url.list, this.addDateRange(this.queryParams, this.dateRange)).then((response) => {
- this.emselectricitydayList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.resetForm("queryForm");
- this.dateRange = [];
- this.handleQuery();
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download(
- "ems/emselectricityday/exportsta",
- {
- ...this.queryParams,
- },
- `用电量_${new Date().getTime()}.xlsx`
- );
- },
- },
- };
- </script>
|