alarmLog.vue
7.21 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
<template>
<div class="alarmLog">
<div class="page_title">
<h2 class="h2">处理日志</h2>
<h3 class="h3">用于统计和展示跟踪车辆警情的日志</h3>
</div>
<!-- 搜索区域 开始 -->
<div class="search_box">
<el-form :inline="true" size="small">
<el-form-item label="关键字">
<el-input v-model.trim="searchForm.keywords" class="longInput" maxlength="20" placeholder="设备号|车架号|姓名|业务工单号"></el-input>
</el-form-item>
<el-form-item label="车辆归属:">
<el-popover v-model="filterVisible" placement="bottom-start" width="400" trigger="click">
<div>
<glsx-organization @change="onChange"></glsx-organization>
</div>
<el-input v-model="searchForm.orgName" :placeholder="searchForm.specialShopName || '所属组织'" slot="reference" readonly clearable>
</el-input>
</el-popover>
</el-form-item>
<el-form-item label="">
<el-date-picker v-model="searchForm.offDate" type="daterange" class="data_picker" :clearable="false" unlink-panels range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd" :picker-options="offPickerOptions">
</el-date-picker>
</el-form-item>
<el-form-item label="报警等级:">
<el-select v-model="searchForm.alarmLevel" class="small_select">
<el-option v-for="(item, index) in alarmLevelList" :key="index" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="searchEvent()">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button icon="el-icon-refresh" type="default" @click="rest()">重置</el-button>
</el-form-item>
</el-form>
</div>
<!-- 搜索区域 end -->
<!-- 操作区域 开始 -->
<div class="links_group">
<span class="name">处理日志列表</span>
<el-button type="primary" size="small" icon="el-icon-download" :loading="dloading" @click="downloadExcel()">导出excel</el-button>
</div>
<!-- 操作区域 end -->
<!-- 表格区域 开始 -->
<div class="table_box">
<glsx-table ref="glsxTable" v-loading="loading" :params="tableParams" :request="GET_ALARM_HANDLE_LOG" :column="columnList">
<div slot="operate" slot-scope="{scope}">
<el-link type="primary" :unline="false" :id="scope.id" @click="lookDetail(scope)">详情</el-link>
</div>
</glsx-table>
</div>
<!-- 表格区域 end -->
</div>
</template>
<script>
import moment from "moment";
import { GET_ALARM_HANDLE_LOG, GET_ALARM_HANDLE_LOG_EXPORT } from "@/services/alarmCenter";
import { deepClone, downFileByPath } from "@/utils/util";
import GlsxOrganization from "@/components/glsx-organization";
import { alarmLogShortcuts } from "@/common"
import GlsxTable from "@/components/glsx-table/table";
import qs from "qs";
export default {
components: {
GlsxTable,
GlsxOrganization
},
data() {
return {
searchForm: {offDate: ["", ""], alarmLevel: ""},
offPickerOptions: {
shortcuts: alarmLogShortcuts,
},
filterVisible: false,
orgInfo: {},
dloading: false,
loading: false,
columnList: [
{ label: "业务工单号/姓名/设备号/车架号", prop: "workOrderNo", formatter:row => {return this.filterText(row, ['workOrderNo', 'ownerName', 'sns', 'vin'], '/')} },
{ label: "警情等级", prop: "alarmLevel", width: "100", formatter: row => {return `${row.alarmLevel}级`} },
{ label: "报警说明&建议", prop: "alarmExplain", formatter: row => {return this.filterText(row, ['alarmExplain', 'alarmSuggest'], '&')} },
{ label: "采取措施&备注", prop: "remark", formatter: row => {return this.filterText(row, ['resolvent', 'remark'], '\n', true)} },
{ label: "处理时间", prop: "processTime" },
],
tableParams: {},
GET_ALARM_HANDLE_LOG,
alarmLevelList:[
{name:'全部',id:''},
{name:'1级',id:'1'},
{name:'2级',id:'2'},
{name:'3级',id:'3'},
{name:'4级',id:'4'},
// {name:'5级',id:'5'},
]
};
},
created() {
// this.defaultDate();
this.tableParams = this.getParams();
},
mounted() {},
methods: {
// 初始化时间
// defaultDate() {
// let end = moment().subtract(0, 'days').endOf('day').format('YYYY-MM-DD HH:mm:ss');
// let start = moment().subtract(0, 'days').startOf('day').format('YYYY-MM-DD HH:mm:ss');
// this.$set(this.searchForm, "offDate", [start, end]);
// },
// 重置
rest() {
// this.defaultDate();
this.searchForm = {offDate: ["", ""], alarmLevel: ""}
this.$refs.glsxTable.restParams()
this.tableParams = this.getParams();
},
// 搜索
searchEvent() {
this.$refs.glsxTable.restParams();
this.tableParams = this.getParams();
},
// 字段处理
filterText(row, filedList, type, hasLabel = false) {
let textResult = []
let label = ['措施', '备注']
filedList.map((val, index) => {
textResult.push(hasLabel ? `<span style="overflow: hidden;text-overflow: ellipsis; white-space: nowrap;margin: 5px 0;">${label[index] + ':' + (row[val] || '--')}</span>` : `${(row[val] || '--')}`)
})
return textResult.join(` ${type} `)
},
// 获取查询参数
getParams() {
let oParams = deepClone(this.searchForm);
let n = oParams.offDate;
if (n && n.length > 0) {
oParams.processStartTime = n[0] && moment(n[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss');
oParams.processEndTime = n[1] && moment(n[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss');
}
delete oParams.offDate;
delete oParams.orgName;
return oParams;
},
// 监听树
onChange(e) {
this.filterVisible = false;
if (e) {
this.orgInfo = e.origin;
this.searchForm.orgId = e.origin.orgId;
this.searchForm.orgType = e.origin.type;
this.searchForm.orgName = e.origin.orgName;
}
},
// 导出excel
downloadExcel() {
let _this = this;
let oParams = this.getParams();
_this.dloading = true;
GET_ALARM_HANDLE_LOG_EXPORT(oParams).then((res) => {
_this.dloading = false;
if (res.code != 200) {
return false;
}
// window.open(res.data);
downFileByPath(res.data)
});
},
// 查看详情
lookDetail(row) {
let oParams = {
alarmId: row.alarmId,
alarmTime: row.alarmTime && row.alarmTime.split(' ')[0],
vehicleId: row.vehicleId
}
let path = `#/alarmCenter/alarm/detail?${qs.stringify(oParams)}`;
// window.open(path)
var newwindow = window.open('_blank');
newwindow.location = path;
},
},
};
</script>
<style lang="scss" scoped>
@import "@/styles/hadoop.scss";
.search_box{
.longInput{
width: 220px;
}
}
</style>
<style lang="scss">
.alarmLog{
.table_box{
.el-table{
.cell{
white-space: pre-line;
}
}
}
}
.el-tooltip__popper{
width: 30%;
}
</style>