视频预警

This commit is contained in:
fyy
2025-08-12 13:51:35 +08:00
parent 0a77934d8b
commit 1d1afb0162
22 changed files with 2260 additions and 379 deletions

View File

@@ -0,0 +1,265 @@
import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';
import { getDictOptions } from '#/utils/dict';
import { renderDict } from '#/utils/render';
import { h } from 'vue';
export const querySchema: FormSchemaGetter = () => [
{
component: 'Input',
fieldName: 'alarmType',
label: '视频预警类型',
},
{
component: 'Select',
componentProps: {
options: [
{ label: '特大', value: '特大' },
{ label: '重要', value: '重要' },
{ label: '一般', value: '一般' },
],
},
fieldName: 'level',
label: '级别',
},
{
component: 'Select',
componentProps: {
options: [
{ label: '待分配', value: '待分配' },
{ label: '处理中', value: '处理中' },
{ label: '已完成', value: '已完成' },
],
},
fieldName: 'processingStatus',
label: '处理状态',
},
];
export const columns: VxeGridProps['columns'] = [
{ type: 'checkbox', width: 60 },
{
title: '预警编号',
field: 'alarmId',
width: 150,
},
{
title: '预警时间',
field: 'alarmTime',
width: 150,
},
{
title: '设备名称',
field: 'deviceName',
width: 150,
},
{
title: '级别',
field: 'level',
width: 100,
slots: {
default: ({ row }: any) => {
const levelColors: Record<string, string> = {
: 'red',
: 'orange',
: 'blue',
};
return h(
'span',
{
style: {
color: levelColors[row.level] || '#666',
fontWeight: 'bold',
},
},
row.level,
);
},
},
},
{
title: '预警类型',
field: 'alarmType',
width: 120,
},
{
title: '描述',
field: 'description',
minWidth: 200,
},
{
title: '所在位置',
field: 'location',
width: 150,
},
{
title: '处理状态',
field: 'processingStatus',
width: 100,
slots: {
default: ({ row }: any) => {
const statusColors: Record<string, string> = {
: 'red',
: 'orange',
: 'green',
};
return h(
'span',
{
style: {
color: statusColors[row.processingStatus] || '#666',
fontWeight: 'bold',
},
},
row.processingStatus,
);
},
},
},
{
title: '处理情况',
field: 'processingDetails',
width: 150,
},
{
title: '预期处理时间',
field: 'expectedProcessingTime',
width: 150,
},
{
title: '处理时间',
field: 'processingTime',
width: 150,
},
{
field: 'action',
fixed: 'right',
slots: { default: 'action' },
title: '操作',
width: 380,
},
];
export const modalSchema: FormSchemaGetter = () => [
{
label: '主键',
fieldName: 'id',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
label: '预警编号',
fieldName: 'alarmId',
component: 'Input',
rules: 'required',
disabled: true,
},
{
label: '预警时间',
fieldName: 'alarmTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY.MM.DD HH:mm',
valueFormat: 'YYYY.MM.DD HH:mm',
showTime: true,
},
rules: 'required',
disabled: true,
},
{
label: '预警类型',
fieldName: 'alarmType',
component: 'Input',
rules: 'required',
disabled: true,
},
{
label: '描述',
fieldName: 'description',
component: 'Input',
formItemClass: 'col-span-2',
disabled: true,
},
{
label: '所在位置',
fieldName: 'location',
component: 'Input',
rules: 'required',
disabled: true,
},
{
label: '设备名称',
fieldName: 'deviceName',
component: 'Input',
rules: 'required',
disabled: true,
},
{
label: '处理情况',
fieldName: 'processingDetails',
component: 'Input',
componentProps: {
rows: 3,
},
formItemClass: 'col-span-2',
disabled: true,
},
{
label: '处理时间',
fieldName: 'processingTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY.MM.DD HH:mm',
valueFormat: 'YYYY.MM.DD HH:mm',
showTime: true,
},
disabled: true,
},
{
label: '处理图片',
fieldName: 'imgUrl',
component: 'Input',
rules: 'required',
disabled: true,
},
{
label: '级别',
fieldName: 'level',
component: 'Select',
componentProps: {
options: [
{ label: '特大', value: '特大' },
{ label: '重要', value: '重要' },
{ label: '一般', value: '一般' },
],
},
rules: 'selectRequired',
},
{
label: '处理状态',
fieldName: 'processingStatus',
component: 'Select',
componentProps: {
options: [
{ label: '待分配', value: '待分配' },
{ label: '处理中', value: '处理中' },
{ label: '已完成', value: '已完成' },
],
},
rules: 'selectRequired',
},
{
label: '预期处理时间',
fieldName: 'expectedProcessingTime',
component: 'DatePicker',
componentProps: {
format: 'YYYY.MM.DD HH:mm',
valueFormat: 'YYYY.MM.DD HH:mm',
showTime: true,
},
rules: 'required',
},
];

