fect: 代码优化

develop
JINGYJ 1 year ago
parent f3357251d0
commit b12d2b8658

@ -364,11 +364,11 @@ export default [
component: 'System/UserList', component: 'System/UserList',
access: 'canReadMenu', access: 'canReadMenu',
}, },
{ // {
name: 'involved-list', // name: 'involved-list',
path: '/involved-list', // path: '/involved-list',
component: 'Alarm/InvolvedList', // component: 'Alarm/InvolvedList',
}, // },
{ {
name: 'videoAnalysis', name: 'videoAnalysis',
path: '/videoAnalysis', path: '/videoAnalysis',
@ -379,4 +379,26 @@ export default [
path: '/involved-list-upload', path: '/involved-list-upload',
component: 'Alarm/InvolvedUploadList', 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": "首页", "title": "首页",
"routes": [] "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", "path": "/alarm/alarm-list",
"key": "", "key": "",
@ -81,16 +122,16 @@ export async function getInitialState(): Promise<{
"title": "告警规则", "title": "告警规则",
"routes": [] "routes": []
}, },
{ // {
"path": "involved-list", // "path": "involved-list",
"key": "", // "key": "",
"name": "involved-list", // "name": "involved-list",
"icon": "FileSearchOutlined", // "icon": "FileSearchOutlined",
"access": "", // "access": "",
"component": "Hidden", // "component": "Hidden",
"title": "重点关注", // "title": "重点关注",
"routes": [] // "routes": []
}, // },
{ {
"path": "interfaceManage", "path": "interfaceManage",
"key": "", "key": "",

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

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

@ -274,7 +274,7 @@ const InvolvedDetails: React.FC<UpdateFormProps> = (props) => {
{index + 1 !== total && <span />} {index + 1 !== total && <span />}
</div> </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> <div>
<Image <Image

@ -145,6 +145,47 @@ const Login: React.FC = () => {
"title": "首页", "title": "首页",
"routes": [] "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", "path": "/alarm/alarm-list",
"key": "", "key": "",
@ -165,16 +206,16 @@ const Login: React.FC = () => {
"title": "告警规则", "title": "告警规则",
"routes": [] "routes": []
}, },
{ // {
"path": "involved-list", // "path": "involved-list",
"key": "", // "key": "",
"name": "involved-list", // "name": "involved-list",
"icon": "FileSearchOutlined", // "icon": "FileSearchOutlined",
"access": "", // "access": "",
"component": "Hidden", // "component": "Hidden",
"title": "重点关注", // "title": "重点关注",
"routes": [] // "routes": []
}, // },
{ {
"path": "interfaceManage", "path": "interfaceManage",
"key": "", "key": "",

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

@ -72,6 +72,9 @@ const VideoAnalysis: React.FC = () => {
const [tab, setTab] = useState<string>(alarmVideoAnalysis[0].key); const [tab, setTab] = useState<string>(alarmVideoAnalysis[0].key);
const [tabs, setTabs] = useState<any>([]); const [tabs, setTabs] = useState<any>([]);
const [importDate, setImportDate] = useState<any>(null);
const [innerDate, setInnerDate] = useState<any>(null);
const changeProjectTab = (key: string) => { const changeProjectTab = (key: string) => {
setTab(key); setTab(key);
console.log(key); console.log(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 = { const reqParams = {
page: currentPage, page: currentPage,
pageSize: currentPageSize, pageSize: currentPageSize,
// desc: false, // desc: false,
warning_type: tabId, warning_type: tabId,
analyse_time: date
// ...rest, // ...rest,
}; };
const resp = await postUploadAlarmList({ ...reqParams }); const resp = await postUploadAlarmList({ ...reqParams });
@ -237,33 +241,6 @@ const VideoAnalysis: React.FC = () => {
// setCurrentPageSize(resp?.data?.count) // setCurrentPageSize(resp?.data?.count)
setTotal(resp?.data?.count) setTotal(resp?.data?.count)
initDataTestList(resp?.data?.results); 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) => { const handleChange: UploadProps['onChange'] = (info) => {
if (info.file.status === 'uploading') { if (info.file.status === 'uploading') {
@ -282,7 +259,10 @@ const VideoAnalysis: React.FC = () => {
} }
}; };
const onChange: DatePickerProps['onChange'] = (date, dateString) => { const onChange: DatePickerProps['onChange'] = (date, dateString) => {
console.log(date, dateString); console.log(dateString);
setImportDate(date)
setInnerDate(dateString)
console.log(importDate,'importDate');
}; };
useEffect(() => { useEffect(() => {
getTabs(); getTabs();
@ -332,11 +312,13 @@ const VideoAnalysis: React.FC = () => {
}} }}
></Tabs> ></Tabs>
<div style={{ padding: '16px 16px 0'}}> <div style={{ padding: '16px 16px 0'}}>
<DatePicker locale={locale} onChange={onChange} /> <DatePicker locale={locale} value={importDate} onChange={onChange} allowClear />
<Button type="primary" <Button type="primary"
style={{ margin: '0 16px' }} style={{ margin: '0 16px' }}
onClick={() => { onClick={() => {
// setCreateModalOpen(true); // setCreateModalOpen(true);
setImportDate(null);
initList(tab, null)
}} }}
> >
@ -344,6 +326,7 @@ const VideoAnalysis: React.FC = () => {
<Button type="primary" <Button type="primary"
onClick={() => { onClick={() => {
// setCreateModalOpen(true); // setCreateModalOpen(true);
initList(tab, innerDate)
}} }}
> >

@ -58,3 +58,21 @@ export async function postUploadAlarmList(
}, },
); );
} }
/** 上传忽略事件 */
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; warning_type?: any;
origin?: any; origin?: any;
person_id_list?: any; person_id_list?: any;
id?: any;
} }
type IgnoringventsParams = { type IgnoringventsParams = {
is_ignore?: any; // 设备代码 // 是否启用 is_ignore?: any; // 设备代码 // 是否启用
person_id?: string; person_id?: string;
} }
type UploadIgnoringventsParams = {
is_ignore?: any; // 设备代码 // 是否启用
id?: string;
}
type SearchInvolvedParams = { type SearchInvolvedParams = {
/** 人员标识 0为正常1为重点关注2为白名单 */ /** 人员标识 0为正常1为重点关注2为白名单 */
classify?: string; classify?: string;

Loading…
Cancel
Save