增加视频监控页面
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
15683799673 2025-07-19 09:09:14 +08:00
parent 5f19bb22a8
commit 2bb661e32b
14 changed files with 896 additions and 143 deletions

View File

@ -1,3 +1,5 @@
import type { DataNode } from 'ant-design-vue/es/tree';
export type ID = number | string;
export type IDS = (number | string)[];
@ -42,15 +44,12 @@ export interface PageQuery {
[key: string]: any;
}
export interface TreeNode<T = any> {
export interface TreeNode<T = any> extends DataNode {
level: number;
code: T;
ParentCode: T;
label: string;
children: TreeNode<T>;
title?: string;
key?:any
disabled: boolean
data?: [];
disabled: boolean;
}

View File

@ -0,0 +1,74 @@
import type {
DeviceChannelForm,
DeviceChannelQuery,
DeviceChannelVO,
} from './model';
import type { ID, IDS, PageResult, TreeNode } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
*
* @param params
* @returns
*/
export function deviceChannelList(params?: DeviceChannelQuery) {
return requestClient.get<PageResult<DeviceChannelVO>>(
'/sis/deviceChannel/list',
{ params },
);
}
/**
*
*/
export function treeList() {
return requestClient.get<TreeNode[]>('/sis/deviceChannel/treeList');
}
/**
*
* @param params
* @returns
*/
export function deviceChannelExport(params?: DeviceChannelQuery) {
return commonExport('/sis/deviceChannel/export', params ?? {});
}
/**
*
* @param id id
* @returns
*/
export function deviceChannelInfo(id: ID) {
return requestClient.get<DeviceChannelVO>(`/sis/deviceChannel/${id}`);
}
/**
*
* @param data
* @returns void
*/
export function deviceChannelAdd(data: DeviceChannelForm) {
return requestClient.postWithMsg<void>('/sis/deviceChannel', data);
}
/**
*
* @param data
* @returns void
*/
export function deviceChannelUpdate(data: DeviceChannelForm) {
return requestClient.putWithMsg<void>('/sis/deviceChannel', data);
}
/**
*
* @param id id
* @returns void
*/
export function deviceChannelRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/sis/deviceChannel/${id}`);
}

View File

@ -0,0 +1,159 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface DeviceChannelVO {
/**
* id
*/
id: string | number;
/**
* id
*/
deviceId: string | number;
/**
*
*/
deviceName: string;
/**
* id
*/
groupId: string | number;
/**
* ip
*/
deviceIp: string;
/**
*
*/
devicePort: number;
/**
*
*/
deviceAccount: string;
/**
*
*/
devicePwd: string;
/**
*
*/
deviceMac: string;
/**
*
*/
channelNo: string;
}
export interface DeviceChannelForm extends BaseEntity {
/**
* id
*/
id?: string | number;
/**
* id
*/
deviceId?: string | number;
/**
*
*/
deviceName?: string;
/**
* id
*/
groupId?: string | number;
/**
* ip
*/
deviceIp?: string;
/**
*
*/
devicePort?: number;
/**
*
*/
deviceAccount?: string;
/**
*
*/
devicePwd?: string;
/**
*
*/
deviceMac?: string;
/**
*
*/
channelNo?: string;
}
export interface DeviceChannelQuery extends PageQuery {
/**
* id
*/
deviceId?: string | number;
/**
*
*/
deviceName?: string;
/**
* id
*/
groupId?: string | number;
/**
* ip
*/
deviceIp?: string;
/**
*
*/
devicePort?: number;
/**
*
*/
deviceAccount?: string;
/**
*
*/
devicePwd?: string;
/**
*
*/
deviceMac?: string;
/**
*
*/
channelNo?: string;
/**
*
*/
params?: any;
}

View File

@ -0,0 +1,61 @@
import type { DeviceGroupVO, DeviceGroupForm, DeviceGroupQuery } from './model';
import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';
import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';
/**
*
* @param params
* @returns
*/
export function deviceGroupList(params?: DeviceGroupQuery) {
return requestClient.get<PageResult<DeviceGroupVO>>('/sis/deviceGroup/list', { params });
}
/**
*
* @param params
* @returns
*/
export function deviceGroupExport(params?: DeviceGroupQuery) {
return commonExport('/sis/deviceGroup/export', params ?? {});
}
/**
*
* @param id id
* @returns
*/
export function deviceGroupInfo(id: ID) {
return requestClient.get<DeviceGroupVO>(`/sis/deviceGroup/${id}`);
}
/**
*
* @param data
* @returns void
*/
export function deviceGroupAdd(data: DeviceGroupForm) {
return requestClient.postWithMsg<void>('/sis/deviceGroup', data);
}
/**
*
* @param data
* @returns void
*/
export function deviceGroupUpdate(data: DeviceGroupForm) {
return requestClient.putWithMsg<void>('/sis/deviceGroup', data);
}
/**
*
* @param id id
* @returns void
*/
export function deviceGroupRemove(id: ID | IDS) {
return requestClient.deleteWithMsg<void>(`/sis/deviceGroup/${id}`);
}

View File

@ -0,0 +1,64 @@
import type { PageQuery, BaseEntity } from '#/api/common';
export interface DeviceGroupVO {
/**
* id
*/
id: string | number;
/**
*
*/
name: string;
/**
* id(-1 )
*/
parentId: string | number;
/**
*
*/
remark: string;
}
export interface DeviceGroupForm extends BaseEntity {
/**
* id
*/
id?: string | number;
/**
*
*/
name?: string;
/**
* id(-1 )
*/
parentId?: string | number;
/**
*
*/
remark?: string;
}
export interface DeviceGroupQuery extends PageQuery {
/**
*
*/
name?: string;
/**
* id(-1 )
*/
parentId?: string | number;
/**
*
*/
params?: any;
}

View File

@ -1,4 +1,4 @@
import type { PageQuery, BaseEntity } from '#/api/common';
import type { BaseEntity, PageQuery } from '#/api/common';
export interface DeviceManageVO {
/**
@ -80,7 +80,6 @@ export interface DeviceManageVO {
* id
*/
accessControlId: string | number;
}
export interface DeviceManageForm extends BaseEntity {
@ -128,42 +127,6 @@ export interface DeviceManageForm extends BaseEntity {
* 线 0:离线 1:在线 2:未知
*/
deviceStatus?: number;
/**
* id
*/
parentId?: string | number;
/**
*
*/
channelNo?: string;
/**
* ip
*/
vcrIp?: string;
/**
*
*/
vcrPort?: number;
/**
*
*/
vcrAccount?: string;
/**
*
*/
vcrPwd?: string;
/**
* id
*/
accessControlId?: string | number;
}
export interface DeviceManageQuery extends PageQuery {
@ -208,42 +171,7 @@ export interface DeviceManageQuery extends PageQuery {
deviceStatus?: number;
/**
* id
*
*/
parentId?: string | number;
/**
*
*/
channelNo?: string;
/**
* ip
*/
vcrIp?: string;
/**
*
*/
vcrPort?: number;
/**
*
*/
vcrAccount?: string;
/**
*
*/
vcrPwd?: string;
/**
* id
*/
accessControlId?: string | number;
/**
*
*/
params?: any;
}

View File

@ -0,0 +1,69 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'name',
label: '分组名称',
},
];
// 需要使用i18n注意这里要改成getter形式 否则切换语言不会刷新
// export const columns: () => VxeGridProps['columns'] = () => [
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '主键id',
field: 'id',
},
{
title: '分组名称',
field: 'name',
},
{
title: '父节点',
field: 'parentId',
},
{
title: '备注',
field: 'remark',
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 180,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键id',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '分组名称',
fieldName: 'name',
component: 'Input',
rules: 'required',
},
{
label: '父节点',
fieldName: 'parentId',
component: 'Input',
rules: 'required',
},
{
label: '备注',
fieldName: 'remark',
component: 'Input',
},
];

View File

@ -0,0 +1,101 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { $t } from '@vben/locales';
import { cloneDeep } from '@vben/utils';
import { useVbenForm } from '#/adapter/form';
import { deviceGroupAdd, deviceGroupInfo, deviceGroupUpdate } from '#/api/sis/deviceGroup';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { modalSchema } from './data';
const emit = defineEmits<{ reload: [] }>();
const isUpdate = ref(false);
const title = computed(() => {
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
});
const [BasicForm, formApi] = useVbenForm({
commonConfig: {
//
formItemClass: 'col-span-2',
// label px
labelWidth: 80,
//
componentProps: {
class: 'w-full',
}
},
schema: modalSchema(),
showDefaultActions: false,
wrapperClass: 'grid-cols-2',
});
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{
initializedGetter: defaultFormValueGetter(formApi),
currentGetter: defaultFormValueGetter(formApi),
},
);
const [BasicModal, modalApi] = useVbenModal({
//
class: 'w-[550px]',
fullscreenButton: false,
onBeforeClose,
onClosed: handleClosed,
onConfirm: handleConfirm,
onOpenChange: async (isOpen) => {
if (!isOpen) {
return null;
}
modalApi.modalLoading(true);
const { id } = modalApi.getData() as { id?: number | string };
isUpdate.value = !!id;
if (isUpdate.value && id) {
const record = await deviceGroupInfo(id);
await formApi.setValues(record);
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
// getValuesreadonly
const data = cloneDeep(await formApi.getValues());
await (isUpdate.value ? deviceGroupUpdate(data) : deviceGroupAdd(data));
resetInitialized();
emit('reload');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.lock(false);
}
}
async function handleClosed() {
await formApi.resetForm();
resetInitialized();
}
</script>
<template>
<BasicModal :title="title">
<BasicForm />
</BasicModal>
</template>

View File

@ -0,0 +1,182 @@
<script setup lang="ts">
import type { Recordable } from '@vben/types';
import { ref } from 'vue';
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space } from 'ant-design-vue';
import dayjs from 'dayjs';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps
} from '#/adapter/vxe-table';
import {
deviceGroupExport,
deviceGroupList,
deviceGroupRemove,
} from '#/api/sis/deviceGroup';
import type { DeviceGroupForm } from '#/api/sis/deviceGroup/model';
import { commonDownloadExcel } from '#/utils/file/download';
import deviceGroupModal from './deviceGroup-modal.vue';
import { columns, querySchema } from './data';
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 80,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
// RangePicker /
//
// fieldMappingTime: [
// [
// 'createTime',
// ['params[beginTime]', 'params[endTime]'],
// ['YYYY-MM-DD 00:00:00', 'YYYY-MM-DD 23:59:59'],
// ],
// ],
};
const gridOptions: VxeGridProps = {
checkboxConfig: {
//
highlight: true,
//
reserve: true,
//
// trigger: 'row',
},
// 使i18ngetter
// columns: columns(),
columns,
height: 'auto',
keepSource: true,
pagerConfig: {},
proxyConfig: {
ajax: {
query: async ({ page }, formValues = {}) => {
return await deviceGroupList({
pageNum: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
//
id: 'sis-deviceGroup-index'
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
const [DeviceGroupModal, modalApi] = useVbenModal({
connectedComponent: deviceGroupModal,
});
function handleAdd() {
modalApi.setData({});
modalApi.open();
}
async function handleEdit(row: Required<DeviceGroupForm>) {
modalApi.setData({ id: row.id });
modalApi.open();
}
async function handleDelete(row: Required<DeviceGroupForm>) {
await deviceGroupRemove(row.id);
await tableApi.query();
}
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: Required<DeviceGroupForm>) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
await deviceGroupRemove(ids);
await tableApi.query();
},
});
}
function handleDownloadExcel() {
commonDownloadExcel(deviceGroupExport, '设备组管理数据', tableApi.formApi.form.values, {
fieldMappingTime: formOptions.fieldMappingTime,
});
}
</script>
<template>
<Page :auto-content-height="true">
<BasicTable table-title="设备组管理列表">
<template #toolbar-tools>
<Space>
<a-button
v-access:code="['sis:deviceGroup:export']"
@click="handleDownloadExcel"
>
{{ $t('pages.common.export') }}
</a-button>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['sis:deviceGroup:remove']"
@click="handleMultiDelete">
{{ $t('pages.common.delete') }}
</a-button>
<a-button
type="primary"
v-access:code="['sis:deviceGroup:add']"
@click="handleAdd"
>
{{ $t('pages.common.add') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<ghost-button
v-access:code="['sis:deviceGroup:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['sis:deviceGroup:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<DeviceGroupModal @reload="tableApi.query()" />
</Page>
</template>

View File

@ -15,6 +15,11 @@ export const querySchema: FormSchemaGetter = () => [
fieldName: 'deviceIp',
label: '设备ip',
},
{
component: 'Input',
fieldName: 'deviceType',
label: '设备类型',
},
{
fieldName: 'deviceStatus',
label: '在线状态',
@ -34,6 +39,14 @@ export const columns: VxeGridProps['columns'] = [
title: '设备名称',
field: 'deviceName',
},
{
title: '厂商编号',
field: 'factoryNo',
},
{
title: '设备类型',
field: 'device_type',
},
{
title: '设备ip',
field: 'deviceIp',
@ -43,30 +56,13 @@ export const columns: VxeGridProps['columns'] = [
field: 'devicePort',
},
{
title: '设备',
title: '设备mac',
field: 'deviceMac',
},
{
title: '在线状态',
field: 'deviceStatus',
},
{
title: '通道编号',
field: 'channelNo',
},
{
title: '录像机ip',
field: 'vcrIp',
},
{
title: '录像机端口',
field: 'vcrPort',
},
/*{
title: '门禁id',
field: 'accessControlId',
},*/
{
field: 'action',
fixed: 'right',
@ -92,6 +88,18 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Input',
rules: 'required',
},
{
label: '设备厂商',
fieldName: 'facrotyNo',
component: 'Input',
rules: 'required',
},
{
label: '设备类型',
fieldName: 'deviceType',
component: 'Input',
rules: 'required',
},
{
label: '设备ip',
fieldName: 'deviceIp',
@ -116,53 +124,10 @@ export const modalSchema: FormSchemaGetter = () => [
component: 'Input',
rules: 'required',
},
{
label: '设备Mac',
fieldName: 'deviceMac',
component: 'Input',
},
{
label: '通道编号',
fieldName: 'channelNo',
component: 'Input',
},
{
label: '录像机ip',
fieldName: 'vcrIp',
component: 'Input',
},
{
label: '录像机端口',
fieldName: 'vcrPort',
component: 'Input',
},
{
label: '录像机账号',
fieldName: 'vcrAccount',
component: 'Input',
},
{
label: '录像机密码',
fieldName: 'vcrPwd',
component: 'Input',
},
/*{
label: '绑定门禁',
fieldName: 'accessControlId',
component: 'ApiSelect',
componentProps: {
// mode: 'multiple', // 关键属性,启用多选模式
resultField: 'list', // 根据API返回结构调整
labelField: 'accessName',
valueField: 'accessCode',
api: async () => {
const params: AccessControlQuery = {
pageNum: 1,
pageSize: 500,
};
const res = await accessControlList(params);
return res.rows;
},
},
},*/
];

View File

@ -126,7 +126,7 @@ function handleDownloadExcel() {
<template>
<Page :auto-content-height="true">
<BasicTable table-title="设备管理列表">
<BasicTable class="flex-1 overflow-hidden" table-title="设备管理列表">
<template #toolbar-tools>
<Space>
<a-button

View File

@ -0,0 +1,114 @@
<script setup lang="ts">
import type { PropType } from 'vue';
import { onMounted, ref } from 'vue';
import { SyncOutlined } from '@ant-design/icons-vue';
import { InputSearch, Skeleton, Tree } from 'ant-design-vue';
import { treeList } from '#/api/sis/deviceChannel';
import type { TreeNode } from '#/api/common';
defineOptions({ inheritAttrs: false });
withDefaults(defineProps<{ showSearch?: boolean }>(), { showSearch: true });
const emit = defineEmits<{
/**
* 点击刷新按钮的事件
*/
reload: [];
/**
* 点击节点的事件
*/
select: [];
}>();
const channelId = defineModel('channelId', {
required: true,
type: Array as PropType<string[]>,
});
const searchValue = defineModel('searchValue', {
type: String,
default: '',
});
/** 通道数据源 */
const channelTree = ref<TreeNode[]>([]);
/** 骨架屏加载 */
const showTreeSkeleton = ref<boolean>(true);
async function loadChannelTree() {
showTreeSkeleton.value = true;
searchValue.value = '';
channelId.value = [];
const ret = await treeList();
channelTree.value = ret;
showTreeSkeleton.value = false;
}
async function handleReload() {
await loadChannelTree();
emit('reload');
}
onMounted(loadChannelTree);
</script>
<template>
<div :class="$attrs.class">
<Skeleton
:loading="showTreeSkeleton"
:paragraph="{ rows: 8 }"
active
class="p-[8px]"
>
<div
class="bg-background flex h-full flex-col overflow-y-auto rounded-lg"
>
<!-- 固定在顶部 必须加上bg-background背景色 否则会产生'穿透'效果 -->
<div
v-if="showSearch"
class="bg-background z-100 sticky left-0 top-0 p-[8px]"
>
<InputSearch
v-model:value="searchValue"
:placeholder="$t('pages.common.search')"
size="small"
>
<template #enterButton>
<a-button @click="handleReload">
<SyncOutlined class="text-primary" />
</a-button>
</template>
</InputSearch>
</div>
<div class="h-full overflow-x-hidden px-[8px]">
<Tree
v-bind="$attrs"
v-if="channelTree.length > 0"
v-model:selected-keys="channelId"
:class="$attrs.class"
:field-names="{ title: 'label', key: 'id' }"
:show-line="{ showLeafIcon: false }"
:tree-data="channelTree"
:virtual="false"
default-expand-all
@select="$emit('select')"
>
<template #title="{ label }">
<span v-if="label.indexOf(searchValue) > -1">
{{ label.substring(0, label.indexOf(searchValue)) }}
<span style="color: #f50">{{ searchValue }}</span>
{{
label.substring(
label.indexOf(searchValue) + searchValue.length,
)
}}
</span>
<span v-else>{{ label }}</span>
</template>
</Tree>
</div>
</div>
</Skeleton>
</div>
</template>

View File

@ -0,0 +1,37 @@
<template>
<Page class="h-full w-full">
<!-- 设备分组区域 -->
<div class="flex h-full gap-[8px]">
<ChannelTree v-model:channel-id="channelId" class="w-[260px]" />
<!-- 设备分组区域 -->
<div class="bg-background flex-1">
<div class="video-play-area h-[calc(100%-40px)]">
<div
v-for="i in playerNum"
class="player"
:class="'player-' + i"
></div>
</div>
<div class="player-area h-[40px]">
</div>
</div>
</div>
</Page>
>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { Page } from '@vben/common-ui';
import ChannelTree from './channel-tree.vue';
const channelId = ref("");
/**
* 屏幕播放器数量
*/
const playerNum = ref(1);
</script>
<style></style>