View File

@@ -0,0 +1,276 @@
<script setup lang="ts">
import { Page, useVbenModal, type VbenFormProps } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils';
import { Modal, Popconfirm, Space, Tag } from 'ant-design-vue';
import { ref, watch } from 'vue';
import {
useVbenVxeGrid,
vxeCheckboxChecked,
type VxeGridProps,
} from '#/adapter/vxe-table';
import { commonDownloadExcel } from '#/utils/file/download';
import { renderDict } from '#/utils/render';
import { columns, querySchema } from './data';
import warningModal from './warning-modal.vue';
import warningDetail from './warning-detail.vue';
import LevelSettingModal from './level-setting-modal.vue';
import imgPng from '../../../../assets/algorithmManagement/image.png';
// 假数据
const mockData = ref([
{
id: 1,
alarmId: 'JWD-3434234',
alarmTime: '2025.07.21 12:20',
level: '特大',
alarmType: '越界侦测',
description: '温度高于80度发生火宅',
location: '1栋3号电梯旁',
processingStatus: '待分配',
processingDetails: '',
processingTime: '',
},
{
id: 2,
alarmId: 'JWD-3434235',
alarmTime: '2025.07.21 11:15',
level: '重要',
alarmType: '异常行为',
description: '人员异常聚集',
location: '2栋大厅',
processingStatus: '待分配',
processingDetails: '已派人员前往处理',
processingTime: '2025.07.21 11:30',
},
{
id: 3,
alarmId: 'JWD-3434236',
alarmTime: '2025.07.21 10:45',
level: '一般',
alarmType: '设备故障',
description: '摄像头离线',
location: '3栋走廊',
processingStatus: '待分配',
processingDetails: '已修复设备',
processingTime: '2025.07.21 11:00',
},
{
id: 4,
alarmId: 'JWD-3434236',
alarmTime: '2025.07.21 10:45',
level: '一般',
alarmType: '设备故障',
description: '摄像头离线',
location: '3栋走廊',
processingStatus: '待分配',
processingDetails: '等待接受',
processingTime: '2025.07.21 11:00',
},
]);
const formOptions: VbenFormProps = {
commonConfig: {
labelWidth: 100,
componentProps: {
allowClear: true,
},
},
schema: querySchema(),
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3',
};
const gridOptions: VxeGridProps = {
columns,
height: 'auto',
data: mockData.value,
pagerConfig: {
currentPage: 1,
pageSize: 10,
total: mockData.value.length,
},
rowConfig: {
keyField: 'id',
},
id: 'video-warning-processing-index',
};
const [BasicTable, tableApi] = useVbenVxeGrid({
formOptions,
gridOptions,
});
// 监听数据变化,强制重新渲染表格
const tableKey = ref(0);
watch(
mockData,
() => {
tableKey.value++;
},
{ deep: true },
);
const [WarningModal, modalApi] = useVbenModal({
connectedComponent: warningModal,
});
const [WarningDetail, detailApi] = useVbenModal({
connectedComponent: warningDetail,
});
const [LevelSettingModalComp, levelModalApi] = useVbenModal({
connectedComponent: LevelSettingModal,
});
// 级别设置
function handleLevelSetting(row: any) {
levelModalApi.setData({ id: row.id, level: row.level, data: mockData.value });
levelModalApi.open();
}
// 查看详情
async function handleView(row: any) {
detailApi.setData({ id: row.id, data: mockData.value });
detailApi.open();
}
// 编辑
async function handleEdit(row: any) {
modalApi.setData({ id: row.id, data: mockData.value });
modalApi.open();
}
// 分配处理
function handleAssign(row: any) {
Modal.confirm({
title: '分配处理',
content: `确定要分配预警 ${row.alarmId} 给处理人员吗?`,
onOk() {
// 模拟分配处理
const index = mockData.value.findIndex((item: any) => item.id === row.id);
if (index !== -1) {
// mockData.value[index].processingStatus = '处理中';
// mockData.value[index].processingDetails = '已分配给处理人员';
// mockData.value[index].processingTime = new Date().toLocaleString();
tableApi.query();
}
},
});
}
// 删除
async function handleDelete(row: any) {
const index = mockData.value.findIndex((item: any) => item.id === row.id);
if (index !== -1) {
mockData.value.splice(index, 1);
await tableApi.query();
}
}
// 批量删除
function handleMultiDelete() {
const rows = tableApi.grid.getCheckboxRecords();
const ids = rows.map((row: any) => row.id);
Modal.confirm({
title: '提示',
okType: 'danger',
content: `确认删除选中的${ids.length}条记录吗?`,
onOk: async () => {
ids.forEach((id) => {
const index = mockData.value.findIndex((item: any) => item.id === id);
if (index !== -1) {
mockData.value.splice(index, 1);
}
});
await tableApi.query();
},
});
}
</script>
<template>
<Page :auto-content-height="true">
<BasicTable
:key="tableKey"
class="flex-1 overflow-hidden"
table-title="视频预警处理"
>
<template #toolbar-tools>
<Space>
<a-button
:disabled="!vxeCheckboxChecked(tableApi)"
danger
type="primary"
v-access:code="['video:warning:remove']"
@click="handleMultiDelete"
>
{{ $t('pages.common.delete') }}
</a-button>
</Space>
</template>
<template #action="{ row }">
<Space>
<!-- <ghost-button
v-access:code="['video:warning:level']"
@click.stop="handleLevelSetting(row)"
>
级别设置
</ghost-button> -->
<ghost-button
v-access:code="['video:warning:view']"
@click.stop="handleView(row)"
>
{{ $t('pages.common.info') }}
</ghost-button>
<ghost-button
v-access:code="['video:warning:edit']"
@click.stop="handleEdit(row)"
>
{{ $t('pages.common.edit') }}
</ghost-button>
<ghost-button
v-access:code="['video:warning:assign']"
@click.stop="handleAssign(row)"
:disabled="row.processingStatus === '已完成'"
>
分配处理
</ghost-button>
<Popconfirm
:get-popup-container="getVxePopupContainer"
placement="left"
title="确认删除?"
@confirm="handleDelete(row)"
>
<ghost-button
danger
v-access:code="['video:warning:remove']"
@click.stop=""
>
{{ $t('pages.common.delete') }}
</ghost-button>
</Popconfirm>
</Space>
</template>
</BasicTable>
<WarningModal @reload="tableApi.query()" />
<WarningDetail />
<LevelSettingModalComp @reload="tableKey++" />
</Page>
</template>
<style scoped lang="scss">
.ant-table-wrapper {
.ant-table-thead > tr > th {
background-color: #fafafa;
font-weight: 600;
}
}
.ant-pagination {
.ant-pagination-item-active {
background-color: #1890ff;
border-color: #1890ff;
}
}
</style>

