violationCaseTable.vue
4.25 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
<template>
<div class="app-container">
<el-form ref="queryForm" :inline="true" label-width="105px">
<el-form-item label="所属区域" prop="owningRegion">
<el-select v-model="owningRegion" multiple placeholder="请选择所属区域" clearable size="small">
<el-option v-for="item in areas" :label="item.name" :value="item.name" />
</el-select>
</el-form-item>
<el-form-item label="日期" prop="createTime">
<el-date-picker
v-model="createTime"
size="small"
type="datetimerange"
start-placeholder="开始日期"
value-format="yyyy-MM-dd HH:mm:ss"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
</el-form-item>
</el-form>
<el-table :data="tableData" :span-method="spanMethod" :show-summary="true" :summary-method="getSummaries"
v-if="hackReset">
<el-table-column label="行政范围" header-align="center" align="center">
<template slot-scope="scope">
<h3>
{{ owningRegion != "" && owningRegion != null ? owningRegion+"" : "长沙市" }}</h3>
<h4>
该区域信息数{{allCount[2]}},回复数{{allCount[3]}},回复率{{allCount[4]}}
</h4>
</template>
</el-table-column>
<el-table-column property="type" label="预警类型" header-align="center" align="center"></el-table-column>
<el-table-column property="count" label="预警信息数" header-align="center" align="center"></el-table-column>
<el-table-column property="repCount" label="预警信息回复数" header-align="center"
align="center"></el-table-column>
<el-table-column property="repPct" label="预警信息回复率" header-align="center" align="center"></el-table-column>
</el-table>
</div>
</template>
<script>
import {caseTable} from "@/api/casefile/violationCaseFile";
import {getArea} from "@/api/dict";
export default {
name: "caseTable",
props: {},
data() {
return {
tableData: [],
owningRegion: "",
createTime: [],
areas: [],
hackReset: false,
pickerMinDate: null,
pickerMaxDate: null,
allCount:[]
}
},
created() {
caseTable({owningRegion: "", startDate: "", endDate: ""}).then(res => {
this.tableData = res.data;
this.hackReset = true;
});
getArea().then(res => {
this.areas = res.result;
});
},
methods: {
spanMethod({row, column, rowIndex, columnIndex}) {
if (columnIndex == 0) {
if (rowIndex == 0) {
return {rowspan: 300, colspan: 1}
} else {
return {rowspan: 0, colspan: 0}
}
}
},
getSummaries(param) {
const {columns, data} = param;
const sums = [];
let allCount = 0;
let allRepCount = 0;
for (let i in data) {
allCount += Number(data[i].count == null ? 0 : data[i].count);
allRepCount += Number(data[i].repCount == null ? 0 : data[i].repCount);
}
columns.forEach((column, index) => {
if (index == 0 || index == 1) {
return;
}
if (index == 2) {
sums[2] = allCount;
}
if (index == 3) {
sums[3] = allRepCount;
}
if (index == 4) {
if (allCount == 0 || allRepCount == 0) {
sums[4] = "0" + "%";
} else {
sums[4] = ((allRepCount / allCount) * 100).toFixed(2) + "%";
}
}
})
this.allCount = sums;
return sums;
},
handleQuery() {
let startDate = null;
let endDate = null;
if(this.createTime.length!=0){
startDate = this.createTime[0];
endDate = this.createTime[1];
}
let owningRegion = null;
if(this.owningRegion)
owningRegion = this.owningRegion + ""
caseTable({owningRegion: owningRegion, startDate: startDate, endDate: endDate}).then(res => {
this.tableData = res.data;
this.hackReset = false;
this.$nextTick(() => {
this.hackReset = true
})
});
},
}
}
</script>
<style scoped>
</style>