fect: 代码优化

develop
JINGYJ 11 months ago
parent f3357251d0
commit b12d2b8658

@ -364,11 +364,11 @@ export default [
component: 'System/UserList',
access: 'canReadMenu',
},
{
name: 'involved-list',
path: '/involved-list',
component: 'Alarm/InvolvedList',
},
// {
// name: 'involved-list',
// path: '/involved-list',
// component: 'Alarm/InvolvedList',
// },
{
name: 'videoAnalysis',
path: '/videoAnalysis',
@ -379,4 +379,26 @@ export default [
path: '/involved-list-upload',
component: 'Alarm/InvolvedUploadList',
},
{
name: 'realTime',
path: '/realTime',
routes: [
// {
// name: 'alarm_rules',
// path: '/realTime/alarm_rules',
// component: 'Alarm/alarmRules',
// },
// {
// name: 'alarm-list',
// path: '/realTime/alarm-list',
// component: 'Alarm/AlarmList',
// access: 'canReadMenu',
// },
{
name: 'involved-list',
path: '/realTime/involved-list',
component: 'Alarm/InvolvedList',
},
],
},
];

@ -61,6 +61,47 @@ export async function getInitialState(): Promise<{
"title": "首页",
"routes": []
},
{
"path": "/realTime",
"key": "",
"name": "realTime",
"icon": "WarningOutlined",
"access": "",
"component": "",
"title": "实时分析",
"routes": [
// {
// "access": "",
// "component": "Alarm/AlarmList",
// "icon": "",
// "key": "",
// "name": "alarm-list",
// "path": "/realTime/alarm-list",
// "routes": [],
// "title": "告警列表",
// },
// {
// "access": "",
// "component": "Alarm/AlarmRules",
// "icon": "",
// "key": "",
// "name": "alarm_rules",
// "path": "/realTime/alarm_rules",
// "routes": [],
// "title": "告警规则",
// },
{
"access": "",
"component": "Alarm/InvolvedList",
"icon": "",
"key": "",
"name": "involved-list",
"path": "/realTime/involved-list",
"routes": [],
"title": "重点关注",
}
]
},
{
"path": "/alarm/alarm-list",
"key": "",
@ -81,16 +122,16 @@ export async function getInitialState(): Promise<{
"title": "告警规则",
"routes": []
},
{
"path": "involved-list",
"key": "",
"name": "involved-list",
"icon": "FileSearchOutlined",
"access": "",
"component": "Hidden",
"title": "重点关注",
"routes": []
},
// {
// "path": "involved-list",
// "key": "",
// "name": "involved-list",
// "icon": "FileSearchOutlined",
// "access": "",
// "component": "Hidden",
// "title": "重点关注",
// "routes": []
// },
{
"path": "interfaceManage",
"key": "",

@ -93,9 +93,9 @@ export function useKeepAliveTabs() {
useEffect(() => {
if (!matchRoute) return;
const existKeepAliveTab = keepAliveTabs.find(o => o.routePath === matchRoute?.routePath);
// console.log(matchRoute.isHideTab,'matchRoute.isHideTab');
setActiveTabRoutePath(matchRoute.routePath);
// 如果不存在则需要插入
@ -126,6 +126,10 @@ export function useKeepAliveTabs() {
return [...prev];
});
} else {
// 取消缓存
if(matchRoute?.pathname === '/involved-list-upload' || matchRoute?.pathname === '/involved-list') {
refreshTab(matchRoute?.pathname)
}
// 如果存在触发组件的onShow的回调
(keepAliveShowEvents.current[existKeepAliveTab.routePath] || []).forEach(cb => {
cb();

@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { Image, Popover, Button, message } from 'antd';
import { CloseCircleOutlined, EllipsisOutlined } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
import { postRecognition } from '@/services/alarm/Involved';
import { postUploadRecognition } from '@/services/alarm/Involved';
interface ImageWithPopoverProps {
src: string;
@ -25,7 +25,7 @@ const ImageWithPopover: React.FC<ImageWithPopoverProps> = ({ src, person_id,relo
icon={<CloseCircleOutlined style={{ color: '#E80D0D',fontSize: 12}} />}
onClick={(event)=>{
event.stopPropagation();
postRecognition({
postUploadRecognition({
person_id: person_id,
classify: '0'
})

@ -274,7 +274,7 @@ const InvolvedDetails: React.FC<UpdateFormProps> = (props) => {
{index + 1 !== total && <span />}
</div>
}
title={<div style={{ lineHeight: '30px', color: '#666' }}>: <span style={{ color: '#333', marginRight: 16}}>{moment(item.appear_time).format('YYYY-MM-DD hh:mm:ss')}</span> : <span style={{ color: '#333'}}>{item.video_name}</span></div>}
title={<div style={{ lineHeight: '30px', color: '#666' }}>: <span style={{ color: '#333', marginRight: 16}}>{moment(item.create_time).format('YYYY-MM-DD hh:mm:ss')}</span> : <span style={{ color: '#333'}}>{item.video_name}</span></div>}
/>
<div>
<Image

@ -145,6 +145,47 @@ const Login: React.FC = () => {
"title": "首页",
"routes": []
},
{
"path": "/realTime",
"key": "",
"name": "realTime",
"icon": "WarningOutlined",
"access": "",
"component": "",
"title": "实时分析",
"routes": [
// {
// "access": "",
// "component": "Alarm/AlarmList",
// "icon": "",
// "key": "",
// "name": "alarm-list",
// "path": "/realTime/alarm-list",
// "routes": [],
// "title": "告警列表",
// },
// {
// "access": "",
// "component": "Alarm/AlarmRules",
// "icon": "",
// "key": "",
// "name": "alarm_rules",
// "path": "/realTime/alarm_rules",
// "routes": [],
// "title": "告警规则",
// },
{
"access": "",
"component": "Alarm/InvolvedList",
"icon": "",
"key": "",
"name": "involved-list",
"path": "/realTime/involved-list",
"routes": [],
"title": "重点关注",
}
]
},
{
"path": "/alarm/alarm-list",
"key": "",
@ -165,16 +206,16 @@ const Login: React.FC = () => {
"title": "告警规则",
"routes": []
},
{
"path": "involved-list",
"key": "",
"name": "involved-list",
"icon": "FileSearchOutlined",
"access": "",
"component": "Hidden",
"title": "重点关注",
"routes": []
},
// {
// "path": "involved-list",
// "key": "",
// "name": "involved-list",
// "icon": "FileSearchOutlined",
// "access": "",
// "component": "Hidden",
// "title": "重点关注",
// "routes": []
// },
{
"path": "interfaceManage",
"key": "",

@ -3,7 +3,7 @@ import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProF
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form, message,Image, Button, Popover } from 'antd';
import React, { useEffect, useState } from 'react';
import { postIgnoringvents } from '@/services/alarm/Alarmlist';
import { postUploadIgnoringvents } from '@/services/alarm/Alarmlist';
import { postUploadRecognition } from '@/services/alarm/Involved';
// Import Swiper React components
// import { Swiper, SwiperSlide } from 'swiper/react';
@ -173,9 +173,9 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
submitTimeout={2000}
onFinish={async (values) => {
values.is_ignore = true
values.person_id = props.values.person_id
// console.log(values);
postIgnoringvents(values)
values.id = props.values.id
// console.log(props.values);
postUploadIgnoringvents(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();

@ -71,6 +71,9 @@ const VideoAnalysis: React.FC = () => {
const [tab, setTab] = useState<string>(alarmVideoAnalysis[0].key);
const [tabs, setTabs] = useState<any>([]);
const [importDate, setImportDate] = useState<any>(null);
const [innerDate, setInnerDate] = useState<any>(null);
const changeProjectTab = (key: string) => {
setTab(key);
@ -224,12 +227,13 @@ const VideoAnalysis: React.FC = () => {
}
// 初始化加载
async function initList(tabId:string = tab) {
async function initList(tabId:string = tab, date: any = null) {
const reqParams = {
page: currentPage,
pageSize: currentPageSize,
// desc: false,
warning_type: tabId,
analyse_time: date
// ...rest,
};
const resp = await postUploadAlarmList({ ...reqParams });
@ -237,33 +241,6 @@ const VideoAnalysis: React.FC = () => {
// setCurrentPageSize(resp?.data?.count)
setTotal(resp?.data?.count)
initDataTestList(resp?.data?.results);
// request={async (params = {}, sort) => {
// const { current, ...rest } = params;
// const reqParams = {
// page: current,
// desc: false,
// warning_type: tab,
// ...rest,
// };
// if (sort && Object.keys(sort).length) {
// reqParams.orderKey = Object.keys(sort)[0];
// let sort_select = sort[reqParams.orderKey];
// reqParams.desc = sort_select === 'descend';
// }
// // TODO 联调查询设备状态接口
// console.log(reqParams, 'reqParams');
// let resp = await postUploadAlarmList({ ...reqParams });
// console.log(resp, 'postAlarmList_result');
// initDataTestList(resp.result);
// // return {
// // data: resp.result,
// // success: resp.success,
// // total: resp.count,
// // current: resp.count,
// // pageSize: resp.count,
// // };
// }}
}
const handleChange: UploadProps['onChange'] = (info) => {
if (info.file.status === 'uploading') {
@ -282,7 +259,10 @@ const VideoAnalysis: React.FC = () => {
}
};
const onChange: DatePickerProps['onChange'] = (date, dateString) => {
console.log(date, dateString);
console.log(dateString);
setImportDate(date)
setInnerDate(dateString)
console.log(importDate,'importDate');
};
useEffect(() => {
getTabs();
@ -332,11 +312,13 @@ const VideoAnalysis: React.FC = () => {
}}
></Tabs>
<div style={{ padding: '16px 16px 0'}}>
<DatePicker locale={locale} onChange={onChange} />
<DatePicker locale={locale} value={importDate} onChange={onChange} allowClear />
<Button type="primary"
style={{ margin: '0 16px' }}
onClick={() => {
// setCreateModalOpen(true);
setImportDate(null);
initList(tab, null)
}}
>
@ -344,6 +326,7 @@ const VideoAnalysis: React.FC = () => {
<Button type="primary"
onClick={() => {
// setCreateModalOpen(true);
initList(tab, innerDate)
}}
>

@ -57,4 +57,22 @@ export async function postUploadAlarmList(
...(options || {}),
},
);
}
/** 上传忽略事件 */
export async function postUploadIgnoringvents(
body: API.UploadIgnoringventsParams,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(
`/api/ignore_warning_info/`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
},
);
}

@ -95,11 +95,16 @@ declare namespace API {
warning_type?: any;
origin?: any;
person_id_list?: any;
id?: any;
}
type IgnoringventsParams = {
is_ignore?: any; // 设备代码 // 是否启用
person_id?: string;
}
type UploadIgnoringventsParams = {
is_ignore?: any; // 设备代码 // 是否启用
id?: string;
}
type SearchInvolvedParams = {
/** 人员标识 0为正常1为重点关注2为白名单 */
classify?: string;

Loading…
Cancel
Save