result.vue
7.57 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
<template>
<div>
<el-row class="manage-head-wrapper">
<el-col :xs="24" :sm="24">
<div class="manage-select-box">
<el-select v-model="queryForm.mallId" multiple collapse-tags filterable :placeholder="$t('pholder.select')">
<el-option v-for="item in mallListForTerm" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</div>
<div class="manage-select-box">
<el-date-picker v-model="queryForm.timeVal" type="daterange" range-separator="至" size='small' start-placeholder="开始日期" end-placeholder="结束日期">
</el-date-picker>
</div>
<el-button type="primary" class="search-btn" @click="searchFun">{{$t('button.search')}}</el-button>
<el-button type="primary" class="search-btn manage-add-btn" @click="exportFun">{{$t('button.export')}}</el-button>
</el-col>
</el-row>
<el-row class="manage-content">
<el-col :span="24">
<el-table ref="row_table" class="gate-table" :data="tableData" :max-height="tableHeight" style="width: 100%" header-row-class-name="manage-tab-head" @sort-change='sortChange'>
<el-table-column prop="order" :label="$t('table.order')" align="center" width="100"></el-table-column>
<el-table-column prop="mallName" :label="$t('table.squareName')" align="center">
<template slot-scope="scope">
<span style="color: #409EFF;cursor: pointer;" @click="storeHref(scope.row)">{{scope.row.mallName}}</span>
</template>
</el-table-column>
<el-table-column prop="times" sortable='custom' :label="$t('table.inspectionTimes')" align="center"></el-table-column>
<el-table-column prop="lastTime" sortable='custom' :label="$t('table.lastInspectionTime')" align="center"></el-table-column>
<el-table-column prop="lastUser" :label="$t('table.lastInspector')" align="center"></el-table-column>
</el-table>
<el-pagination class="manage-pagination-box" background :current-page="currentPage" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" @size-change="sizeChange" @current-change="cerrentChange" layout="sizes, prev, pager, next, slot" :total="total">
<span class="slot-ele-total">{{$t('table.pageHead')}} {{ total }} {{$t('table.pageTail')}}</span>
</el-pagination>
</el-col>
</el-row>
</div>
</template>
<script>
import moment from 'moment'
export default {
data() {
return {
mallListForTerm: [],
tableData: [],
total: 0,
pageSize: 10,
currentPage: 1,
queryForm: {
mallId: [],
timeVal: [moment().subtract(30, 'days').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')]
},
sortType: 'lastTimeDesc'
};
},
mounted() {
this.getMallListForTerm()
},
computed: {
tableHeight() {
const windowInnerHeight = window.innerHeight;
return windowInnerHeight - windowInnerHeight * 0.24;
}
},
methods: {
sortChange(column) {
// 次数
if (column.prop == 'times') {
this.sortType = column.order == 'descending' ? 'timesDesc' : 'timesAsc'
}
// 巡检时间
if (column.prop == "lastTime") {
this.sortType = column.order == 'descending' ? 'lastTimeDesc' : 'lastTimeAsc'
}
this.searchFun()
},
getMallListForTerm() {
this.mallListForTerm = [];
this.queryForm.mallId = "";
this.$api.base.mall({
accountId: this.$cookie.get('accountId')
}).then(data => {
let result = data.data;
if (result.data.length) {
this.mallListForTerm = result.data;
}
this.getTableData();
})
},
getTableData() {
if (!this.queryForm.timeVal) {
this.$message({
message: '请选择时间范围',
type: 'warning'
});
return
}
let tabelParams = {
pageNum: this.currentPage,
pageSize: this.pageSize,
accountId: this.$cookie.get('accountId'),
mallIds: this.queryForm.mallId.toString(),
startDate: moment(this.queryForm.timeVal[0]).format('YYYY-MM-DD'),
endDate: moment(this.queryForm.timeVal[1]).format('YYYY-MM-DD'),
sort: this.sortType
};
Object.keys(tabelParams).map(key => (!tabelParams[key] ? delete tabelParams[key] : ''));
this.$api.management.getPatrolResultList(tabelParams, null, true).then(data => {
this.tableData = [];
var result = data.data;
if (result.data.list && result.data.list.length) {
result.data.list.forEach((item, index) => {
item.order = (this.currentPage - 1) * this.pageSize + index + 1;
});
}
this.tableData = result.data.list;
this.total = result.data.total;
})
},
sizeChange(val) {
this.pageSize = val;
this.getTableData();
},
cerrentChange(val) {
if (this.currentPage != val) {
this.currentPage = val;
this.getTableData();
}
},
storeHref(data) {
data.startDate = moment(this.queryForm.timeVal[0]).format('YYYY-MM-DD')
data.endDate = moment(this.queryForm.timeVal[1]).format('YYYY-MM-DD')
this.$emit('getStore', data)
},
exportFun() {
let parameter = {
accountId: this.$cookie.get('accountId'),
mallIds: this.queryForm.mallId.toString(),
startDate: moment(this.queryForm.timeVal[0]).format('YYYY-MM-DD'),
endDate: moment(this.queryForm.timeVal[1]).format('YYYY-MM-DD'),
sort:this.sortType
};
let Url = window._vionConfig.apiUrl + "/b-mall-patrol/count/export?";
let dowloadUrl = `${Url}sort=${parameter.sort}&mallIds=${parameter.mallIds}&startDate=${parameter.startDate}&endDate=${parameter.endDate}&patrolType=1&accountId=${parameter.accountId}&authorization=${this.$cookie.get("atoken")}`
window.open(dowloadUrl);
},
searchFun() {
this.currentPage = 1;
this.getTableData();
}
}
};
</script>
<style scoped="scoped" lang="less">
.manage-head-wrapper {
padding-top: 0;
}
.manage-select-box {
/deep/.el-date-editor.el-input__inner {
width: 230px;
}
/deep/.el-select {
width: 200px;
}
}
</style>