oil.vue
6.96 KB
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
<template>
<div class="system-container">
<div class="container">
<h1>油耗统计</h1>
<div class="m-b-md title_tips">统计车辆油耗情况,以自然日为时间单位统计(此功能仅针对OBD设备)</div>
<!-- 搜索区域 开始 -->
<div class="search_box">
<el-form :model="searchForm" :inline="true" size="small">
<el-form-item label="关键字:">
<el-input v-model="searchForm.keywords" class="a_input" placeholder="特约店编码|店名称|车架号|车型"></el-input>
</el-form-item>
<el-form-item label="年份:">
<el-date-picker v-model="searchForm.dataRange" type="month" placeholder="选择月" value-format="yyyy-MM" @change="initColumn">
</el-date-picker>
</el-form-item>
<!-- <el-form-item label="月份:">
<el-select v-model="searchForm.month" placeholder="请选择" @change="onChange">
<el-option label="1月" value="1"></el-option>
<el-option label="2月" value="2"></el-option>
<el-option label="3月" value="3"></el-option>
<el-option label="4月" value="4"></el-option>
<el-option label="5月" value="5"></el-option>
<el-option label="6月" value="6"></el-option>
<el-option label="7月" value="7"></el-option>
<el-option label="8月" value="8"></el-option>
<el-option label="9月" value="9"></el-option>
<el-option label="10月" value="10"></el-option>
<el-option label="11月" value="11"></el-option>
<el-option label="12月" value="12"></el-option>
</el-select>
</el-form-item> -->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getList()">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-refresh" size="mini" @click="rest()">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 搜索区域 end -->
<!-- 按钮区域 开始 -->
<div class="links_group">
<span>油耗信息</span>
<el-button class="pull-right" type="primary" icon="el-icon-download" size="mini" :loading="dloading" @click="downloadExcel()">导出Excel</el-button>
</div>
<!-- 按钮区域 end -->
<!-- 列表 开始 -->
<glsx-table ref="glsxTable" :list="tableData" :column="tableColumnList" :pageTotal="pageTotal" @change="getList">
</glsx-table>
<!-- <div class="table_box">
<el-table :data="tableData" border>
<el-table-column label="工单号" prop=""></el-table-column>
<el-table-column label="姓名" prop=""></el-table-column>
<el-table-column label="设备号" prop=""></el-table-column>
<el-table-column label="车架号" prop=""></el-table-column>
<el-table-column label="总行驶次数" prop=""></el-table-column>
<el-table-column label="总里程km" prop=""></el-table-column>
<el-table-column label="操作" prop=""></el-table-column>
</el-table>
</div> -->
<!-- <basic-table ref="reportTable" :tableParams="reportTableParams" :beforeSearchFn="beforeSearchFn" :searchForm="searchDataForm" :getListApi="getListApi" @dataFinished="tableDataFinished" :hasNum="false">
</basic-table> -->
<!-- 列表 end -->
</div>
</div>
</template>
<script>
import GlsxTable from "@/components/glsx-table";
import {
OIL_STATISTICS_SEARCH,
OIL_YEARS_LIST,
OIL_STATISTICS_EXPORT,
} from "services/report";
import moment from "moment";
import { deepClone } from "@/utils/util";
export default {
data() {
return {
searchForm: {},
tableData: [],
columnList: [
{
label: "特约店代码",
prop: "shopCode",
fixed: "left",
width: "100px",
},
{
label: "特约店名称",
prop: "shopName",
fixed: "left",
width: "100px",
},
{ label: "车型", prop: "modelName", fixed: "left", width: "160px" },
{ label: "设备号", prop: "sn", fixed: "left", width: "160px" },
{ label: "车架号VIN码", prop: "vin", fixed: "left", width: "160px" },
{ label: "时间", prop: "statDate", fixed: "left", width: "100px" },
],
tableColumnList: [],
pageTotal: 0,
yearList: [],
dloading: false,
};
},
components: {
GlsxTable,
},
mounted() {
this.getYear();
this.initColumn();
this.getList();
},
methods: {
// 获取查询参数
getParams() {
let oParams = deepClone(this.searchForm);
let o = oParams.dataRange;
if(o){
oParams.year = o.split('-')[0]
oParams.month = o.split('-')[1]
delete oParams.dataRange
}
return oParams;
},
// 获取列表
getList(options) {
let oParams = this.getParams();
oParams.pageSize = this.$refs.glsxTable.pageSize;
oParams.pageNumber = options ? options.pageNumber || 1 : 1;
OIL_STATISTICS_SEARCH(oParams).then((res) => {
let { data } = res;
let { list, totalElements } = data;
this.pageTotal = totalElements;
this.tableData = list;
});
},
// 查看详情
lookDetail(row) {
console.log(row);
this.$router.push({ name: "mileageDetail" });
},
/** 初始化 表格日期 */
initColumn(e) {
let y = e?e.split('-')[0] : moment().date();
let m = e?e.split('-')[1] : moment().month() + 1;
let day = moment(`${y}-${m}`, "YYYY-MM").daysInMonth();
let list = deepClone(this.columnList);
for (let i = 1, len = day; i <= len; i++) {
let o = { label: `${i}日`, prop: `dayNum${i}` };
list.push(o);
}
list.push({ label: "总计(升)", prop: "summation" });
this.tableColumnList = list;
},
//监听月份和年份 切换
// onChange() {
// this.initColumn();
// },
// 重置
rest() {
this.searchForm = {};
this.getList();
this.$refs.glsxTable.rest();
},
// 获取年份
getYear() {
OIL_YEARS_LIST().then((res) => {
this.yearList = res.data || [];
});
},
// 导出excel
downloadExcel() {
let _this = this;
let oParams = this.getParams();
_this.dloading = true;
_this.$Common.exportExcel({
url: `${_this.$store.state.baseURL}${OIL_STATISTICS_EXPORT}`,
method: "GET",
data: oParams,
fileName: "油耗统计报表",
success: () => {
_this.dloading = false;
},
fail: () => {
_this.dloading = false;
},
});
},
},
};
</script>
<style lang="scss" scoped>
.pre_select {
width: 100px;
}
.title_tips {
font-size: 14px;
}
.links_group {
display: flex;
align-items: center;
justify-content: space-between;
}
.search_box{
.a_input{
width:260px;
}
}
</style>>