index.vue
4.78 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
<template>
<BasicTable
class="bg-neutral-100 dark:text-gray-300 dark:bg-dark-700 p-4"
@register="registerTable"
>
<template #toolbar>
<Authority :value="GBT28181_DEVICE_PERMISSION_ENUM.PLAY_SYNC">
<a-button type="primary" @click="handleSyncPlay"
>{{ t('deviceManagement.device.channelSyncText') }}
</a-button>
</Authority>
</template>
<template #hasAudio="{ record }: { record: VideoChannelItemType }">
<Switch
:checked="record.status === 1"
:loading="record.pendingStatus"
:checkedChildren="t('common.onText')"
:unCheckedChildren="t('common.offText')"
@change="(checked: boolean) => handleTurnVideo(checked, record)"
/>
</template>
<template #action="{ record }">
<TableAction
:actions="[
{
label: t('business.playText'),
auth: GBT28181_DEVICE_PERMISSION_ENUM.PLAY_SYNC,
icon: 'ant-design:play-circle-outlined',
onClick: handlePlay.bind(null, record),
ifShow: deviceDetail.isEdge === 0 && record?.status === 'ONLINE', //在线则显示播放按钮,边端同步到云端的视频设备,不能进行点播。
},
{
label: t('business.stopText'),
auth: GBT28181_DEVICE_PERMISSION_ENUM.STOP,
icon: 'ant-design:pause-outlined',
onClick: handleStopPlay.bind(null, record),
ifShow: deviceDetail.isEdge === 0 && !!record?.streamId, //通道号存在则显示停止点播按钮
},
]"
/>
</template>
</BasicTable>
<VideoModal @register="registerModal" @reloadTable="reload()" />
</template>
<script lang="ts" setup>
import {
configColumns,
searchFormSchema,
GBT28181_DEVICE_PERMISSION_ENUM,
VideoCancelModalParamsType,
} from './config';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { Switch } from 'ant-design-vue';
import { DeviceRecord } from '/@/api/device/model/deviceModel';
import VideoModal from './videoModal.vue';
import { useModal } from '/@/components/Modal';
import { useMessage } from '/@/hooks/web/useMessage';
import { getVideoChannelList, getVideoControlStart } from '/@/api/device/videoChannel';
import { stopOnDemandVideoApiGet, syncVideoApiGet } from '/@/api/camera/cameraManager';
import { Authority } from '/@/components/Authority';
import { VideoChannelItemType } from '/@/api/device/model/videoChannelModel';
import { useI18n } from '/@/hooks/web/useI18n';
const { t } = useI18n();
import { useGlobSetting } from '/@/hooks/setting';
const props = defineProps<{ deviceDetail: DeviceRecord }>();
const { createMessage } = useMessage();
const [registerModal, { openModal }] = useModal();
const [registerTable, { setProps, setSelectedRowKeys, reload }] = useTable({
api: getVideoChannelList,
columns: configColumns,
showTableSetting: true,
bordered: true,
showIndexColumn: false,
beforeFetch: (params: Recordable) => {
return { ...params, tbDeviceId: props.deviceDetail.tbDeviceId };
},
formConfig: {
labelWidth: 120,
layout: 'inline',
schemas: searchFormSchema,
},
useSearchForm: true,
});
const handleTurnVideo = async (checked: Boolean, _record: Recordable) => {
setProps({
loading: true,
});
setSelectedRowKeys([]);
const newStatus = checked ? 1 : 0;
try {
if (newStatus) createMessage.success('开启成功');
else createMessage.success('关闭成功');
} finally {
setProps({
loading: false,
});
reload();
}
};
const handlePlay = (record: VideoChannelItemType) => {
const { channelId } = record;
openModal(true, {
record: {
canControl: true,
isGBT: true,
channelId,
tbDeviceId: props.deviceDetail.tbDeviceId,
getPlayUrl: async () => {
const { deviceId, channelId } = record;
const result = await getVideoControlStart({ deviceId, channelId });
const { streamMediaContentSecurityProtocol } = useGlobSetting();
return {
type: 'flv',
url: !!streamMediaContentSecurityProtocol ? result.data.https_flv : result.data.flv,
};
},
} as VideoCancelModalParamsType,
});
};
//停止点播
const handleStopPlay = async (record: Recordable) => {
if (!record) return;
const { deviceId, channelId } = record;
if (await stopOnDemandVideoApiGet(deviceId, channelId)) {
createMessage.success(t('common.stopped'));
}
reload();
};
//通道同步
const handleSyncPlay = async () => {
if (await syncVideoApiGet(props.deviceDetail.tbDeviceId)) {
createMessage.success(t('common.channelSynchronizedMessageText'));
reload();
}
};
</script>