Files
wvp-platform/web_src/src/components/JTChannelList.vue

330 lines
11 KiB
Vue
Raw Normal View History

2024-06-07 00:10:36 +08:00
<template>
<div id="channelList" style="width: 100%">
<div class="page-header">
<div class="page-title">
<el-button icon="el-icon-back" size="mini" style="font-size: 20px; color: #000;" type="text" @click="showDevice" ></el-button>
<el-divider direction="vertical"></el-divider>
通道列表
</div>
<div class="page-header-btn">
<div style="display: inline;">
搜索:
<el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
<el-button icon="el-icon-plus" size="mini" style="margin-right: 1rem;" type="primary" @click="add">添加通道</el-button>
<el-button icon="el-icon-refresh-right" circle size="mini" @click="refresh()"></el-button>
</div>
</div>
</div>
<devicePlayer ref="devicePlayer"></devicePlayer>
<el-container v-loading="isLoging" style="height: 82vh;">
<el-main style="padding: 5px;">
<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>
<el-table-column prop="name" label="名称" min-width="180">
</el-table-column>
<el-table-column label="快照" min-width="100">
<template v-slot:default="scope">
<el-image
:src="getSnap(scope.row)"
:preview-src-list="getBigSnap(scope.row)"
@error="getSnapErrorEvent(scope.row.deviceId, scope.row.channelId)"
:fit="'contain'"
style="width: 60px">
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline"></i>
</div>
</el-image>
</template>
</el-table-column>
<el-table-column label="开启音频" min-width="100">
<template slot-scope="scope">
<el-switch @change="updateChannel(scope.row)" v-model="scope.row.hasAudio" active-color="#409EFF">
</el-switch>
</template>
</el-table-column>
<el-table-column label="操作" min-width="340" fixed="right">
<template slot-scope="scope">
<el-button size="medium" v-bind:disabled="device == null || device.online === 0" icon="el-icon-video-play"
type="text" @click="sendDevicePush(scope.row)">播放
</el-button>
<el-button size="medium" v-bind:disabled="device == null || device.online === 0"
icon="el-icon-switch-button"
2024-06-08 00:46:08 +08:00
type="text" style="color: #f56c6c" v-if="!!scope.row.stream"
2024-06-07 00:10:36 +08:00
@click="stopDevicePush(scope.row)">停止
</el-button>
<el-divider direction="vertical"></el-divider>
<el-button
size="medium"
type="text"
icon="el-icon-edit"
@click="handleEdit(scope.row)"
>
编辑
</el-button>
<el-divider direction="vertical"></el-divider>
<el-dropdown @command="(command)=>{moreClick(command, scope.row)}">
<el-button size="medium" type="text" >
更多功能<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="records" v-bind:disabled="device == null || device.online === 0">
设备录像</el-dropdown-item>
<el-dropdown-item command="cloudRecords" v-bind:disabled="device == null || device.online === 0" >
云端录像</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<el-pagination
style="float: right"
@size-change="handleSizeChange"
@current-change="currentChange"
:current-page="currentPage"
:page-size="count"
:page-sizes="[15, 25, 35, 50]"
layout="total, sizes, prev, pager, next"
:total="total">
</el-pagination>
</el-main>
</el-container>
<channelEdit ref="channelEdit"></channelEdit>
<!--设备列表-->
</div>
</template>
<script>
2024-06-08 23:55:06 +08:00
import devicePlayer from './dialog/jtDevicePlayer.vue'
2024-06-07 00:10:36 +08:00
import uiHeader from '../layout/UiHeader.vue'
import DeviceTree from "./common/DeviceTree";
import channelEdit from "./dialog/jtChannelEdit.vue";
2024-06-07 14:03:41 +08:00
import JTDeviceService from "./service/JTDeviceService";
2024-06-07 00:10:36 +08:00
export default {
name: 'channelList',
components: {
channelEdit,
devicePlayer,
uiHeader,
DeviceTree
},
data() {
return {
2024-06-07 14:03:41 +08:00
deviceService: new JTDeviceService(),
2024-06-07 00:10:36 +08:00
device: null,
deviceId: this.$route.params.deviceId,
deviceChannelList: [],
updateLooper: 0, //数据刷新轮训标志
searchSrt: "",
channelType: "",
online: "",
winHeight: window.innerHeight - 200,
currentPage: 1,
count: 15,
total: 0,
beforeUrl: "/jtDeviceList",
isLoging: false,
loadSnap: {},
};
},
mounted() {
2024-06-07 14:35:07 +08:00
this.initParam();
2024-06-07 00:10:36 +08:00
this.initData();
},
destroyed() {
this.$destroy('videojs');
clearTimeout(this.updateLooper);
},
methods: {
initData: function () {
this.getDeviceChannelList();
},
initParam: function () {
this.deviceId = this.$route.params.deviceId;
this.currentPage = 1;
this.count = 15;
2024-06-07 14:35:07 +08:00
this.deviceService.getDevice(this.deviceId, (result) => {
2024-06-08 00:46:08 +08:00
if (result.code === 0) {
this.device = result.data;
}
2024-06-07 14:35:07 +08:00
}, (error) => {
console.log("获取设备信息失败")
console.error(error)
})
2024-06-07 00:10:36 +08:00
},
currentChange: function (val) {
this.currentPage = val;
this.initData();
},
handleSizeChange: function (val) {
this.count = val;
this.getDeviceChannelList();
},
getDeviceChannelList: function () {
2024-06-07 14:35:07 +08:00
if (typeof (this.deviceId) == "undefined") return;
this.deviceService.getAllChannel(this.currentPage, this.count, this.searchSrt, this.deviceId, (data)=>{
2024-06-08 00:46:08 +08:00
console.log(data)
2024-06-07 14:35:07 +08:00
if (data.code === 0) {
this.total = data.data.total;
this.deviceChannelList = data.data.list;
2024-06-07 00:10:36 +08:00
// 防止出现表格错位
2024-06-07 14:35:07 +08:00
this.$nextTick(() => {
this.$refs.channelListTable.doLayout();
2024-06-07 00:10:36 +08:00
})
}
2024-06-07 14:35:07 +08:00
})
2024-06-07 00:10:36 +08:00
},
//通知设备上传媒体流
sendDevicePush: function (itemData) {
this.isLoging = true;
let channelId = itemData.channelId;
2024-06-08 22:58:23 +08:00
console.log("通知设备推流1" + this.device.phoneNumber + " : " + channelId);
2024-06-07 00:10:36 +08:00
this.$axios({
method: 'get',
2024-06-07 14:35:07 +08:00
url: '/api/jt1078/live/start',
2024-06-07 00:10:36 +08:00
params: {
2024-06-07 14:35:07 +08:00
phoneNumber: this.device.phoneNumber,
2024-06-07 14:03:41 +08:00
channelId: channelId,
type: 0,
2024-06-07 00:10:36 +08:00
}
2024-06-08 22:58:23 +08:00
}).then((res)=> {
this.isLoging = false;
2024-06-07 00:10:36 +08:00
if (res.data.code === 0) {
setTimeout(() => {
2024-06-08 22:58:23 +08:00
let snapId = this.device.phoneNumber + "_" + channelId;
this.loadSnap[this.device.phoneNumber + channelId] = 0;
this.getSnapErrorEvent(snapId)
2024-06-07 00:10:36 +08:00
}, 5000)
itemData.streamId = res.data.data.stream;
2024-06-08 22:58:23 +08:00
this.$refs.devicePlayer.openDialog("media", this.device.phoneNumber, channelId, {
2024-06-07 00:10:36 +08:00
streamInfo: res.data.data,
hasAudio: itemData.hasAudio
});
setTimeout(() => {
2024-06-08 22:58:23 +08:00
this.initData();
2024-06-07 00:10:36 +08:00
}, 1000)
} else {
2024-06-08 22:58:23 +08:00
this.$message.error(res.data.msg);
2024-06-07 00:10:36 +08:00
}
2024-06-08 23:11:56 +08:00
}).catch((e)=> {
2024-06-07 00:10:36 +08:00
console.error(e)
2024-06-08 22:58:23 +08:00
this.isLoging = false;
2024-06-07 00:10:36 +08:00
// that.$message.error("请求超时");
});
},
moreClick: function (command, itemData) {
if (command === "records") {
this.queryRecords(itemData)
}else if (command === "cloudRecords") {
this.queryCloudRecords(itemData)
}
},
queryRecords: function (itemData) {
2024-06-09 20:50:59 +08:00
this.$router.push(`/jtRecordDetail/${this.device.phoneNumber}/${itemData.channelId}`)
2024-06-07 00:10:36 +08:00
},
queryCloudRecords: function (itemData) {
let deviceId = this.deviceId;
let channelId = itemData.channelId;
this.$router.push(`/cloudRecordDetail/rtp/${deviceId}_${channelId}`)
},
stopDevicePush: function (itemData) {
this.$axios({
method: 'get',
url: '/api/jt1078/live/stop',
2024-06-07 00:10:36 +08:00
params: {
phoneNumber: this.device.phoneNumber,
channelId: itemData.channelId,
2024-06-07 00:10:36 +08:00
}
2024-06-09 20:50:59 +08:00
}).then((res)=> {
console.log(res)
if (res.data.code === 0) {
this.initData();
}else {
this.$message.error(res.data.msg);
2024-06-07 00:10:36 +08:00
}
2024-06-09 20:50:59 +08:00
}).catch(function (error) {
console.error(error)
2024-06-07 00:10:36 +08:00
});
},
getSnap: function (row) {
let baseUrl = window.baseUrl ? window.baseUrl : "";
2024-06-08 22:58:23 +08:00
return ((process.env.NODE_ENV === 'development') ? process.env.BASE_API : baseUrl) + '/api/device/query/snap/' + this.device.phoneNumber + '/' + row.channelId;
2024-06-07 00:10:36 +08:00
},
getBigSnap: function (row) {
return [this.getSnap(row)]
},
getSnapErrorEvent: function (deviceId, channelId) {
if (typeof (this.loadSnap[deviceId + channelId]) != "undefined") {
console.log("下载截图" + this.loadSnap[deviceId + channelId])
if (this.loadSnap[deviceId + channelId] > 5) {
delete this.loadSnap[deviceId + channelId];
return;
}
setTimeout(() => {
let url = (process.env.NODE_ENV === 'development' ? "debug" : "") + '/api/device/query/snap/' + deviceId + '/' + channelId
this.loadSnap[deviceId + channelId]++
document.getElementById(deviceId + channelId).setAttribute("src", url + '?' + new Date().getTime())
}, 1000)
}
},
showDevice: function () {
this.$router.push(this.beforeUrl).then(() => {
this.initParam();
this.initData();
})
},
search: function () {
this.currentPage = 1;
this.total = 0;
this.initData();
},
updateChannel: function (row) {
this.$axios({
method: 'post',
2024-06-07 00:20:52 +08:00
url: `/api/jt1078/terminal/channel/update`,
2024-06-07 00:10:36 +08:00
params: row
}).then(function (res) {
console.log(JSON.stringify(res));
});
},
refresh: function () {
this.initData();
},
add: function () {
this.$refs.channelEdit.openDialog(null, this.deviceId, () => {
this.$refs.channelEdit.close();
this.$message({
showClose: true,
message: "添加成功",
type: "success",
});
setTimeout(this.getList, 200)
})
},
// 编辑
handleEdit(row) {
2024-06-08 23:11:56 +08:00
this.$refs.channelEdit.openDialog(row, this.deviceId, () => {
this.$refs.channelEdit.close();
this.$message({
showClose: true,
message: "修改成功",
type: "success",
});
setTimeout(this.getList, 200)
})
2024-06-07 00:10:36 +08:00
}
}
};
</script>