feat: 国标级联推送
This commit is contained in:
parent
8d2558b721
commit
3707b71c38
File diff suppressed because it is too large
Load Diff
|
@ -36,5 +36,7 @@ export default {
|
|||
updateGbChannelId: (id: string, data: any): any => server.put(`/media/gb28181-cascade/binding/${id}`, data),
|
||||
// 查询通道分页列表
|
||||
queryChannelList: (data: any): any => server.post(`media/channel/_query`, data),
|
||||
// 推送
|
||||
publish: (id: string, params: any) => server.get(`/media/gb28181-cascade/${id}/bindings/publish`, params)
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
<!-- 国标级联-推送 -->
|
||||
<template>
|
||||
<a-modal
|
||||
v-model:visible="_vis"
|
||||
title="推送"
|
||||
cancelText="取消"
|
||||
okText="确定"
|
||||
width="900px"
|
||||
@ok="_vis = false"
|
||||
@cancel="_vis = false"
|
||||
>
|
||||
<a-row :gutter="20">
|
||||
<a-col :span="8">
|
||||
<p>成功:{{ successCount }}</p>
|
||||
<a-space>
|
||||
<p>失败:{{ failCount }}</p>
|
||||
<a
|
||||
v-if="errMessage.length"
|
||||
@click="
|
||||
downloadObject(
|
||||
errMessage || '',
|
||||
data.name + '-推送失败',
|
||||
)
|
||||
"
|
||||
>下载</a
|
||||
>
|
||||
</a-space>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<p>推送通道数量:{{ data.count }}</p>
|
||||
</a-col>
|
||||
<a-col :span="8">
|
||||
<p>已推送通道数量:{{ successCount + failCount }}</p>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<div v-if="flag">
|
||||
<a-textarea :rows="10" v-model:value="errStr" />
|
||||
</div>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { LocalStore } from '@/utils/comm';
|
||||
import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable';
|
||||
import { EventSourcePolyfill } from 'event-source-polyfill';
|
||||
import { PropType } from 'vue';
|
||||
import { downloadObject } from '@/utils/utils';
|
||||
|
||||
type Emits = {
|
||||
(e: 'update:visible', data: boolean): void;
|
||||
};
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
const props = defineProps({
|
||||
visible: { type: Boolean, default: false },
|
||||
data: {
|
||||
type: Object as PropType<Partial<Record<string, any>>>,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
|
||||
const _vis = computed({
|
||||
get: () => props.visible,
|
||||
set: (val) => emit('update:visible', val),
|
||||
});
|
||||
|
||||
watch(
|
||||
() => _vis.value,
|
||||
(val: boolean) => {
|
||||
if (val) publish();
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 推送
|
||||
*/
|
||||
const successCount = ref(0);
|
||||
const failCount = ref(0);
|
||||
const flag = ref(false);
|
||||
const errMessage = ref<any[]>([]);
|
||||
const errStr = computed(() => JSON.stringify(errMessage.value));
|
||||
const publish = () => {
|
||||
const activeAPI = `/${BASE_API_PATH}/media/gb28181-cascade/${
|
||||
props.data.id
|
||||
}/bindings/publish?:X_Access_Token=${LocalStore.get(TOKEN_KEY)}`;
|
||||
const source = new EventSourcePolyfill(activeAPI);
|
||||
source.onmessage = (e: any) => {
|
||||
const res = JSON.parse(e.data);
|
||||
console.log('res: ', res);
|
||||
if (res.successful) {
|
||||
successCount.value += 1;
|
||||
} else {
|
||||
failCount.value += 1;
|
||||
if (errMessage.value.length <= 5) {
|
||||
errMessage.value.push({ ...res });
|
||||
}
|
||||
}
|
||||
};
|
||||
source.onerror = () => {
|
||||
source.close();
|
||||
};
|
||||
source.onopen = () => {};
|
||||
};
|
||||
</script>
|
|
@ -193,6 +193,8 @@
|
|||
</a-space>
|
||||
</template>
|
||||
</JTable>
|
||||
|
||||
<Publish v-model:visible="publishVis" :data="currentData" />
|
||||
</page-container>
|
||||
</template>
|
||||
|
||||
|
@ -201,6 +203,7 @@ import CascadeApi from '@/api/media/cascade';
|
|||
import type { ActionsType } from '@/components/Table/index.vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { getImage } from '@/utils/comm';
|
||||
import Publish from './Publish/index.vue';
|
||||
|
||||
import { useMenuStore } from 'store/menu';
|
||||
|
||||
|
@ -314,6 +317,13 @@ const handleAdd = () => {
|
|||
menuStory.jumpPage('media/Cascade/Save');
|
||||
};
|
||||
|
||||
const publishVis = ref(false);
|
||||
const currentData = ref();
|
||||
/**
|
||||
* 按钮
|
||||
* @param data
|
||||
* @param type
|
||||
*/
|
||||
const getActions = (
|
||||
data: Partial<Record<string, any>>,
|
||||
type: 'card' | 'table',
|
||||
|
@ -366,7 +376,8 @@ const getActions = (
|
|||
disabled: data.status?.value === 'disabled',
|
||||
icon: 'ShareAltOutlined',
|
||||
onClick: () => {
|
||||
// updateChannel()
|
||||
publishVis.value = true;
|
||||
currentData.value = data;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue