|
|
@@ -33,7 +33,7 @@
|
|
33
|
33
|
|
|
34
|
34
|
<script setup>
|
|
35
|
35
|
import ChartsContainer from '../ChartsContainer.vue';
|
|
36
|
|
-import { ref } from 'vue';
|
|
|
36
|
+import { ref, watch } from 'vue';
|
|
37
|
37
|
import { getSiteStatistics, getModuleMetrics, getRankInfo } from '@/api/item/items'
|
|
38
|
38
|
import { useTimeOut } from '../pageItems/useTimeOut'
|
|
39
|
39
|
const props = defineProps({
|
|
|
@@ -50,49 +50,70 @@ const rowTableItem = ref({
|
|
50
|
50
|
})
|
|
51
|
51
|
const rank = ref({})
|
|
52
|
52
|
const params = inject('provideParams')
|
|
53
|
|
-useTimeOut(() => {
|
|
54
|
|
- !props.type && params.value.deptId && getSiteStatistics({ deptId: params.value.deptId }).then(res => {
|
|
55
|
|
- tableData.value = res.data
|
|
56
|
|
- })
|
|
|
53
|
+
|
|
|
54
|
+// 封装API请求函数
|
|
|
55
|
+const fetchData = () => {
|
|
|
56
|
+ // 站点统计请求(当没有type时)
|
|
|
57
|
+ if (!props.type && params.value.deptId) {
|
|
|
58
|
+ getSiteStatistics({ deptId: params.value.deptId }).then(res => {
|
|
|
59
|
+ tableData.value = res.data
|
|
|
60
|
+ })
|
|
|
61
|
+ }
|
|
|
62
|
+
|
|
|
63
|
+ // 构建API参数
|
|
57
|
64
|
let apiParams = {}
|
|
58
|
65
|
if (props.type === 'personal') {
|
|
59
|
66
|
apiParams = { userId: params.value.deptId }
|
|
60
|
67
|
} else {
|
|
61
|
68
|
apiParams = { deptId: params.value.deptId }
|
|
62
|
69
|
}
|
|
63
|
|
- props.type && params.value.deptId && getModuleMetrics({ ...apiParams, userTypeStr: props.type }).then(res => {
|
|
64
|
|
- const { moduleResults } = res.data
|
|
65
|
|
- if (!moduleResults || Object.keys(moduleResults).length === 0) {
|
|
66
|
|
- moduleResults = {
|
|
67
|
|
- item: {
|
|
68
|
|
- effectiveSeizureCount: {},
|
|
69
|
|
- referToPoliceCount: {},
|
|
70
|
|
- willfulConcealmentCount: {},
|
|
|
70
|
+
|
|
|
71
|
+ // 模块指标请求(当有type时)
|
|
|
72
|
+ if (props.type && params.value.deptId) {
|
|
|
73
|
+ getModuleMetrics({ ...apiParams, userTypeStr: props.type }).then(res => {
|
|
|
74
|
+ let { moduleResults } = res.data
|
|
|
75
|
+ if (!moduleResults || Object.keys(moduleResults).length === 0) {
|
|
|
76
|
+ moduleResults = {
|
|
|
77
|
+ item: {
|
|
|
78
|
+ effectiveSeizureCount: {},
|
|
|
79
|
+ referToPoliceCount: {},
|
|
|
80
|
+ willfulConcealmentCount: {},
|
|
|
81
|
+ }
|
|
71
|
82
|
}
|
|
72
|
83
|
}
|
|
73
|
|
- }
|
|
74
|
84
|
|
|
75
|
|
- if (props.type === 'personal') {
|
|
76
|
|
- rowTableItem.value = {
|
|
77
|
|
- effectiveSeizureCount: {
|
|
78
|
|
- totalCount: moduleResults.item.effectiveSeizureCount
|
|
79
|
|
- },
|
|
80
|
|
- referToPoliceCount: {
|
|
81
|
|
- count: moduleResults.item.referToPoliceCount
|
|
82
|
|
- },
|
|
83
|
|
- willfulConcealmentCount: {
|
|
84
|
|
- count: moduleResults.item.willfulConcealmentCount
|
|
85
|
|
- },
|
|
|
85
|
+ if (props.type === 'personal') {
|
|
|
86
|
+ rowTableItem.value = {
|
|
|
87
|
+ effectiveSeizureCount: {
|
|
|
88
|
+ totalCount: moduleResults.item.effectiveSeizureCount
|
|
|
89
|
+ },
|
|
|
90
|
+ referToPoliceCount: {
|
|
|
91
|
+ count: moduleResults.item.referToPoliceCount
|
|
|
92
|
+ },
|
|
|
93
|
+ willfulConcealmentCount: {
|
|
|
94
|
+ count: moduleResults.item.willfulConcealmentCount
|
|
|
95
|
+ },
|
|
|
96
|
+ }
|
|
|
97
|
+ } else {
|
|
|
98
|
+ rowTableItem.value = moduleResults.item
|
|
86
|
99
|
}
|
|
87
|
|
- } else {
|
|
88
|
|
- rowTableItem.value = moduleResults.item
|
|
|
100
|
+ })
|
|
|
101
|
+
|
|
|
102
|
+ // 排名信息请求
|
|
|
103
|
+ getRankInfo({ ...apiParams, level: 'station' }).then(res => {
|
|
|
104
|
+ rank.value = res.data || {};
|
|
|
105
|
+ })
|
|
|
106
|
+ }
|
|
|
107
|
+}
|
|
89
|
108
|
|
|
90
|
|
- }
|
|
|
109
|
+// 监听props.type变化
|
|
|
110
|
+watch(() => props.type, () => {
|
|
|
111
|
+ fetchData()
|
|
|
112
|
+})
|
|
91
|
113
|
|
|
92
|
|
- })
|
|
93
|
|
- props.type && params.value.deptId && getRankInfo({ ...apiParams, level: 'station' }).then(res => {
|
|
94
|
|
- rank.value = res.data || {};
|
|
95
|
|
- })
|
|
|
114
|
+// 使用定时器调用fetchData
|
|
|
115
|
+useTimeOut(() => {
|
|
|
116
|
+ fetchData()
|
|
96
|
117
|
}, [ params ])
|
|
97
|
118
|
|
|
98
|
119
|
|