|
|
@@ -41,7 +41,6 @@
|
|
41
|
41
|
playsinline
|
|
42
|
42
|
controls
|
|
43
|
43
|
class="video-player"
|
|
44
|
|
- style="width: 100%; height: 100%; object-fit: contain;"
|
|
45
|
44
|
autoplay
|
|
46
|
45
|
muted
|
|
47
|
46
|
></video>
|
|
|
@@ -60,6 +59,10 @@ import { getPageListData } from '@/api/index'
|
|
60
|
59
|
import videoSrc from '@/assets/mp4/ziyuan.mp4'
|
|
61
|
60
|
import defaultImg from '@/assets/defaultImg.png'
|
|
62
|
61
|
import axios from 'axios'
|
|
|
62
|
+import { getToken } from '@/utils/auth'
|
|
|
63
|
+import { ElMessage } from 'element-plus'
|
|
|
64
|
+
|
|
|
65
|
+
|
|
63
|
66
|
|
|
64
|
67
|
// 监控设备列表(响应式数据)
|
|
65
|
68
|
const videoList = ref([])
|
|
|
@@ -86,8 +89,8 @@ const fetchDriveInfoList = async () => {
|
|
86
|
89
|
return {
|
|
87
|
90
|
name: device.deviceName || device.fRemark || '未知监控设备',
|
|
88
|
91
|
time: formattedTime,
|
|
89
|
|
- deviceId: device.id || device.deviceId || '',
|
|
90
|
|
- streamUrl: 'rtsp://'+device.fAccount+':'+device.fPassword+'@'+device.fIp,
|
|
|
92
|
+ deviceId: device.fDriveid,
|
|
|
93
|
+ streamUrl: device.url,
|
|
91
|
94
|
fImg: device.fImg || '' // 保存设备图片地址
|
|
92
|
95
|
}
|
|
93
|
96
|
})
|
|
|
@@ -134,14 +137,18 @@ watch(() => props.selectedProjectId, () => {
|
|
134
|
137
|
// 重新获取数据
|
|
135
|
138
|
fetchDriveInfoList();
|
|
136
|
139
|
}, { immediate: true })
|
|
137
|
|
-
|
|
|
140
|
+const fDriveid = ref('')
|
|
138
|
141
|
// 关闭所有视频并打开模态框
|
|
139
|
142
|
function closeAllVideosAndOpenModal(video) {
|
|
140
|
|
-
|
|
|
143
|
+ if (!video.streamUrl) {
|
|
|
144
|
+ ElMessage.warning('视频流URL为空,无法播放');
|
|
|
145
|
+
|
|
|
146
|
+ return;
|
|
|
147
|
+ }
|
|
141
|
148
|
// 打开模态框播放当前视频
|
|
142
|
149
|
selectedVideo.value = video
|
|
143
|
150
|
isModalOpen.value = true
|
|
144
|
|
-
|
|
|
151
|
+ fDriveid.value = video.deviceId
|
|
145
|
152
|
// 等待模态框完全渲染后初始化视频元素并自动播放
|
|
146
|
153
|
setTimeout(() => {
|
|
147
|
154
|
if (videoElement.value) {
|
|
|
@@ -159,7 +166,7 @@ function closeAllVideosAndOpenModal(video) {
|
|
159
|
166
|
// 关闭视频播放模态框
|
|
160
|
167
|
function closeModal() {
|
|
161
|
168
|
// 先触发截图并上传
|
|
162
|
|
- // captureAndUploadSnapshot();
|
|
|
169
|
+ captureAndUploadSnapshot();
|
|
163
|
170
|
|
|
164
|
171
|
// 停止视频播放
|
|
165
|
172
|
if (videoElement.value) {
|
|
|
@@ -204,29 +211,57 @@ async function captureAndUploadSnapshot() {
|
|
204
|
211
|
console.warn('创建截图失败');
|
|
205
|
212
|
return;
|
|
206
|
213
|
}
|
|
207
|
|
-
|
|
|
214
|
+ console.log('截图创建成功,大小:', blob.size);
|
|
208
|
215
|
try {
|
|
209
|
|
- // 创建FormData用于上传
|
|
|
216
|
+ // 创建FormData用于上传,添加文件名参数
|
|
210
|
217
|
const formData = new FormData();
|
|
211
|
|
- const fileName = `${selectedVideo.value?.deviceId || 'unknown'}_${new Date().getTime()}_snapshot.jpg`;
|
|
|
218
|
+ // 为文件添加文件名参数,格式为:监控截图_时间戳.jpg
|
|
|
219
|
+ const fileName = `监控截图_${Date.now()}.jpg`;
|
|
212
|
220
|
formData.append('file', blob, fileName);
|
|
213
|
221
|
|
|
214
|
|
- // 添加其他可能需要的参数
|
|
215
|
|
- if (selectedVideo.value) {
|
|
216
|
|
- formData.append('deviceId', selectedVideo.value.deviceId);
|
|
217
|
|
- formData.append('deviceName', selectedVideo.value.name);
|
|
218
|
|
- }
|
|
219
|
|
-
|
|
220
|
222
|
// 上传图片到指定接口
|
|
221
|
|
- const response = await axios.post('/file/uploadFacilityFile', formData, {
|
|
|
223
|
+ const response = await axios.post(import.meta.env.VITE_APP_BASE_API +'/file/uploadFile', formData, {
|
|
222
|
224
|
headers: {
|
|
223
|
225
|
'Content-Type': 'multipart/form-data',
|
|
224
|
|
- 'token': localStorage.getItem('token') || ''
|
|
|
226
|
+ 'fSource':2,
|
|
|
227
|
+ 'token':getToken()
|
|
225
|
228
|
},
|
|
226
|
229
|
timeout: 10000 // 设置10秒超时
|
|
227
|
230
|
});
|
|
228
|
231
|
|
|
229
|
232
|
console.log('截图上传成功:', response.data);
|
|
|
233
|
+ // 上传成功后保存图片路径到设备信息
|
|
|
234
|
+ if (response.data && response.data.data && response.data.data[0]) {
|
|
|
235
|
+ const fFileurl = response.data.data[0].fFileurl;
|
|
|
236
|
+ // 获取当前设备ID
|
|
|
237
|
+
|
|
|
238
|
+
|
|
|
239
|
+ // 调用更新设备信息接口保存图片路径
|
|
|
240
|
+ try {
|
|
|
241
|
+ if (!fDriveid.value) {
|
|
|
242
|
+ console.warn('设备ID为空,无法保存图片路径');
|
|
|
243
|
+ return;
|
|
|
244
|
+ }
|
|
|
245
|
+ await axios.post(import.meta.env.VITE_APP_BASE_API + 'tbasedriveinfo/updateDriveInfo', {
|
|
|
246
|
+ data: {
|
|
|
247
|
+ fDriveid: fDriveid.value,
|
|
|
248
|
+ fImg: fFileurl,
|
|
|
249
|
+ }
|
|
|
250
|
+ }, {
|
|
|
251
|
+ headers: {
|
|
|
252
|
+ 'Content-Type': 'application/json',
|
|
|
253
|
+ 'token': getToken(),
|
|
|
254
|
+ 'fSource':2
|
|
|
255
|
+ }
|
|
|
256
|
+ });
|
|
|
257
|
+ fDriveid.value = ''
|
|
|
258
|
+ fetchDriveInfoList()
|
|
|
259
|
+ console.log('图片路径保存成功');
|
|
|
260
|
+ } catch (saveError) {
|
|
|
261
|
+ console.error('图片路径保存失败:', saveError.message || saveError);
|
|
|
262
|
+ }
|
|
|
263
|
+ }
|
|
|
264
|
+
|
|
230
|
265
|
} catch (uploadError) {
|
|
231
|
266
|
console.error('截图上传失败:', uploadError.message || uploadError);
|
|
232
|
267
|
}
|
|
|
@@ -551,7 +586,6 @@ onUnmounted(() => {
|
|
551
|
586
|
height: 72vh;
|
|
552
|
587
|
background-image: url('@/assets/bj2.png');
|
|
553
|
588
|
background-size: 100% 100%;
|
|
554
|
|
- background-size: cover;
|
|
555
|
589
|
background-position: center;
|
|
556
|
590
|
background-repeat: no-repeat;
|
|
557
|
591
|
border-radius: 6px;
|
|
|
@@ -564,7 +598,7 @@ onUnmounted(() => {
|
|
564
|
598
|
flex: 1;
|
|
565
|
599
|
display: flex;
|
|
566
|
600
|
flex-direction: column;
|
|
567
|
|
-
|
|
|
601
|
+ height: 100%;
|
|
568
|
602
|
.video-wrapper {
|
|
569
|
603
|
position: relative;
|
|
570
|
604
|
flex: 1;
|
|
|
@@ -577,7 +611,7 @@ onUnmounted(() => {
|
|
577
|
611
|
.video-player {
|
|
578
|
612
|
width: 100%;
|
|
579
|
613
|
height: 100%;
|
|
580
|
|
- object-fit: contain;
|
|
|
614
|
+ object-fit: cover;
|
|
581
|
615
|
background: #000;
|
|
582
|
616
|
cursor: pointer;
|
|
583
|
617
|
}
|