2025-05-11 08:01:45 +08:00
|
|
|
|
<template>
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<div id="channelList" style="height: calc(100vh - 124px);">
|
2025-05-11 08:01:45 +08:00
|
|
|
|
<div v-if="!jtChannel">
|
2025-05-14 18:01:12 +08:00
|
|
|
|
<el-form :inline="true" size="mini">
|
|
|
|
|
|
<el-form-item style="margin-right: 2rem">
|
|
|
|
|
|
<el-page-header content="通道列表" @back="showDevice" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="搜索">
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="searchSrt"
|
|
|
|
|
|
style="margin-right: 1rem; width: auto;"
|
|
|
|
|
|
placeholder="关键字"
|
|
|
|
|
|
prefix-icon="el-icon-search"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
@input="search"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加通道</el-button>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item style="float: right;">
|
|
|
|
|
|
<el-button icon="el-icon-refresh-right" circle @click="refresh()" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
2025-05-11 08:01:45 +08:00
|
|
|
|
<el-container v-loading="isLoging" style="height: 82vh;">
|
|
|
|
|
|
<el-main style="padding: 5px;">
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<el-table
|
|
|
|
|
|
ref="channelListTable"
|
|
|
|
|
|
:data="deviceChannelList"
|
|
|
|
|
|
:height="winHeight"
|
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
|
header-row-class-name="table-header"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-table-column prop="channelId" label="通道编号" min-width="180" />
|
|
|
|
|
|
<el-table-column prop="name" label="名称" min-width="180" />
|
2025-05-11 08:01:45 +08:00
|
|
|
|
<el-table-column label="快照" min-width="100">
|
|
|
|
|
|
<template v-slot:default="scope">
|
|
|
|
|
|
<el-image
|
|
|
|
|
|
:src="getSnap(scope.row)"
|
|
|
|
|
|
:preview-src-list="getBigSnap(scope.row)"
|
|
|
|
|
|
:fit="'contain'"
|
2025-05-12 18:01:10 +08:00
|
|
|
|
style="width: 60px"
|
|
|
|
|
|
@error="getSnapErrorEvent(scope.row.deviceId, scope.row.channelId)"
|
|
|
|
|
|
>
|
2025-05-11 08:01:45 +08:00
|
|
|
|
<div slot="error" class="image-slot">
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<i class="el-icon-picture-outline" />
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-image>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="开启音频" min-width="100">
|
|
|
|
|
|
<template slot-scope="scope">
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<el-switch v-model="scope.row.hasAudio" active-color="#409EFF" @change="updateChannel(scope.row)" />
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="操作" min-width="340" fixed="right">
|
|
|
|
|
|
<template slot-scope="scope">
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
size="medium"
|
2025-07-16 11:00:43 +08:00
|
|
|
|
:disabled="device == null || !device.status"
|
2025-05-12 18:01:10 +08:00
|
|
|
|
icon="el-icon-video-play"
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
@click="sendDevicePush(scope.row)"
|
|
|
|
|
|
>播放
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</el-button>
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
v-if="!!scope.row.stream"
|
|
|
|
|
|
size="medium"
|
2025-07-16 11:00:43 +08:00
|
|
|
|
:disabled="device == null || !device.status"
|
2025-05-12 18:01:10 +08:00
|
|
|
|
icon="el-icon-switch-button"
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
style="color: #f56c6c"
|
|
|
|
|
|
@click="stopDevicePush(scope.row)"
|
|
|
|
|
|
>停止
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</el-button>
|
2025-07-16 11:00:43 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
size="medium"
|
|
|
|
|
|
:disabled="device == null || !device.status"
|
|
|
|
|
|
icon="el-icon-camera"
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
@click="shooting(scope.row)"
|
|
|
|
|
|
>抓图
|
|
|
|
|
|
</el-button>
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<el-divider direction="vertical" />
|
2025-05-11 08:01:45 +08:00
|
|
|
|
<el-button
|
|
|
|
|
|
size="medium"
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
icon="el-icon-edit"
|
|
|
|
|
|
@click="handleEdit(scope.row)"
|
|
|
|
|
|
>
|
|
|
|
|
|
编辑
|
|
|
|
|
|
</el-button>
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<el-divider direction="vertical" />
|
2025-05-11 08:01:45 +08:00
|
|
|
|
<el-dropdown @command="(command)=>{moreClick(command, scope.row)}">
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<el-button size="medium" type="text">
|
|
|
|
|
|
更多功能<i class="el-icon-arrow-down el-icon--right" />
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</el-button>
|
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
2025-07-16 11:00:43 +08:00
|
|
|
|
<el-dropdown-item command="records" :disabled="device == null || !device.status">
|
2025-05-11 08:01:45 +08:00
|
|
|
|
设备录像</el-dropdown-item>
|
2025-07-16 11:00:43 +08:00
|
|
|
|
<el-dropdown-item command="cloudRecords" :disabled="device == null || !device.status">
|
2025-05-11 08:01:45 +08:00
|
|
|
|
云端录像</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<el-pagination
|
|
|
|
|
|
style="float: right"
|
|
|
|
|
|
:current-page="currentPage"
|
|
|
|
|
|
:page-size="count"
|
|
|
|
|
|
:page-sizes="[15, 25, 35, 50]"
|
|
|
|
|
|
layout="total, sizes, prev, pager, next"
|
2025-05-12 18:01:10 +08:00
|
|
|
|
:total="total"
|
|
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
|
|
@current-change="currentChange"
|
|
|
|
|
|
/>
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</el-main>
|
|
|
|
|
|
</el-container>
|
|
|
|
|
|
</div>
|
2025-05-12 18:01:10 +08:00
|
|
|
|
<devicePlayer ref="devicePlayer" />
|
|
|
|
|
|
<channelEdit v-if="jtChannel" ref="channelEdit" :jt-channel="jtChannel" :close-edit="closeEdit" />
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-07-28 14:32:38 +08:00
|
|
|
|
import devicePlayer from '../dialog/jtDevicePlayer.vue'
|
2025-05-12 18:01:10 +08:00
|
|
|
|
import channelEdit from './edit.vue'
|
2025-07-11 21:41:50 +08:00
|
|
|
|
import dayjs from 'dayjs'
|
2025-05-11 08:01:45 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
name: 'ChannelList',
|
2025-05-11 08:01:45 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
channelEdit,
|
2025-07-11 21:41:50 +08:00
|
|
|
|
devicePlayer
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-14 15:48:35 +08:00
|
|
|
|
props: {
|
|
|
|
|
|
deviceId: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
default: null
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-05-11 08:01:45 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
device: null,
|
|
|
|
|
|
deviceChannelList: [],
|
2025-05-12 18:01:10 +08:00
|
|
|
|
updateLooper: 0, // 数据刷新轮训标志
|
|
|
|
|
|
searchSrt: '',
|
|
|
|
|
|
channelType: '',
|
|
|
|
|
|
online: '',
|
2025-05-11 08:01:45 +08:00
|
|
|
|
winHeight: window.innerHeight - 200,
|
|
|
|
|
|
currentPage: 1,
|
|
|
|
|
|
count: 15,
|
|
|
|
|
|
total: 0,
|
2025-05-12 18:01:10 +08:00
|
|
|
|
beforeUrl: '/jtDeviceList',
|
2025-05-11 08:01:45 +08:00
|
|
|
|
isLoging: false,
|
|
|
|
|
|
loadSnap: {},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
jtChannel: null
|
|
|
|
|
|
}
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
mounted() {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
this.initParam()
|
|
|
|
|
|
this.initData()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
destroyed() {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
this.$destroy('videojs')
|
|
|
|
|
|
clearTimeout(this.updateLooper)
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
initData: function() {
|
|
|
|
|
|
this.getDeviceChannelList()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
initParam: function() {
|
|
|
|
|
|
this.currentPage = 1
|
|
|
|
|
|
this.count = 15
|
2025-05-14 15:48:35 +08:00
|
|
|
|
this.$store.dispatch('jtDevice/queryDeviceById', this.deviceId)
|
|
|
|
|
|
.then(data => {
|
|
|
|
|
|
this.device = data
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(err => {
|
|
|
|
|
|
console.error(err)
|
|
|
|
|
|
})
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
currentChange: function(val) {
|
|
|
|
|
|
this.currentPage = val
|
|
|
|
|
|
this.initData()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
handleSizeChange: function(val) {
|
|
|
|
|
|
this.count = val
|
|
|
|
|
|
this.getDeviceChannelList()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
getDeviceChannelList: function() {
|
|
|
|
|
|
if (typeof (this.deviceId) === 'undefined') return
|
2025-05-14 15:48:35 +08:00
|
|
|
|
this.$store.dispatch('jtDevice/queryChannels', {
|
|
|
|
|
|
page: this.currentPage,
|
|
|
|
|
|
count: this.count,
|
|
|
|
|
|
query: this.searchSrt,
|
|
|
|
|
|
deviceId: this.deviceId
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(data => {
|
|
|
|
|
|
this.total = data.total
|
|
|
|
|
|
this.deviceChannelList = data.list
|
2025-05-11 08:01:45 +08:00
|
|
|
|
// 防止出现表格错位
|
|
|
|
|
|
this.$nextTick(() => {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
this.$refs.channelListTable.doLayout()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
})
|
2025-05-14 15:48:35 +08:00
|
|
|
|
})
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2025-05-12 18:01:10 +08:00
|
|
|
|
// 通知设备上传媒体流
|
|
|
|
|
|
sendDevicePush: function(itemData) {
|
|
|
|
|
|
this.isLoging = true
|
|
|
|
|
|
const channelId = itemData.channelId
|
|
|
|
|
|
console.log('通知设备推流1:' + this.device.phoneNumber + ' : ' + channelId)
|
2025-05-14 15:48:35 +08:00
|
|
|
|
|
|
|
|
|
|
this.$store.dispatch('jtDevice/play', {
|
|
|
|
|
|
phoneNumber: this.device.phoneNumber,
|
|
|
|
|
|
channelId: channelId,
|
|
|
|
|
|
type: 0
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(data => {
|
2025-05-11 08:01:45 +08:00
|
|
|
|
setTimeout(() => {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
const snapId = this.device.phoneNumber + '_' + channelId
|
|
|
|
|
|
this.loadSnap[this.device.phoneNumber + channelId] = 0
|
2025-05-11 08:01:45 +08:00
|
|
|
|
this.getSnapErrorEvent(snapId)
|
|
|
|
|
|
}, 5000)
|
2025-05-14 15:48:35 +08:00
|
|
|
|
itemData.streamId = data.stream
|
2025-05-12 18:01:10 +08:00
|
|
|
|
this.$refs.devicePlayer.openDialog('media', this.device.phoneNumber, channelId, {
|
2025-05-14 15:48:35 +08:00
|
|
|
|
streamInfo: data,
|
2025-05-11 08:01:45 +08:00
|
|
|
|
hasAudio: itemData.hasAudio
|
2025-05-12 18:01:10 +08:00
|
|
|
|
})
|
2025-05-11 08:01:45 +08:00
|
|
|
|
setTimeout(() => {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
this.initData()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
}, 1000)
|
2025-05-14 15:48:35 +08:00
|
|
|
|
})
|
|
|
|
|
|
.catch(err => {
|
|
|
|
|
|
console.error(err)
|
|
|
|
|
|
})
|
|
|
|
|
|
.finally(() => {
|
|
|
|
|
|
this.isLoging = false
|
|
|
|
|
|
})
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
moreClick: function(command, itemData) {
|
|
|
|
|
|
if (command === 'records') {
|
2025-05-11 08:01:45 +08:00
|
|
|
|
this.queryRecords(itemData)
|
2025-05-12 18:01:10 +08:00
|
|
|
|
} else if (command === 'cloudRecords') {
|
2025-05-11 08:01:45 +08:00
|
|
|
|
this.queryCloudRecords(itemData)
|
2025-05-12 18:01:10 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.info('尚不支持')
|
2025-05-11 08:01:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
queryRecords: function(itemData) {
|
2025-05-14 15:48:35 +08:00
|
|
|
|
this.$router.push(`/jtDevice/record/${this.device.phoneNumber}/${itemData.channelId}`)
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
queryCloudRecords: function(itemData) {
|
2025-05-14 15:48:35 +08:00
|
|
|
|
const deviceId = this.device.phoneNumber
|
2025-05-12 18:01:10 +08:00
|
|
|
|
const channelId = itemData.channelId
|
2025-05-15 18:32:03 +08:00
|
|
|
|
this.$router.push(`/cloudRecord/detail/rtp/jt_${deviceId}_${channelId}`)
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
stopDevicePush: function(itemData) {
|
2025-05-14 15:48:35 +08:00
|
|
|
|
this.$store.dispatch('jtDevice/stopPlay', {
|
|
|
|
|
|
phoneNumber: this.device.phoneNumber,
|
|
|
|
|
|
channelId: itemData.channelId
|
2025-05-12 18:01:10 +08:00
|
|
|
|
})
|
2025-05-14 15:48:35 +08:00
|
|
|
|
.then((data) => {
|
|
|
|
|
|
this.initData()
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(function(error) {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
})
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
getSnap: function(row) {
|
|
|
|
|
|
const baseUrl = window.baseUrl ? window.baseUrl : ''
|
2025-05-14 15:48:35 +08:00
|
|
|
|
return ((process.env.NODE_ENV === 'development') ? process.env.VUE_APP_BASE_API : baseUrl) + '/api/device/query/snap/' + this.device.phoneNumber + '/' + row.channelId
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
getBigSnap: function(row) {
|
2025-05-11 08:01:45 +08:00
|
|
|
|
return [this.getSnap(row)]
|
|
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
getSnapErrorEvent: function(deviceId, channelId) {
|
|
|
|
|
|
if (typeof (this.loadSnap[deviceId + channelId]) !== 'undefined') {
|
|
|
|
|
|
console.log('下载截图' + this.loadSnap[deviceId + channelId])
|
2025-05-11 08:01:45 +08:00
|
|
|
|
if (this.loadSnap[deviceId + channelId] > 5) {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
delete this.loadSnap[deviceId + channelId]
|
|
|
|
|
|
return
|
2025-05-11 08:01:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
setTimeout(() => {
|
2025-05-14 15:48:35 +08:00
|
|
|
|
const baseUrl = window.baseUrl ? window.baseUrl : ''
|
|
|
|
|
|
const url = (process.env.NODE_ENV === 'development' ? process.env.VUE_APP_BASE_API : baseUrl) + '/api/device/query/snap/' + deviceId + '/' + channelId
|
2025-05-11 08:01:45 +08:00
|
|
|
|
this.loadSnap[deviceId + channelId]++
|
2025-05-12 18:01:10 +08:00
|
|
|
|
document.getElementById(deviceId + channelId).setAttribute('src', url + '?' + new Date().getTime())
|
2025-05-11 08:01:45 +08:00
|
|
|
|
}, 1000)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
showDevice: function() {
|
2025-05-14 15:48:35 +08:00
|
|
|
|
this.$emit('show-device')
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
search: function() {
|
|
|
|
|
|
this.currentPage = 1
|
|
|
|
|
|
this.total = 0
|
|
|
|
|
|
this.initData()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
updateChannel: function(row) {
|
2025-05-14 15:48:35 +08:00
|
|
|
|
this.$store.dispatch('jtDevice/updateChannel', row)
|
2025-05-14 18:01:12 +08:00
|
|
|
|
.catch((e) => {
|
|
|
|
|
|
console.log(e)
|
2025-05-14 15:48:35 +08:00
|
|
|
|
})
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
refresh: function() {
|
|
|
|
|
|
this.initData()
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
2025-05-12 18:01:10 +08:00
|
|
|
|
add: function() {
|
2025-05-11 08:01:45 +08:00
|
|
|
|
this.jtChannel = {
|
|
|
|
|
|
terminalDbId: this.deviceId
|
2025-05-12 18:01:10 +08:00
|
|
|
|
}
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 编辑
|
|
|
|
|
|
handleEdit(row) {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
this.jtChannel = row
|
2025-05-11 08:01:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 编辑
|
|
|
|
|
|
closeEdit(row) {
|
2025-05-12 18:01:10 +08:00
|
|
|
|
this.jtChannel = null
|
2025-07-11 20:15:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 编辑
|
|
|
|
|
|
shooting(row) {
|
2025-07-16 11:00:43 +08:00
|
|
|
|
this.$message.success('已申请截图,完成后自动下载', { closed: true })
|
2025-07-11 21:41:50 +08:00
|
|
|
|
// 文件下载地址
|
|
|
|
|
|
const baseUrl = window.baseUrl ? window.baseUrl : ''
|
|
|
|
|
|
const fileUrl = ((process.env.NODE_ENV === 'development') ? process.env.VUE_APP_BASE_API : baseUrl) + `/api/jt1078/snap?phoneNumber=${this.device.phoneNumber}&channelId=${row.channelId}`
|
2025-07-22 20:51:03 +08:00
|
|
|
|
let controller = new AbortController()
|
|
|
|
|
|
let signal = controller.signal
|
2025-07-11 21:41:50 +08:00
|
|
|
|
// 设置请求头
|
|
|
|
|
|
const headers = new Headers()
|
|
|
|
|
|
headers.append('access-token', this.$store.getters.token) // 设置授权头,替换YourAccessToken为实际的访问令牌
|
2025-08-08 10:38:38 +08:00
|
|
|
|
|
|
|
|
|
|
let timer = setTimeout(() => {
|
|
|
|
|
|
this.$message.error('等待截图超时', { closed: true })
|
|
|
|
|
|
controller.abort('timeout')
|
|
|
|
|
|
}, 15000)
|
|
|
|
|
|
|
2025-07-11 21:41:50 +08:00
|
|
|
|
// 发起 请求
|
|
|
|
|
|
fetch(fileUrl, {
|
|
|
|
|
|
method: 'GET',
|
2025-07-22 20:51:03 +08:00
|
|
|
|
headers: headers,
|
|
|
|
|
|
signal: signal
|
2025-07-11 21:41:50 +08:00
|
|
|
|
})
|
|
|
|
|
|
.then(response => response.blob())
|
|
|
|
|
|
.then(blob => {
|
2025-08-08 10:38:38 +08:00
|
|
|
|
window.clearTimeout(timer)
|
2025-07-11 21:41:50 +08:00
|
|
|
|
// 创建一个虚拟的链接元素,模拟点击下载
|
|
|
|
|
|
const link = document.createElement('a')
|
|
|
|
|
|
link.href = window.URL.createObjectURL(blob)
|
|
|
|
|
|
link.download = `${this.device.phoneNumber}-${row.channelId}-${dayjs().format('YYYYMMDDHHmmss')}.jpg` // 设置下载文件名,替换filename.ext为实际的文件名和扩展名
|
|
|
|
|
|
document.body.appendChild(link)
|
|
|
|
|
|
// 模拟点击
|
|
|
|
|
|
link.click()
|
|
|
|
|
|
// 移除虚拟链接元素
|
|
|
|
|
|
document.body.removeChild(link)
|
|
|
|
|
|
})
|
2025-08-08 10:38:38 +08:00
|
|
|
|
.catch(error => {
|
|
|
|
|
|
window.clearTimeout(timer)
|
|
|
|
|
|
console.error('下载失败:', error)
|
|
|
|
|
|
})
|
2025-05-11 08:01:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-12 18:01:10 +08:00
|
|
|
|
}
|
2025-05-11 08:01:45 +08:00
|
|
|
|
</script>
|