Commit 33c45f885b8ed17a3c667d3b62ad1978ef3ad48d
Committed by
xp.Huang
1 parent
dcd11373
perf: 调整设备里的视频通道,由原先的关闭弹窗调用停止点播接口,调整为点击按钮停止
Showing
5 changed files
with
65 additions
and
13 deletions
... | ... | @@ -43,8 +43,8 @@ |
43 | 43 | /> |
44 | 44 | </template> |
45 | 45 | <template #accessMode="{ record }"> |
46 | - <Tag :color="record.accessMode === AccessMode.ManuallyEnter ? 'cyan' : 'blue'">{{ | |
47 | - record.accessMode === AccessMode.ManuallyEnter ? '手动输入' : '流媒体获取' | |
46 | + <Tag :color="computedAccessMode(record, 'color')">{{ | |
47 | + computedAccessMode(record, 'text') | |
48 | 48 | }}</Tag> |
49 | 49 | </template> |
50 | 50 | <template #action="{ record }"> |
... | ... | @@ -87,7 +87,7 @@ |
87 | 87 | </template> |
88 | 88 | |
89 | 89 | <script lang="ts"> |
90 | - import { defineComponent, reactive, nextTick } from 'vue'; | |
90 | + import { defineComponent, reactive, nextTick, computed } from 'vue'; | |
91 | 91 | import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table'; |
92 | 92 | import { PageWrapper } from '/@/components/Page'; |
93 | 93 | import { useDrawer } from '/@/components/Drawer'; |
... | ... | @@ -102,6 +102,7 @@ |
102 | 102 | PageMode, |
103 | 103 | CameraPermission, |
104 | 104 | VideoPlatformEnum, |
105 | + accessModeConfig, | |
105 | 106 | } from './config.data'; |
106 | 107 | import VideoPreviewModal from './DialogPreviewVideo.vue'; |
107 | 108 | import { useModal } from '/@/components/Modal'; |
... | ... | @@ -231,6 +232,14 @@ |
231 | 232 | |
232 | 233 | const handleGBTSuccess = () => reload(); |
233 | 234 | |
235 | + const computedAccessMode = computed(() => (record, mode) => { | |
236 | + const findAccessMode = accessModeConfig.find( | |
237 | + (findItem) => findItem.key === record.accessMode | |
238 | + ); | |
239 | + if (mode === 'text') return findAccessMode?.text; | |
240 | + return findAccessMode?.color; | |
241 | + }); | |
242 | + | |
234 | 243 | return { |
235 | 244 | searchInfo, |
236 | 245 | hasBatchDelete, |
... | ... | @@ -250,6 +259,7 @@ |
250 | 259 | handleOpenGBTDrawer, |
251 | 260 | registerGBTDrawer, |
252 | 261 | handleGBTSuccess, |
262 | + computedAccessMode, | |
253 | 263 | }; |
254 | 264 | }, |
255 | 265 | }); | ... | ... |
... | ... | @@ -99,6 +99,18 @@ |
99 | 99 | return record; |
100 | 100 | }); |
101 | 101 | |
102 | + //验证视频通道号 | |
103 | + const validateChannelNos = (gptDeviceDTOS) => { | |
104 | + gptDeviceDTOS.some((deviceDTO) => { | |
105 | + const channelNo = deviceDTO['channelNos']; | |
106 | + const ChannelNoRegexp = /^\d{1,20}$/; | |
107 | + if (!ChannelNoRegexp.test(channelNo)) { | |
108 | + createMessage.error('输入内容只能是数字,且不能超过20位'); | |
109 | + throw Error('输入内容只能是数字,且不能超过20位'); | |
110 | + } | |
111 | + }); | |
112 | + }; | |
113 | + | |
102 | 114 | const handleSubmit = async () => { |
103 | 115 | try { |
104 | 116 | setDrawerProps({ confirmLoading: true }); |
... | ... | @@ -107,6 +119,7 @@ |
107 | 119 | const gptDeviceDTOS = selectDeviceRef.value?.getDeviceChannels(); |
108 | 120 | if (Array.isArray(gptDeviceDTOS) && gptDeviceDTOS.length == 0) |
109 | 121 | return createMessage.error('请填写设备通道号'); |
122 | + validateChannelNos(gptDeviceDTOS); | |
110 | 123 | const mergeValues = { |
111 | 124 | ...values, |
112 | 125 | accessMode: 2, | ... | ... |
... | ... | @@ -77,6 +77,26 @@ export enum ArticulationEnumNameType { |
77 | 77 | HIGH_DEFINITION = '高清', |
78 | 78 | SMOOTH = '流畅', |
79 | 79 | } |
80 | + | |
81 | +//获取方式文字和Tag颜色配置 | |
82 | +export const accessModeConfig = [ | |
83 | + { | |
84 | + key: AccessMode.ManuallyEnter, | |
85 | + text: '手动输入', | |
86 | + color: 'cyan', | |
87 | + }, | |
88 | + { | |
89 | + key: AccessMode.Streaming, | |
90 | + text: '流媒体获取', | |
91 | + color: 'blue', | |
92 | + }, | |
93 | + { | |
94 | + key: AccessMode.GBT28181, | |
95 | + text: 'GBT28181', | |
96 | + color: 'orange', | |
97 | + }, | |
98 | +]; | |
99 | + | |
80 | 100 | // 表格列数据 |
81 | 101 | export const columns: BasicColumn[] = [ |
82 | 102 | { | ... | ... |
... | ... | @@ -21,6 +21,12 @@ |
21 | 21 | icon: 'ant-design:play-circle-outlined', |
22 | 22 | onClick: handlePlay.bind(null, record), |
23 | 23 | }, |
24 | + { | |
25 | + label: '停止点播', | |
26 | + auth: 'api:yt:sceneLinkage:get', | |
27 | + icon: 'ant-design:pause-outlined', | |
28 | + onClick: handleStopPlay.bind(null, record), | |
29 | + }, | |
24 | 30 | ]" |
25 | 31 | /> |
26 | 32 | </template> |
... | ... | @@ -37,9 +43,12 @@ |
37 | 43 | import { useModal } from '/@/components/Modal'; |
38 | 44 | import { useMessage } from '/@/hooks/web/useMessage'; |
39 | 45 | import { getVideoChannelList } from '/@/api/device/videoChannel'; |
46 | + import { stopOnDemandVideoApiGet } from '/@/api/camera/cameraManager'; | |
40 | 47 | |
41 | 48 | const props = defineProps<{ deviceDetail: DeviceRecord }>(); |
42 | 49 | |
50 | + const { createMessage } = useMessage(); | |
51 | + | |
43 | 52 | const [registerModal, { openModal }] = useModal(); |
44 | 53 | |
45 | 54 | const [registerTable, { setProps, setSelectedRowKeys, reload }] = useTable({ |
... | ... | @@ -64,7 +73,6 @@ |
64 | 73 | }); |
65 | 74 | setSelectedRowKeys([]); |
66 | 75 | const newStatus = checked ? 1 : 0; |
67 | - const { createMessage } = useMessage(); | |
68 | 76 | try { |
69 | 77 | if (newStatus) createMessage.success('开启成功'); |
70 | 78 | else createMessage.success('关闭成功'); |
... | ... | @@ -82,4 +90,13 @@ |
82 | 90 | ifShowGBT: true, |
83 | 91 | }); |
84 | 92 | }; |
93 | + | |
94 | + //停止点播 | |
95 | + const handleStopPlay = async (record: Recordable) => { | |
96 | + if (!record) return; | |
97 | + const { deviceId, channelId } = record; | |
98 | + if (await stopOnDemandVideoApiGet(deviceId, channelId)) { | |
99 | + createMessage.success('已停止点播'); | |
100 | + } | |
101 | + }; | |
85 | 102 | </script> | ... | ... |
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | } from '@ant-design/icons-vue'; |
21 | 21 | import { Button } from 'ant-design-vue'; |
22 | 22 | import { nextTick } from 'vue'; |
23 | - import { controlling, stopOnDemandVideoApiGet } from '/@/api/camera/cameraManager'; | |
23 | + import { controlling } from '/@/api/camera/cameraManager'; | |
24 | 24 | import { setVideoControl } from '/@/api/device/videoChannel'; |
25 | 25 | |
26 | 26 | const { prefixCls } = useDesign('basic-video-play'); |
... | ... | @@ -171,16 +171,8 @@ |
171 | 171 | unref(videoPlayInstance)?.dispose(); |
172 | 172 | videoPlayInstance.value = null; |
173 | 173 | emit('onUnmounted'); |
174 | - stopOnDemandVideo(); | |
175 | 174 | }); |
176 | 175 | |
177 | - // 停止点播视频 | |
178 | - const stopOnDemandVideo = async () => { | |
179 | - if (!unref(getGBT)) return; | |
180 | - const { tbDeviceId, channelId } = props.GBTOption; | |
181 | - await stopOnDemandVideoApiGet(tbDeviceId, channelId); | |
182 | - }; | |
183 | - | |
184 | 176 | defineExpose({ |
185 | 177 | reloadPlayer: init, |
186 | 178 | getInstance: () => unref(videoPlayInstance), | ... | ... |