...
|
...
|
@@ -9,6 +9,8 @@ import { useChartDataSocket } from './useChartDataSocket' |
9
|
9
|
import { customRequest } from '@/api/external/customRequest'
|
10
|
10
|
import { useFilterFn } from './useFilterFn'
|
11
|
11
|
import { RequestContentTypeEnum } from '@/enums/external/httpEnum'
|
|
12
|
+import dayjs from 'dayjs'
|
|
13
|
+
|
12
|
14
|
|
13
|
15
|
// 获取类型
|
14
|
16
|
type ChartEditStoreType = typeof useChartEditStore
|
...
|
...
|
@@ -67,6 +69,18 @@ export const useChartDataFetch = ( |
67
|
69
|
clearInterval(fetchInterval)
|
68
|
70
|
|
69
|
71
|
const fetchFn = async () => {
|
|
72
|
+ let startTsValue = null
|
|
73
|
+ let endTsValue = null
|
|
74
|
+ const { requestParams } = toRaw(targetComponent.request)
|
|
75
|
+ const { Params } = requestParams
|
|
76
|
+ const { entityType, startTs, endTs } = Params
|
|
77
|
+ const days = Math.ceil((endTs - startTs) / (1 * 60 * 60 * 24 * 1000))
|
|
78
|
+ if (entityType === 'DEVICE') {
|
|
79
|
+ startTsValue = Date.now() - days <= 32 ? 2592000000: days <= 8 ? 604800000 : startTs
|
|
80
|
+ endTsValue = Date.now()
|
|
81
|
+ toRaw(targetComponent.request).requestParams.Params.startTs = startTsValue
|
|
82
|
+ toRaw(targetComponent.request).requestParams.Params.endTs = endTsValue
|
|
83
|
+ }
|
70
|
84
|
const res = await customRequest(toRaw(targetComponent.request))
|
71
|
85
|
if (res) {
|
72
|
86
|
try {
|
...
|
...
|
@@ -106,9 +120,9 @@ export const useChartDataFetch = ( |
106
|
120
|
} catch (error) {
|
107
|
121
|
console.log(error)
|
108
|
122
|
}
|
109
|
|
- }
|
|
123
|
+ }
|
110
|
124
|
|
111
|
|
- if (isPreview()) {
|
|
125
|
+ if (isPreview()) {
|
112
|
126
|
requestIntervalFn()
|
113
|
127
|
const chartEditStore = useChartEditStore()
|
114
|
128
|
const { initial } = useChartDataSocket()
|
...
|
...
|
@@ -116,9 +130,9 @@ export const useChartDataFetch = ( |
116
|
130
|
* 支持分组也可以接受ws
|
117
|
131
|
* 如果是分组并且绑定了ws
|
118
|
132
|
*/
|
119
|
|
- chartEditStore.getComponentList?.forEach((item:CreateComponentType | CreateComponentGroupType)=>{
|
120
|
|
- if(item.isGroup){
|
121
|
|
- if(item.request.requestUrl?.includes('ws')){
|
|
133
|
+ chartEditStore.getComponentList?.forEach((item: CreateComponentType | CreateComponentGroupType) => {
|
|
134
|
+ if (item.isGroup) {
|
|
135
|
+ if (item.request.requestUrl?.includes('ws')) {
|
122
|
136
|
initial(item, useChartEditStore, updateCallback)
|
123
|
137
|
}
|
124
|
138
|
}
|
...
|
...
|
|