violationCaseTable.vue
4.89 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
<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" 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"
type="daterange"
:picker-options="pickerOptions"
range-separator="至"
start-placeholder="开始日期"
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">
{{ owningRegion != "" && owningRegion != null ? owningRegion : "长沙市" }}
</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 {getAreaList} from "@/api/casefile/remoteServer";
export default {
name: "caseTable",
props: {},
data() {
return {
tableData: [],
owningRegion: "",
createTime: [],
areas: [],
hackReset: false,
pickerMinDate: null,
pickerMaxDate: null,
pickerOptions: {
onPick: ({ maxDate, minDate }) => {
if (minDate && this.pickerMinDate) {
this.pickerMinDate = null;
} else if (minDate) {
this.pickerMinDate = minDate.getTime();
}
},
disabledDate: (time) => {
if (this.pickerMinDate) {
const day1 = 30 * 24 * 3600 * 1000
let maxTime = this.pickerMinDate + day1
let minTime = this.pickerMinDate - day1
return time.getTime() > maxTime || time.getTime()<minTime || time.getTime() > Date.now()
} else {
return time.getTime() > Date.now()
}
},
},
}
},
created() {
caseTable({owningRegion: "", startDate: "", endDate: ""}).then(res => {
this.tableData = res.data;
this.hackReset = true;
});
getAreaList().then(res => {
this.areas = res.data;
});
},
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) + "%";
}
}
})
return sums;
},
handleQuery() {
let startDate = null;
let endDate = null;
if(this.createTime.length!=0){
startDate = this.formatDate(this.createTime[0]);
endDate = this.formatDate(this.createTime[1]);
}
caseTable({owningRegion: this.owningRegion, startDate: startDate, endDate: endDate}).then(res => {
this.tableData = res.data;
this.hackReset = false;
this.$nextTick(() => {
this.hackReset = true
})
});
},
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
}
}
</script>
<style scoped>
</style>