index.ts
4.85 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import { defHttp } from '@/utils/external/http/axios'
import { CameraRecord, ConfigurationItemType, DictItem, OrganizationListItem, UploadResponse } from './model'
import { PaginationResult } from '/#/external/axios'
import { isShareMode } from '@/views/share/hook'
enum Api {
GET_DICT = '/dict_item',
UPLOAD = '/oss/upload',
DOWNLOAD = '/oss/download_file/',
AREALIST = '/area/list',
PLATFORM = '/platform/get',
CONFIGURATION = '/configuration/center',
CONFIGURATION_SHARE = '/configuration/center/share/',
BASEORIGINATION = '/organization/me/list/',
VIDEO = '/video/list',
DEVICE_PROFILE = '/device_profile/me/list',
DEVICE = '/device',
VIDEOURL = '/video/url/',
GEOJSONURL = '/map/geo_json/',
DEVICE_URL = '/device',
GET_ATTRBUTELIST = '/device/attributes/',
GET_DEVICE_LATEST = '/plugins/telemetry/DEVICE/',
DEVICE_ATTR = '/device/attributes',
ALARM_LIST = '/alarm',
BASE_DELETE_URL = '/oss',
DATA_SQL = '/dbConnect',
}
//sql选择列表
export const getDataViewSqlPage = (params: object) => {
return defHttp.get<PaginationResult<ConfigurationItemType>>({ url: `${Api.DATA_SQL}`, params })
}
//保存和更新组件SQL查询配置
export const saveDictItemByCode = (params: object) => {
return defHttp.post<DictItem[]>({
url: `${Api.DATA_SQL}/saveDataSet`,
params: params
})
}
//预览大屏查询组件数据
export const getDataView = (params: object) => {
return defHttp.post<DictItem[]>({
url: `${Api.DATA_SQL}/getDataView`,
params: params
})
}
export const getDictItemByCode = (value: string) => {
return defHttp.post<DictItem[]>({
url: `${Api.GET_DICT}/find`,
params: {
dictCode: value
}
})
}
export const upload = (file: FormData) => {
return defHttp.post<UploadResponse>({
url: Api.UPLOAD,
params: file
})
}
export const downloadFile = (fileName: string) => {
return defHttp.get({ url: `${Api.DOWNLOAD}${fileName}` })
}
//获取区域
export const getAreaList = (data: object) => {
return defHttp.post<any>({
url: Api.AREALIST,
data
})
}
//获取企业定制
export const getPlatformInfo = () => defHttp.get({ url: Api.PLATFORM })
//获取组态列表
export const getConfigurationList = (params: object) => {
return defHttp.get<PaginationResult<ConfigurationItemType>>({ url: `${Api.CONFIGURATION}`, params })
}
//组态设置是否公开或私有
export const setConfigurationIsShare = (params: string, isShare: boolean, data: object) => {
return defHttp.post({
url: `${Api.CONFIGURATION_SHARE}${params}?isShare=${isShare}`,
data
})
}
// 获取设备状态,在线 or 离线时间
export const getDeviceActiveTime = (entityId: string) => {
return defHttp.get(
{
url: `/plugins/telemetry/DEVICE/${entityId}/values/attributes?keys=active`
},
{
joinPrefix: false
}
)
}
//获取组织列表
export const getOrganizationList = (params?: OrganizationListItem) =>
defHttp.get({
url: Api.BASEORIGINATION,
params
})
//获取视频列表
export const getVideoList = (params?: object) =>
defHttp.get<{ data: CameraRecord[] }>({
url: Api.VIDEO,
params
})
//获取产品列表
export const getProfileList = (params?: object) =>
defHttp.get({
url: Api.DEVICE_PROFILE,
params
})
//获取设备列表
export const getDeviceList = (params: any, data?: object) =>
defHttp.post({
url: Api.DEVICE,
params,
data
})
//获取平台视频流播放地址
export const getVideoUrl = (id: string) =>
defHttp.get({
url: `${Api.VIDEOURL}${id}`
}, {
withShareToken: true
})
//获取行政区域
export const getGeoJsonMap = (code: number | string, level: string) => {
return defHttp.get({
url: `${Api.GEOJSONURL}${code}/${level}`
}, { withShareToken: isShareMode() })
}
// 获取设备详情
export const getDeviceDetail = (id: string) =>
defHttp.get({
url: Api.DEVICE_URL + `/${id}`
})
// 获取产品属性
export const getAttribute = (deviceProfileId: string) =>
defHttp.get({
url: `${Api.GET_ATTRBUTELIST}${deviceProfileId}`
})
// 获取设备最新数据
export const getDeviceLatest = (tbDeviceId: string) =>
defHttp.get({
url: `${Api.GET_DEVICE_LATEST}${tbDeviceId}/values/timeseries`
}, {
joinPrefix: false
})
//获取产品属性
export const getProfileAttrs = (params: { deviceProfileId: string; dataType?: string }) => {
const { deviceProfileId, dataType } = params;
return defHttp.get({
url: `${Api.DEVICE_ATTR}/${deviceProfileId}`,
params: { dataType },
});
};
//获取告警列表
export const getAlarmList = (params?: object) =>
defHttp.get({
url: Api.ALARM_LIST,
params
},
{
withShareToken: true
})
/**
* 删除上传的图片
* @description deleteFilePath图片url
*/
export const deleteFilePath = (deleteFilePath?: string) => {
return defHttp.delete({
url: `${Api.BASE_DELETE_URL}?deleteFilePath=${deleteFilePath}`,
});
};