Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev

This commit is contained in:
leiqiaochu 2023-03-02 10:16:04 +08:00
commit 569c430ca2
14 changed files with 346 additions and 298 deletions

View File

@ -85,6 +85,7 @@ export const batchDeleteDevice = (data: string[]) => server.put(`/device-instanc
*/
export const deviceTemplateDownload = (productId: string, type: string) => `${BASE_API_PATH}/device-instance/${productId}/template.${type}`
export const templateDownload = (productId: string, type: string) => server.get(`/device-instance/${productId}/template.${type}`,{},{responseType: 'blob'})
/**
*
* @param productId id

View File

@ -99,6 +99,12 @@ export const _import = (configId: any, params: any) => server.get(`/network/card
*/
export const _export = (format: string, data: any) => server.post(`/network/card/download.${format}/_query`, data, { responseType: 'blob' });
/**
*
* @param format xlsxcsv
*/
export const exportCard = (format: string) => server.get(`/network/card/template.${format}`,{},{responseType: 'blob'});
/**
* iccid
* @param id

View File

@ -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)
}

View File

@ -36,8 +36,8 @@
import { FILE_UPLOAD } from '@/api/comm'
import { TOKEN_KEY } from '@/utils/variable';
import { LocalStore } from '@/utils/comm';
import { downloadFile } from '@/utils/utils';
import { deviceImport, deviceTemplateDownload } from '@/api/device/instance'
import { downloadFile, downloadFileByUrl } from '@/utils/utils';
import { deviceImport, deviceTemplateDownload ,templateDownload} from '@/api/device/instance'
import { EventSourcePolyfill } from 'event-source-polyfill'
import { message } from 'ant-design-vue';
@ -72,8 +72,20 @@ const flag = ref<boolean>(false)
const count = ref<number>(0)
const errMessage = ref<string>('')
const downFile = (type: string) => {
downloadFile(deviceTemplateDownload(props.product, type));
const downFile =async (type: string) => {
// downloadFile(deviceTemplateDownload(props.product, type));
const res:any =await templateDownload(props.product, type)
if(res){
const blob = new Blob([res], { type: type });
const url = URL.createObjectURL(blob);
console.log(url);
downloadFileByUrl(
url,
`设备导入模版`,
type,
);
}
}
const submitData = async (fileUrl: string) => {

View File

@ -146,12 +146,6 @@ const rest = async () => {
getDeviceCode();
message.success('操作成功')
}
// service.delDeviceCode(productId, deviceId).then((res) => {
// if (res.status === 200) {
// getDeviceCode(productId, deviceId);
// onlyMessage('');
// }
// });
};
//topic
const getTopic = async () => {
@ -285,7 +279,7 @@ onMounted(() => {
display: flex;
justify-content: space-between;
padding: 10px;
background-color: '#f7f7f7';
background-color: #f7f7f7;
.bottom-title {
display: flex;

View File

@ -60,7 +60,7 @@
</a-card>
</template>
<script setup lang='ts' name="Parsing">
<script setup lang='ts' name="DataAnalysis">
import AIcon from '@/components/AIcon'
import PermissionButton from '@/components/PermissionButton/index.vue'
import MonacoEditor from '@/components/MonacoEditor/index.vue';
@ -225,7 +225,7 @@ onMounted(() => {
display: flex;
justify-content: space-between;
padding: 10px;
background-color: '#f7f7f7';
background-color: #f7f7f7;
.bottom-title {
display: flex;

View File

@ -205,7 +205,9 @@ const getProtocol = async () => {
}
}
};
getProtocol();
onMounted(()=>{
getProtocol();
})
</script>
<style scoped lang="less">
.ant-switch-loading,

View File

@ -80,8 +80,8 @@
import { FILE_UPLOAD } from '@/api/comm';
import { BASE_API_PATH, TOKEN_KEY } from '@/utils/variable';
import { LocalStore } from '@/utils/comm';
import { downloadFile } from '@/utils/utils';
import { queryPlatformNoPage, _import } from '@/api/iot-card/cardManagement';
import { downloadFile, downloadFileByUrl } from '@/utils/utils';
import { queryPlatformNoPage, _import ,exportCard} from '@/api/iot-card/cardManagement';
import { message } from 'ant-design-vue';
const emit = defineEmits(['close']);
@ -136,9 +136,21 @@ const fileChange = (info: any) => {
}
};
const downFileFn = (type: string) => {
const url = `${BASE_API_PATH}/network/card/template.${type}`;
downloadFile(url);
const downFileFn =async (type: string) => {
// const url = `${BASE_API_PATH}/network/card/template.${type}`;
// downloadFile(url);
const res:any = await exportCard(type)
if(res){
const blob = new Blob([res], { type: type });
const url = URL.createObjectURL(blob);
console.log(url);
downloadFileByUrl(
url,
`物联卡导入模版`,
type,
);
}
};
const handleCancel = () => {

View File

@ -1,24 +1,12 @@
<!-- 物联卡管理 -->
<template>
<page-container>
<Search
:columns="columns"
target="iot-card-management-search"
@search="handleSearch"
/>
<JTable
ref="cardManageRef"
:columns="columns"
:request="query"
:defaultParams="{ sorts: [{ name: 'createTime', order: 'desc' }] }"
:rowSelection="{
<Search :columns="columns" target="iot-card-management-search" @search="handleSearch" />
<JTable ref="cardManageRef" :columns="columns" :request="query"
:defaultParams="{ sorts: [{ name: 'createTime', order: 'desc' }] }" :rowSelection="{
selectedRowKeys: _selectedRowKeys,
onChange: onSelectChange,
}"
@cancelSelect="cancelSelect"
:params="params"
:gridColumn="3"
>
}" @cancelSelect="cancelSelect" :params="params" :gridColumn="3">
<template #headerTitle>
<a-space>
<a-button type="primary" @click="handleAdd">
@ -32,72 +20,62 @@
<template #overlay>
<a-menu>
<a-menu-item>
<a-button @click="exportVisible = true">
<PermissionButton @click="exportVisible = true"
:hasPermission="'iot-card/CardManagement:export'">
<AIcon type="ExportOutlined" />
批量导出
</a-button>
</PermissionButton>
</a-menu-item>
<a-menu-item>
<a-button @click="importVisible = true"
><AIcon
type="ImportOutlined"
/></a-button
>
<PermissionButton @click="importVisible = true"
:hasPermission="'iot-card/CardManagement:import'">
<AIcon type="ImportOutlined" />批量导入
</PermissionButton>
</a-menu-item>
<a-menu-item>
<a-popconfirm
@confirm="handleActive"
title="确认激活吗?"
>
<a-button>
<AIcon type="CheckCircleOutlined" />
批量激活
</a-button>
</a-popconfirm>
<PermissionButton :popConfirm="{
title: '确认激活吗?',
onConfirm: handleActive,
}" :hasPermission="'iot-card/CardManagement:active'">
<AIcon type="CheckCircleOutlined" />
批量激活
</PermissionButton>
</a-menu-item>
<a-menu-item>
<a-popconfirm
@confirm="handleStop"
title="确认停用吗?"
>
<a-button type="primary" ghost>
<AIcon type="StopOutlined" />
<PermissionButton :popConfirm="{
title: '确认停用吗?',
onConfirm: handleStop,
}" ghost type="primary" :hasPermission="'iot-card/CardManagement:action'">
<AIcon type="StopOutlined" />
批量停用
</a-button>
</a-popconfirm>
</PermissionButton>
</a-menu-item>
<a-menu-item>
<a-popconfirm
@confirm="handleResumption"
title="确认复机吗?"
>
<a-button type="primary" ghost>
<AIcon type="PoweroffOutlined" />
<PermissionButton :popConfirm="{
title: '确认复机吗?',
onConfirm: handleResumption,
}" ghost type="primary" :hasPermission="'iot-card/CardManagement:action'">
<AIcon type="PoweroffOutlined" />
批量复机
</a-button>
</a-popconfirm>
</PermissionButton>
</a-menu-item>
<a-menu-item>
<a-popconfirm
@confirm="handleSync"
title="确认同步状态吗?"
>
<a-button type="primary" ghost>
<AIcon type="SwapOutlined" />
<PermissionButton :popConfirm="{
title: '确认同步状态吗?',
onConfirm: handleSync,
}" ghost type="primary" :hasPermission="'iot-card/CardManagement:sync'">
<AIcon type="SwapOutlined" />
同步状态
</a-button>
</a-popconfirm>
</PermissionButton>
</a-menu-item>
<a-menu-item v-if="_selectedRowKeys.length > 0">
<a-popconfirm
@confirm="handelRemove"
title="确认删除吗?"
>
<a-button>
<AIcon type="DeleteOutlined" />
批量删除
</a-button>
</a-popconfirm>
<PermissionButton :popConfirm="{
title: '确认删除吗?',
onConfirm: handelRemove,
}" ghost type="primary" :hasPermission="'iot-card/CardManagement:delete'">
<AIcon type="SwapOutlined" />
批量删除
</PermissionButton>
</a-menu-item>
</a-menu>
</template>
@ -105,20 +83,13 @@
</a-space>
</template>
<template #card="slotProps">
<CardBox
:value="slotProps"
@click="handleClick"
:actions="getActions(slotProps, 'card')"
v-bind="slotProps"
:active="_selectedRowKeys.includes(slotProps.id)"
:status="slotProps.cardStateType.value"
:statusText="slotProps.cardStateType.text"
:statusNames="{
<CardBox :value="slotProps" @click="handleClick" :actions="getActions(slotProps, 'card')" v-bind="slotProps"
:active="_selectedRowKeys.includes(slotProps.id)" :status="slotProps.cardStateType.value"
:statusText="slotProps.cardStateType.text" :statusNames="{
using: 'success',
toBeActivated: 'default',
deactivate: 'error',
}"
>
}">
<template #img>
<slot name="img">
<img :src="getImage('/iot-card/iot-card-bg.png')" />
@ -150,8 +121,7 @@
{{ slotProps.totalFlow }}
</span>
<span class="card-item-content-text">
M 使用流量</span
>
M 使用流量</span>
</div>
<div v-else>
<div class="progress-text">
@ -165,17 +135,22 @@
总共 {{ slotProps.totalFlow }} M
</div>
</div>
<a-progress
:strokeColor="'#ADC6FF'"
:showInfo="false"
:percent="
slotProps.totalFlow - slotProps.usedFlow
"
/>
<a-progress :strokeColor="'#ADC6FF'" :showInfo="false" :percent="
slotProps.totalFlow - slotProps.usedFlow
" />
</div>
</template>
<template #actions="item">
<a-tooltip
<PermissionButton :disabled="item.disabled" :popConfirm="item.popConfirm" :tooltip="{
...item.tooltip,
}" @click="item.onClick" :hasPermission="'iot-card/CardManagement:' + item.key">
<AIcon type="DeleteOutlined" v-if="item.key === 'delete'" />
<template v-else>
<AIcon :type="item.icon" />
<span>{{ item?.text }}</span>
</template>
</PermissionButton>
<!-- <a-tooltip
v-bind="item.tooltip"
:title="item.disabled && item.tooltip.title"
>
@ -210,7 +185,7 @@
</template>
</a-button>
</template>
</a-tooltip>
</a-tooltip> -->
</template>
</CardBox>
</template>
@ -221,8 +196,8 @@
<div>
{{
slotProps.totalFlow
? slotProps.totalFlow.toFixed(2) + ' M'
: ''
? slotProps.totalFlow.toFixed(2) + ' M'
: ''
}}
</div>
</template>
@ -230,8 +205,8 @@
<div>
{{
slotProps.usedFlow
? slotProps.usedFlow.toFixed(2) + ' M'
: ''
? slotProps.usedFlow.toFixed(2) + ' M'
: ''
}}
</div>
</template>
@ -239,8 +214,8 @@
<div>
{{
slotProps.residualFlow
? slotProps.residualFlow.toFixed(2) + ' M'
: ''
? slotProps.residualFlow.toFixed(2) + ' M'
: ''
}}
</div>
</template>
@ -253,74 +228,52 @@
<template #activationDate="slotProps">
{{
slotProps.activationDate
? moment(slotProps.activationDate).format(
'YYYY-MM-DD HH:mm:ss',
)
: ''
? moment(slotProps.activationDate).format(
'YYYY-MM-DD HH:mm:ss',
)
: ''
}}
</template>
<template #updateTime="slotProps">
{{
slotProps.updateTime
? moment(slotProps.updateTime).format(
'YYYY-MM-DD HH:mm:ss',
)
: ''
? moment(slotProps.updateTime).format(
'YYYY-MM-DD HH:mm:ss',
)
: ''
}}
</template>
<template #action="slotProps">
<a-space :size="16">
<a-tooltip
v-for="i in getActions(slotProps, 'table')"
<template
v-for="i in getActions(slotProps,'table')"
:key="i.key"
v-bind="i.tooltip"
>
<a-popconfirm v-if="i.popConfirm" v-bind="i.popConfirm">
<a-button
:disabled="i.disabled"
style="padding: 0"
type="link"
><AIcon :type="i.icon"
/></a-button>
</a-popconfirm>
<a-button
style="padding: 0"
<PermissionButton
:disabled="i.disabled"
:popConfirm="i.popConfirm"
:tooltip="{
...i.tooltip,
}"
@click="i.onClick"
type="link"
v-else
@click="i.onClick && i.onClick(slotProps)"
style="padding: 0px"
:hasPermission="'iot-card/CardManagement:' + i.key"
>
<a-button
:disabled="i.disabled"
style="padding: 0"
type="link"
><AIcon :type="i.icon"
/></a-button>
</a-button>
</a-tooltip>
<template #icon><AIcon :type="i.icon" /></template>
</PermissionButton>
</template>
</a-space>
</template>
</JTable>
<!-- 批量导入 -->
<Import v-if="importVisible" @close="importVisible = false" />
<!-- 批量导出 -->
<Export
v-if="exportVisible"
@close="exportVisible = false"
:data="_selectedRowKeys"
/>
<Export v-if="exportVisible" @close="exportVisible = false" :data="_selectedRowKeys" />
<!-- 绑定设备 -->
<BindDevice
v-if="bindDeviceVisible"
:cardId="cardId"
@change="bindDevice"
/>
<BindDevice v-if="bindDeviceVisible" :cardId="cardId" @change="bindDevice" />
<!-- 新增编辑 -->
<Save
v-if="visible"
:type="saveType"
:data="current"
@change="saveChange"
/>
<Save v-if="visible" :type="saveType" :data="current" @change="saveChange" />
</page-container>
</template>
@ -516,7 +469,21 @@ const getActions = (
if (!data) return [];
return [
{
key: 'edit',
key: 'view',
text: '查看',
tooltip: {
title: '查看',
},
icon: 'EyeOutlined',
onClick: () => {
// router.push({
// path: `/iot-card/CardManagement/detail/${data.id}`,
// });
menuStory.jumpPage('iot-card/CardManagement/Detail', { id: data.id })
},
},
{
key: 'update',
text: '编辑',
tooltip: {
title: '编辑',
@ -529,21 +496,7 @@ const getActions = (
},
},
{
key: 'view',
text: '查看',
tooltip: {
title: '查看',
},
icon: 'EyeOutlined',
onClick: () => {
// router.push({
// path: `/iot-card/CardManagement/detail/${data.id}`,
// });
menuStory.jumpPage('iot-card/CardManagement/Detail',{id:data.id})
},
},
{
key: 'bindDevice',
key: 'bind',
text: data.deviceId ? '解绑设备' : '绑定设备',
tooltip: {
title: data.deviceId ? '解绑设备' : '绑定设备',
@ -551,18 +504,18 @@ const getActions = (
icon: data.deviceId ? 'DisconnectOutlined' : 'LinkOutlined',
popConfirm: data.deviceId
? {
title: '确认解绑设备?',
okText: '确定',
cancelText: '取消',
onConfirm: async () => {
unbind(data.id).then((resp: any) => {
if (resp.status === 200) {
message.success('操作成功');
cardManageRef.value?.reload();
}
});
},
}
title: '确认解绑设备?',
okText: '确定',
cancelText: '取消',
onConfirm: async () => {
unbind(data.id).then((resp: any) => {
if (resp.status === 200) {
message.success('操作成功');
cardManageRef.value?.reload();
}
});
},
}
: undefined,
onClick: () => {
if (!data.deviceId) {
@ -572,34 +525,34 @@ const getActions = (
},
},
{
key: 'activation',
key: data.cardStateType?.value === 'toBeActivated' ? 'active' : 'action',
text:
data.cardStateType?.value === 'toBeActivated'
? '激活'
: data.cardStateType?.value === 'deactivate'
? '复机'
: '停用',
? '复机'
: '停用',
tooltip: {
title:
data.cardStateType?.value === 'toBeActivated'
? '激活'
: data.cardStateType?.value === 'deactivate'
? '复机'
: '停用',
? '复机'
: '停用',
},
icon:
data.cardStateType?.value === 'toBeActivated'
? 'CheckCircleOutlined'
: data.cardStateType?.value === 'deactivate'
? 'PoweroffOutlined'
: 'StopOutlined',
? 'PoweroffOutlined'
: 'StopOutlined',
popConfirm: {
title:
data.cardStateType?.value === 'toBeActivated'
? '确认激活?'
: data.cardStateType?.value === 'deactivate'
? '确认复机?'
: '确认停用?',
? '确认复机?'
: '确认停用?',
okText: '确定',
cancelText: '取消',
onConfirm: async () => {
@ -793,14 +746,17 @@ const handelRemove = async () => {
font-size: 20px;
font-weight: 600;
}
.progress-text {
display: flex;
justify-content: space-between;
align-items: center;
}
:deep(.ant-progress-inner) {
border-radius: 0px;
}
:deep(.ant-progress-bg) {
border-radius: 0px;
}

View File

@ -56,42 +56,15 @@
</a-row>
</template>
<template #actions="item">
<a-tooltip
v-bind="item.tooltip"
:title="item.disabled && item.tooltip.title"
>
<a-popconfirm
v-if="item.popConfirm"
v-bind="item.popConfirm"
:disabled="item.disabled"
>
<a-button :disabled="item.disabled">
<AIcon
type="DeleteOutlined"
v-if="item.key === 'delete'"
/>
<template v-else>
<AIcon :type="item.icon" />
<span>{{ item.text }}</span>
</template>
</a-button>
</a-popconfirm>
<PermissionButton :disabled="item.disabled" :popConfirm="item.popConfirm" :tooltip="{
...item.tooltip,
}" @click="item.onClick" :hasPermission="'iot-card/Platform:' + item.key">
<AIcon type="DeleteOutlined" v-if="item.key === 'delete'" />
<template v-else>
<a-button
:disabled="item.disabled"
@click="item.onClick"
>
<AIcon
type="DeleteOutlined"
v-if="item.key === 'delete'"
/>
<template v-else>
<AIcon :type="item.icon" />
<span>{{ item.text }}</span>
</template>
</a-button>
<AIcon :type="item.icon" />
<span>{{ item?.text }}</span>
</template>
</a-tooltip>
</PermissionButton>
</template>
</CardBox>
</template>
@ -107,33 +80,24 @@
</template>
<template #action="slotProps">
<a-space :size="16">
<a-tooltip
v-for="i in getActions(slotProps, 'table')"
<template
v-for="i in getActions(slotProps,'table')"
:key="i.key"
v-bind="i.tooltip"
>
<a-popconfirm v-if="i.popConfirm" v-bind="i.popConfirm">
<a-button
:disabled="i.disabled"
style="padding: 0"
type="link"
><AIcon :type="i.icon"
/></a-button>
</a-popconfirm>
<a-button
style="padding: 0"
<PermissionButton
:disabled="i.disabled"
:popConfirm="i.popConfirm"
:tooltip="{
...i.tooltip,
}"
@click="i.onClick"
type="link"
v-else
@click="i.onClick && i.onClick(slotProps)"
style="padding: 0px"
:hasPermission="'iot-card/Platform:' + i.key"
>
<a-button
:disabled="i.disabled"
style="padding: 0"
type="link"
><AIcon :type="i.icon"
/></a-button>
</a-button>
</a-tooltip>
<template #icon><AIcon :type="i.icon" /></template>
</PermissionButton>
</template>
</a-space>
</template>
</JTable>
@ -218,7 +182,7 @@ const getActions = (
if (!data) return [];
return [
{
key: 'edit',
key: 'update',
text: '编辑',
tooltip: {
title: '编辑',

View File

@ -1,24 +1,14 @@
<!-- 充值管理 -->
<template>
<page-container>
<Search
:columns="columns"
target="recharge-search"
@search="handleSearch"
/>
<JTable
ref="rechargeRef"
:columns="columns"
:request="queryRechargeList"
model="TABLE"
:defaultParams="{ sorts: [{ name: 'createTime', order: 'desc' }] }"
:params="params"
>
<Search :columns="columns" target="recharge-search" @search="handleSearch" />
<JTable ref="rechargeRef" :columns="columns" :request="queryRechargeList" model="TABLE"
:defaultParams="{ sorts: [{ name: 'createTime', order: 'desc' }] }" :params="params">
<template #headerTitle>
<a-space>
<a-button type="primary" @click="visible = true">
<PermissionButton @click="visible = true" :hasPermission="'iot-card/Recharge:pay'" type="primary">
充值
</a-button>
</PermissionButton>
<div class="tips-text">
<span style="margin-right: 8px; font-size: 16px">
<AIcon type="ExclamationCircleOutlined"></AIcon>
@ -30,41 +20,32 @@
<template #createTime="slotProps">
{{
slotProps.createTime
? moment(slotProps.createTime).format(
'YYYY-MM-DD HH:mm:ss',
)
: ''
? moment(slotProps.createTime).format(
'YYYY-MM-DD HH:mm:ss',
)
: ''
}}
</template>
<template #action="slotProps">
<a-space :size="16">
<a-tooltip
<template
v-for="i in getActions(slotProps)"
:key="i.key"
v-bind="i.tooltip"
>
<a-popconfirm v-if="i.popConfirm" v-bind="i.popConfirm">
<a-button
:disabled="i.disabled"
style="padding: 0"
type="link"
><AIcon :type="i.icon"
/></a-button>
</a-popconfirm>
<a-button
style="padding: 0"
<PermissionButton
:disabled="i.disabled"
:popConfirm="i.popConfirm"
:tooltip="{
...i.tooltip,
}"
@click="i.onClick"
type="link"
v-else
@click="i.onClick && i.onClick(slotProps)"
style="padding: 0px"
:hasPermission="'iot-card/Recharge:' + i.key"
>
<a-button
:disabled="i.disabled"
style="padding: 0"
type="link"
><AIcon :type="i.icon"
/></a-button>
</a-button>
</a-tooltip>
<template #icon><AIcon :type="i.icon" /></template>
</PermissionButton>
</template>
</a-space>
</template>
</JTable>
@ -145,8 +126,8 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
},
icon: 'EyeOutlined',
onClick: () => {
detailVisible.value = true;
current.value = data;
detailVisible.value = true;
current.value = data;
},
},
];

View File

@ -298,6 +298,10 @@ const getActions = (
* 批量解绑
*/
const handleMultipleUnbind = async () => {
if (!_selectedRowKeys.value.length) {
message.error('请先选择需要解绑的通道列表');
return;
}
const channelIds = listRef.value?._dataSource
.filter((f: any) => _selectedRowKeys.value.includes(f.id))
.map((m: any) => m.channelId);

View File

@ -0,0 +1,103 @@
<!-- 国标级联-推送 -->
<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);
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>

View File

@ -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;
},
},
{