index.vue
5.24 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
<!-- 车辆管理 -->
<template>
<d2-container class="reportingLogs">
<el-form
:inline="true"
:model="searchForm"
label-width="85px"
slot="header"
>
<el-form-item label="上报时间">
<el-date-picker
v-model="searchForm.reportTime"
type="daterange"
value-format="yyyy-MM-dd"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item label="车辆编号">
<el-input v-model="searchForm.trafficCode" placeholder="请输入车辆编号" clearable @clear="loadingGetList"></el-input>
</el-form-item>
<el-form-item label="归属车辆段">
<el-select v-model="searchForm.stationCode" placeholder="请选择" clearable filterable @clear="loadingGetList">
<el-option v-for="(item, index) in baseData.station"
:key="index"
:value="item.confCode"
:label="item.confValue"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="子系统编号">
<el-input v-model="searchForm.subSystemCode" placeholder="请输入子系统编号" clearable @clear="loadingGetList"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleSearch">查询</el-button>
</el-form-item>
</el-form>
<d2-table-header title="上报日志列表"></d2-table-header>
<el-table
:data="tableData"
v-loading="$store.state.d2admin.loading.value"
border
:stripe="true"
:highlight-current-row="true"
>
<el-table-column
align="center"
width="60px"
label="序号"
type='index'
:index="index=>index+(currentPage - 1) * pageSize + 1"
></el-table-column>
<el-table-column
v-for="(item, index) in tableColumns"
:key="index"
:label="item.label"
:prop="item.prop"
:width="item.width"
align="center"
>
</el-table-column>
</el-table>
<el-pagination
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10,20,30,40]"
:page-size="pageSize"
:total="total"
layout="sizes,total,->,prev,pager,next,jumper"
>
</el-pagination>
</d2-container>
</template>
<script>
import { getLogsApi, exportApi } from '@api/reportingLogs'
import { BaseData } from '@/common/constants'
import notice from '@/common/notice'
export default {
name: 'FimsReportingLogs',
data() {
return {
searchForm: {
reportTime: '',
trafficCode: '',
stationCode: '',
subSystemCode: ''
},
tableData: [],
tableColumns: [{
label: '上报时间',
prop: 'reportTime'
}, {
label: '车辆编号',
prop: 'trafficCode'
}, {
label: '归属车辆段',
prop: 'stationName'
}, {
label: '子系统编号',
prop: 'subSystemCode'
}, {
label: '子系统类型',
prop: 'subSystemType'
}, {
label: '子系统厂家',
prop: 'merchantName'
}, {
label: '上报内容',
prop: 'reportValue'
}],
// 页码
currentPage: 1,
pageSize: 10,
total: 30,
baseData: {
station: []
}
}
},
watch: {
'searchForm.reportTime'(value) {
!value && this.loadingGetList()
}
},
mounted() {
this.loadingGetList()
this.loadBaseData()
},
methods: {
async loadBaseData() {
const data = await this.$store.dispatch('d2admin/base/get', BaseData.STATION.KEY)
this.baseData.station = data
},
loadingGetList() {
this.getList()
},
getParams() {
var time = [{ attr: 'startTime', addTime: '00:00:00' }, { attr: 'endTime', addTime: '23:59:59' }]
this.searchForm.reportTime && this.searchForm.reportTime.map((value, i) => { this.searchForm[time[i].attr] = value + ' ' + time[i].addTime })
return {
pageCount: this.pageSize,
pageSize: this.currentPage,
...this.searchForm
}
},
getList() {
const params = this.getParams()
delete params.reportTime
getLogsApi(params).then(res => {
// res.pagination && (this.total = res.pagination.totalCount)
this.tableData = res.loges
this.total = res.pagination.totalCount
})
.catch(() => {
notice.errorTips()
})
},
handleExport() {
const params = this.getParams()
delete params.reportTime
exportApi(params).then(res => {
// console.log(res)
// window.location.href = res.url
this.$open(res.url)
notice.okTips()
}).catch(() => {
notice.errorTips()
})
},
// 搜索
handleSearch() {
this.loadingGetList()
},
// 页码
handleSizeChange(value) {
this.pageSize = value
// 调接口
this.loadingGetList()
},
handleCurrentChange(value) {
this.currentPage = value
// 调接口
this.loadingGetList()
}
}
}
</script>
<style scoped>
</style>