View File

@@ -0,0 +1,45 @@
<template>
<BasicModal>
<RadioGroup v-model:value="selectedLevel">
<Radio value="特大">特大</Radio>
<Radio value="重要">重要</Radio>
<Radio value="一般">一般</Radio>
</RadioGroup>
</BasicModal>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import { RadioGroup, Radio } from 'ant-design-vue';
const emit = defineEmits<{ reload: [] }>();
const selectedLevel = ref('一般');
const [BasicModal, modalApi] = useVbenModal({
class: 'w-[360px]',
title: '设置级别',
onOpenChange: async (isOpen) => {
if (!isOpen) return null;
const { level } = modalApi.getData() as { level?: string };
selectedLevel.value = level || '一般';
},
onConfirm: handleConfirm,
});
function handleConfirm() {
const { id, data } = modalApi.getData() as {
id: number | string;
data: any[];
};
if (id != null && data) {
const idx = data.findIndex((item: any) => item.id === id);
if (idx !== -1) {
data[idx].level = selectedLevel.value;
}
}
emit('reload');
modalApi.close();
}
</script>

View File

@@ -0,0 +1,147 @@
<script setup lang="ts">
import { shallowRef } from 'vue';
import { useVbenModal } from '@vben/common-ui';
import {
Descriptions,
DescriptionsItem,
Tag,
Timeline,
TimelineItem,
} from 'ant-design-vue';
const [BasicModal, modalApi] = useVbenModal({
onOpenChange: handleOpenChange,
onClosed() {
warningDetail.value = null;
},
});
const warningDetail = shallowRef<any>(null);
async function handleOpenChange(open: boolean) {
if (!open) {
return null;
}
modalApi.modalLoading(true);
const { id, data } = modalApi.getData() as {
id: number | string;
data: any[];
};
// 从传递的数据中查找对应的记录
const record = data.find((item: any) => item.id === id);
if (record) {
warningDetail.value = record;
}
modalApi.modalLoading(false);
}
</script>
<template>
<BasicModal
:footer="false"
:fullscreen-button="false"
title="预警详情"
class="w-[70%]"
>
<Descriptions
v-if="warningDetail"
size="small"
:column="2"
bordered
:labelStyle="{ width: '120px' }"
style="margin-bottom: 30px"
>
<DescriptionsItem label="预警编号">
{{ warningDetail.alarmId }}
</DescriptionsItem>
<DescriptionsItem label="预警时间">
{{ warningDetail.alarmTime }}
</DescriptionsItem>
<DescriptionsItem label="级别">
<Tag
:color="
warningDetail.level === '特大'
? 'red'
: warningDetail.level === '重要'
? 'orange'
: 'blue'
"
>
{{ warningDetail.level }}
</Tag>
</DescriptionsItem>
<DescriptionsItem label="预警类型">
{{ warningDetail.alarmType }}
</DescriptionsItem>
<DescriptionsItem label="描述" :span="2">
{{ warningDetail.description }}
</DescriptionsItem>
<DescriptionsItem label="所在位置">
{{ warningDetail.location }}
</DescriptionsItem>
<DescriptionsItem label="处理状态">
<Tag
:color="
warningDetail.processingStatus === '待分配'
? 'red'
: warningDetail.processingStatus === '处理中'
? 'orange'
: 'green'
"
>
{{ warningDetail.processingStatus }}
</Tag>
</DescriptionsItem>
<DescriptionsItem label="处理情况" :span="2">
{{ warningDetail.processingDetails || '-' }}
</DescriptionsItem>
<DescriptionsItem label="处理时间">
{{ warningDetail.processingTime || '-' }}
</DescriptionsItem>
<DescriptionsItem label="设备名称">
{{ warningDetail.deviceName || '-' }}
</DescriptionsItem>
<DescriptionsItem
label="预处理时间"
v-if="warningDetail.processingStatus === '处理中'"
>
{{ warningDetail.expectedProcessingTime || '-' }}
</DescriptionsItem>
<DescriptionsItem
label="处理图片"
v-if="warningDetail.processingStatus === '已完成'"
>
<img
:src="warningDetail.imgUrl"
alt="处理图片"
style="max-width: 200px; max-height: 150px"
/>
</DescriptionsItem>
</Descriptions>
<Timeline>
<TimelineItem>
<p style="display: flex">类型已完成</p>
<p>时间2025-06-01 11:07:59</p>
<p>处理人张三</p>
</TimelineItem>
<TimelineItem>
<p style="display: flex">类型处理异常</p>
<p>时间2025-06-01 11:07:59</p>
<p>处理人张三</p>
<p>异常原因时长不够</p>
</TimelineItem>
<TimelineItem>
<p style="display: flex">类型处理中</p>
<p>时间2025-06-01 11:07:59</p>
<p>处理人张三</p>
</TimelineItem>
<TimelineItem>
<p style="display: flex">类型创建预警</p>
<p>时间2025-06-01 11:07:59</p>
<p>处理人张三</p>
</TimelineItem>
</Timeline>
</BasicModal>
</template>

View File

@@ -0,0 +1,121 @@
<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 { 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-1',
labelWidth: 110,
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-[70%]',
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 { data } = modalApi.getData() as {
id: number | string;
data: any[];
};
const record = data.find((item: any) => item.id === id);
if (record) {
await formApi.setValues(record);
}
}
await markInitialized();
modalApi.modalLoading(false);
},
});
async function handleConfirm() {
try {
modalApi.lock(true);
const { valid } = await formApi.validate();
if (!valid) {
return;
}
const formData = cloneDeep(await formApi.getValues());
// 更新表格数据
const { data } = modalApi.getData() as { id: number | string; data: any[] };
const index = data.findIndex((item: any) => item.id === formData.id);
if (index !== -1) {
// 更新数据
Object.assign(data[index], formData);
}
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>
<style scoped>
/* 使用 :deep() 穿透 scoped 样式,影响子组件 */
:deep(.ant-input[disabled]),
:deep(.ant-input-number-disabled .ant-input-number-input),
:deep(.ant-select-disabled .ant-select-selection-item),
:deep(.ant-picker-disabled .ant-picker-input > input) {
/* 设置一个更深的颜色 */
color: rgb(0 0 0 / 65%) !important;
/* 有些浏览器需要这个来覆盖默认颜色 */
-webkit-text-fill-color: rgb(0 0 0 / 65%) !important;
}
</style>