fect: 离线告警规则接口联调

develop
JINGYJ 1 year ago
parent 66bf130b49
commit 61aceb63c5

@ -355,11 +355,11 @@ export default [
// path: '/alarm_rules',
// component: 'Alarm/alarmRules',
// },
{
name: 'interfaceManage',
path: '/interfaceManage',
component: 'Setting/interfaceManage',
},
// {
// name: 'interfaceManage',
// path: '/interfaceManage',
// component: 'Setting/interfaceManage',
// },
// {
// name: 'userList',
// path: '/userList',
@ -401,6 +401,11 @@ export default [
path: '/realTime/involved-list',
component: 'Alarm/InvolvedList',
},
{
name: 'interfaceManage',
path: '/realTime/interfaceManage',
component: 'Setting/interfaceManage',
},
],
},
{
@ -423,6 +428,11 @@ export default [
path: '/offline/involved-list-upload',
component: 'Alarm/InvolvedUploadList',
},
{
name: 'RealTimeInterfaceManage',
path: '/offline/RealTimeInterfaceManage',
component: 'Setting/RealTimeInterfaceManage',
},
],
},
];

@ -99,6 +99,16 @@ export async function getInitialState(): Promise<{
"path": "/realTime/involved-list",
"routes": [],
"title": "告警汇总",
},
{
"access": "",
"component": "Setting/interfaceManage",
"icon": "",
"key": "",
"name": "interfaceManage",
"path": "/realTime/interfaceManage",
"routes": [],
"title": "接口管理",
}
]
},
@ -170,19 +180,29 @@ export async function getInitialState(): Promise<{
"path": "/offline/involved-list-upload",
"routes": [],
"title": "告警汇总",
},
{
"access": "",
"component": "Setting/RealTimeInterfaceManage",
"icon": "",
"key": "",
"name": "RealTimeInterfaceManage",
"path": "/offline/RealTimeInterfaceManage",
"routes": [],
"title": "设备管理",
}
]
},
{
"path": "interfaceManage",
"key": "",
"name": "interfaceManage",
"icon": "BranchesOutlined",
"access": "",
"component": "Hidden",
"title": "接口管理",
"routes": []
},
// {
// "path": "interfaceManage",
// "key": "",
// "name": "interfaceManage",
// "icon": "BranchesOutlined",
// "access": "",
// "component": "Hidden",
// "title": "接口管理",
// "routes": []
// },
// {
// "path": "userList",
// "key": "",

@ -82,7 +82,29 @@ export const interface_manage: { [key: string]: string } = {
'device.interface_manage.table.list.addPic': '新建图像获取接口',
'device.interface_manage.table.list.updatePic': '编辑图像获取接口',
'device.interface_manage.table.list.capture': '最近拍摄',
'device.interface_manage.table.list.port': '端口',
'device.interface_manage.table.list.loginName': '登录名',
'device.interface_manage.table.list.password': '密码',
'device.interface_manage.table.list.fileDirectory': '文件目录',
'device.interface_manage.table.list.requestAddress': '请求地址',
'device.interface_manage.table.list.requestKey': '请求Key',
'device.interface_manage.table.list.secretKey': '秘钥',
'device.interface_manage.table.list.bucket': 'Bucket',
'device.interface_manage.table.list.Code': 'Code',
'device.interface_manage.table.list.addVideoSource': '新建视频源',
'device.interface_manage.table.list.updatVideoSource': '编辑视频源',
'device.interface_manage.table.list.videoName': '视频源名称',
'device.interface_manage.table.list.obtainMode': '获取方式',
'device.interface_manage.table.list.obtainStatus': '获取状态',
'device.interface_manage.table.rule.required.name': '接口名称为必填项',
'device.interface_manage.table.rule.required.address': '接口地址为必填项',
'device.interface_manage.table.rule.required.ip': 'IP地址为必填项',
'device.interface_manage.table.rule.required.loginName': '登录名为必填项',
'device.interface_manage.table.rule.required.password': '密码为必填项',
'device.interface_manage.table.rule.required.fileDirectory': '文件目录为必填项',
'device.interface_manage.table.rule.required.requestAddress': '请求地址为必填项',
'device.interface_manage.table.rule.required.requestKey': '请求Key为必填项',
'device.interface_manage.table.rule.required.secretKey': '请求Key为必填项',
'device.interface_manage.table.rule.required.bucket': 'Bucket为必填项',
'device.interface_manage.table.rule.required.Code': 'Code为必填项',
};

@ -69,7 +69,7 @@
.alarmImgContent {
box-sizing: border-box;
margin-bottom: 24px;
padding: 16px;
padding: 16px 0 16px 16px;
width: 784px;
// height: 172px;
background: #F7F7F7;
@ -77,6 +77,7 @@
border: 1px dashed #DCDCDC;
display: flex;
justify-content: center;
flex-wrap: wrap;
}
}
.myButtonDisabled{

@ -62,7 +62,7 @@ const ImageSinglePopover: React.FC<ImageSinglePopoverProps> = ({ src, involved,
// };
return (
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 160, marginRight: 12 }}>
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 170, marginRight: 12 }}>
<Image
style={{ borderRadius: 4 }}
width={140}

@ -59,7 +59,7 @@ const ImageWithPopover: React.FC<ImageWithPopoverProps> = ({ src, involved, inde
};
return (
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 160, marginRight: 12 }}>
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 170, marginRight: 12 }}>
<Image
style={{ borderRadius: 4 }}
width={140}
@ -83,7 +83,7 @@ const ImageWithPopover: React.FC<ImageWithPopoverProps> = ({ src, involved, inde
onOpenChange={handleOpenChange}
>
<Button
style={{ position: 'absolute', bottom: 20, right: 0 }}
style={{ position: 'absolute', bottom: 30, right: 0 }}
type="text"
icon={<EllipsisOutlined style={{ color: '#fff', fontSize: 24, transform: 'rotate(90deg)' }} />}
/>

@ -1,6 +1,6 @@
import { alarmRulesEnums } from '@/enums/status';
import { ActionType, PageContainer, ProCard, ProList, useIntl } from '@ant-design/pro-components';
import { Button, DatePicker, Image, Modal, Tabs } from 'antd';
import { Button, Checkbox, DatePicker, Image, Modal, Tabs } from 'antd';
import React, { useEffect, useRef, useState } from 'react';
import { proTablePaginationOptions } from '../../../../config/defaultTable';
// import DeviceStatusCard from './components/DeviceStatusCard';
@ -11,6 +11,8 @@ import InvolvedDetails from './components/InvolvedDetails';
import moment from 'moment';
import ImageWithPopover from './components/ImageWithPopover';
import locale from 'antd/es/date-picker/locale/zh_CN';
import { DatePickerProps } from 'antd/lib/date-picker';
import { CheckboxProps } from 'antd/lib/checkbox';
/**
* @
@ -69,6 +71,7 @@ const InvolvedList: React.FC = () => {
const [importDate, setImportDate] = useState<any>(null);
const [innerDate, setInnerDate] = useState<any>(null);
const [classify, setClassify] = useState<string>('all');
// const changeProjectTab = (key: string) => {
// setTab(key);
// console.log(key);
@ -227,7 +230,7 @@ const InvolvedList: React.FC = () => {
}
// 初始化加载
async function initList(tabId:string = '1',date: any = null) {
async function initList(tabId:string = 'all',date: any = null) {
const reqParams = {
page: currentPage,
pageSize: currentPageSize,
@ -275,6 +278,16 @@ const InvolvedList: React.FC = () => {
setInnerDate(dateString)
console.log(importDate,'importDate');
};
const onChangeCheckbox: CheckboxProps['onChange'] = (e) => {
console.log(`checked = ${e.target.checked}`);
if(e.target.checked) {
setClassify('1')
initList('1', innerDate)
}else {
setClassify('all')
initList('all', innerDate)
}
};
useEffect(() => {
getTabs();
initList();
@ -311,26 +324,29 @@ const InvolvedList: React.FC = () => {
changeProjectTab(key);
}}
></Tabs> */}
<div style={{ padding: '16px 16px 0'}}>
<DatePicker locale={locale} value={importDate} onChange={onChange} allowClear />
<Button type="primary"
style={{ margin: '0 16px' }}
<div style={{ padding: '16px 16px 0', display:'flex',justifyContent: 'space-between',alignItems:'center'}}>
<div>
<DatePicker locale={locale} value={importDate} onChange={onChange} allowClear />
<Button type="primary"
style={{ margin: '0 16px' }}
onClick={() => {
// setCreateModalOpen(true);
setImportDate(null);
initList(classify, null)
}}
>
</Button>
<Button type="primary"
onClick={() => {
// setCreateModalOpen(true);
setImportDate(null);
initList(tab, null)
initList(classify, innerDate)
}}
>
</Button>
<Button type="primary"
onClick={() => {
// setCreateModalOpen(true);
initList(tab, innerDate)
}}
>
</Button>
</Button>
</div>
<Checkbox onChange={onChangeCheckbox}></Checkbox>
</div>
<ProList<any>
className="gn"

@ -1,6 +1,6 @@
import { alarmRulesEnums } from '@/enums/status';
import { ActionType, PageContainer, ProCard, ProList, useIntl } from '@ant-design/pro-components';
import { Image, Modal, Tabs } from 'antd';
import { Button, Checkbox, DatePicker, Image, Modal, Tabs } from 'antd';
import React, { useEffect, useRef, useState } from 'react';
import { proTablePaginationOptions } from '../../../../config/defaultTable';
// import DeviceStatusCard from './components/DeviceStatusCard';
@ -10,6 +10,9 @@ import { QuestionCircleFilled } from '@ant-design/icons';
import InvolvedDetails from './components/InvolvedDetails';
import moment from 'moment';
import ImageWithPopover from './components/ImageWithPopover';
import { DatePickerProps } from 'antd/lib/date-picker';
import locale from 'antd/es/date-picker/locale/zh_CN';
import { CheckboxProps } from 'antd/lib/checkbox';
/**
* @
@ -65,6 +68,9 @@ const InvolvedUploadList: React.FC = () => {
const [tab, setTab] = useState<string>(alarmRulesEnums[0].key);
const [tabs, setTabs] = useState<any>([]);
const [importDate, setImportDate] = useState<any>(null);
const [innerDate, setInnerDate] = useState<any>(null);
const [classify, setClassify] = useState<string>('all');
// const changeProjectTab = (key: string) => {
// setTab(key);
// console.log(key);
@ -151,7 +157,7 @@ const InvolvedUploadList: React.FC = () => {
display: 'flex',
alignItems: 'center',
padding: 20,
justifyContent: 'flex-start',
justifyContent: 'flex-start'
}}
onClick={() => {
console.log(index, 'index');
@ -224,12 +230,13 @@ const InvolvedUploadList: React.FC = () => {
}
// 初始化加载
async function initList(tabId:string = '1') {
async function initList(tabId:string = 'all',date: any = null) {
const reqParams = {
page: currentPage,
pageSize: currentPageSize,
// desc: false,
classify: tabId,
analyse_time: date
// ...rest,
};
const resp = await getUploadInvolvedList({ ...reqParams });
@ -265,6 +272,22 @@ const InvolvedUploadList: React.FC = () => {
// // };
// }}
}
const onChange: DatePickerProps['onChange'] = (date, dateString) => {
console.log(dateString);
setImportDate(date)
setInnerDate(dateString)
console.log(importDate,'importDate');
};
const onChangeCheckbox: CheckboxProps['onChange'] = (e) => {
console.log(`checked = ${e.target.checked}`);
if(e.target.checked) {
setClassify('1')
initList('1', innerDate)
}else {
setClassify('all')
initList('all', innerDate)
}
};
useEffect(() => {
getTabs();
initList();
@ -301,6 +324,30 @@ const InvolvedUploadList: React.FC = () => {
changeProjectTab(key);
}}
></Tabs> */}
<div style={{ padding: '16px 16px 0', display:'flex',justifyContent: 'space-between',alignItems:'center'}}>
<div>
<DatePicker locale={locale} value={importDate} onChange={onChange} allowClear />
<Button type="primary"
style={{ margin: '0 16px' }}
onClick={() => {
// setCreateModalOpen(true);
setImportDate(null);
initList(classify, null)
}}
>
</Button>
<Button type="primary"
onClick={() => {
// setCreateModalOpen(true);
initList(classify, innerDate)
}}
>
</Button>
</div>
<Checkbox onChange={onChangeCheckbox}></Checkbox>
</div>
<ProList<any>
className="gn"
ghost={true}

@ -1,6 +1,6 @@
import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory';
import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup';
import { postAlarmRules } from '@/services/alarm/AlarmRules';
import { postOfflineAlarmRules } from '@/services/alarm/AlarmRules';
import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form, message } from 'antd';
@ -49,7 +49,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
values.id = props.values.id
values.is_use = values.is_use ? 1 : 0
// console.log(values);
await postAlarmRules(values)
await postOfflineAlarmRules(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();

@ -1,6 +1,6 @@
import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory';
import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup';
import { postAlarmRules } from '@/services/alarm/AlarmRules';
import { postOfflineAlarmRules } from '@/services/alarm/AlarmRules';
import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form, message } from 'antd';
@ -49,7 +49,7 @@ const UpdateMultiForm: React.FC<UpdateFormProps> = (props) => {
values.id = props.values.id
values.is_use = values.is_use ? 1 : 0
// console.log(values);
await postAlarmRules(values)
await postOfflineAlarmRules(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();

@ -1,6 +1,6 @@
import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory';
import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup';
import { postAlarmRules } from '@/services/alarm/AlarmRules';
import { postOfflineAlarmRules } from '@/services/alarm/AlarmRules';
import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText, ProFormTimePicker } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form, message } from 'antd';
@ -49,7 +49,7 @@ const UpdateTimeForm: React.FC<UpdateFormProps> = (props) => {
values.id = props.values.id
values.is_use = values.is_use ? 1 : 0
// console.log(values);
await postAlarmRules(values)
await postOfflineAlarmRules(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();

@ -6,7 +6,7 @@ import {
deleteDeviceCategoryDeleteDeviceCategory,
postDeviceCategoryGetDeviceCategoryList,
} from '@/services/device/DeviceCategory';
import {getAlarmRules} from '@/services/alarm/AlarmRules'
import {getOfflineAlarmRules} from '@/services/alarm/AlarmRules'
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { PageContainer, ProTable } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
@ -238,7 +238,7 @@ const OfflineAlarmRulesList: React.FC = () => {
reqParams.desc = sort_select === 'descend';
}
// let resp = await postDeviceCategoryGetDeviceCategoryList({ ...reqParams });
let resp = await getAlarmRules(reqParams);
let resp = await getOfflineAlarmRules(reqParams);
console.log(resp);
return {
data: resp.data.results.map((v: API.DeviceCategory) => {

@ -0,0 +1,58 @@
import React, { useState } from 'react';
import { Button, Tag, message } from 'antd';
import { RedoOutlined } from '@ant-design/icons';
import { postTestDevice } from '@/services/alarm/Interfaces'
import moment from 'moment';
import { useIntl } from '@umijs/max';
interface ImageSinglePopoverProps {
values: any;
reload: any;
}
const CaptureButton: React.FC<ImageSinglePopoverProps> = (props) => {
const intl = useIntl();
const [loading, setLoading] = useState<boolean>(false);
const connection = () => {
setLoading(true);
postTestDevice({
device_ip: props.values.device_ip,
id: props.values.id,
})
.then((res) => {
if(res.success) {
message.success(res.msg);
}
props.reload();
setLoading(false);
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
setLoading(false);
});
};
return (
<div>
<Tag bordered={false} color={props.values.test_result === 1? "success": ""} style={{
// fontSize:14,
color: props.values.test_result === 1? '#52C41A': "#999"
}}>
{props.values.test_result === 1 ? '在线' : '离线'}
</Tag>
<span>{moment(props.values.test_time).format('YYYY-MM-DD hh:mm:ss')}</span>
<Button
type="link"
icon={<RedoOutlined />}
loading={loading}
onClick={() => {
connection()
}}
/>
</div>
);
};
export default CaptureButton;

@ -0,0 +1,80 @@
import { postInterfaces, postTestDevice } from '@/services/alarm/Interfaces';
import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Image, Form, message } from 'antd';
import React, { useState } from 'react';
import {
proFormSmallItemStyleProps,
proFormSmallModelWidth,
} from '../../../../../config/defaultForm';
import moment from 'moment';
import styles from './CaptureForm.less'
export type FormValueType = {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
} & Partial<API.UpdateInterfacesParams>;
export type UpdateFormProps = {
captureModalOpen: boolean;
handleModal: () => void;
values: Partial<API.UpdateInterfacesParams>;
reload: any;
};
const CaptureForm: React.FC<UpdateFormProps> = (props) => {
const intl = useIntl();
const [form] = Form.useForm<API.UpdateInterfacesParams>();
return (
<ModalForm<any>
width={proFormSmallModelWidth}
title={intl.formatMessage({
id: 'device.interface_manage.table.list.capture',
defaultMessage: `最近拍摄`,
})}
open={props.captureModalOpen}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => {
props.handleModal()
},
// okText: intl.formatMessage({ id: 'common.okText', defaultMessage: '确认' }),
// cancelText: intl.formatMessage({ id: 'common.cancelText', defaultMessage: '取消' }),
}}
submitTimeout={2000}
submitter={false}
onFinish={async (values) => {
console.log(values);
values.id = props.values.id
postInterfaces(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
});
props.handleModal();
return true;
}}
>
<div className={styles.captureImgBox}>
<div className={styles.captureImgDescribe}>: <span>{props.values.device_name}</span></div>
<div className={styles.captureImgDescribe}>: <span>{moment(props.values.appear_time).format('YYYY-MM-DD hh:mm:ss')}</span></div>
<div className={styles.captureImgContent}>
<Image
width={100}
preview={false}
src={props.values.picture_path}
/>
</div>
</div>
</ModalForm>
);
};
export default CaptureForm;

@ -0,0 +1,675 @@
/**
*
*
*/
import { postInterfaces, postTestDevice } from '@/services/alarm/Interfaces';
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
ProFormTextArea,
} from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Form, message } from 'antd';
import React, { useEffect, useState } from 'react';
import {
proFormSmallItemStyleProps,
proFormSmallModelWidth,
} from '../../../../../config/defaultForm';
export type FormValueType = {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
} & Partial<API.UpdateInterfacesParams>;
export type CreateFormProps = {
createModalOpen: boolean;
handleModal: () => void;
values: Partial<API.UpdateInterfacesParams>;
reload: any;
};
const CreateForm: React.FC<CreateFormProps> = (props) => {
const intl = useIntl();
const [form] = Form.useForm<API.UpdateInterfacesParams>();
const [loading, setLoading] = useState<boolean>(false);
const [fileType, setFileType] = useState<string>('1');
const [fileMethod, setFileMethod] = useState<string>('pull');
const [methodName, setMethodName] = useState<string>('0');
const connection = async () => {
setLoading(true);
console.log(form.getFieldsValue());
postTestDevice({
device_ip: form.getFieldsValue().device_ip,
})
.then((res) => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
// props.reload();
console.log(res);
if (res.success) {
message.success(res.msg);
}
setLoading(false);
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
});
// setTimeout(() => {
// setLoading(false);
// }, 6000);
};
const handleChangeFileType = (value: string) => {
setFileMethod(value);
};
const handleChangeFile = (value: string) => {
setMethodName(value);
};
useEffect(() => {
if (fileMethod === 'upload' && methodName === '2') {
setFileType(() => {
return '3';
});
} else if (fileMethod === 'pull' && methodName === '1') {
setFileType(() => {
return '2';
});
} else {
setFileType(() => {
return '1';
});
}
}, [methodName, fileMethod]);
return (
<ModalForm<API.UpdateInterfacesParams>
width={proFormSmallModelWidth}
title={intl.formatMessage({
id: 'device.interface_manage.table.list.addVideoSource',
defaultMessage: '新建视频源',
})}
open={props.createModalOpen}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => {
setLoading(false);
setFileMethod('pull');
setMethodName('0');
props.handleModal();
},
okText: intl.formatMessage({ id: 'common.okText', defaultMessage: '确认' }),
cancelText: intl.formatMessage({ id: 'common.cancelText', defaultMessage: '取消' }),
}}
submitTimeout={2000}
onFinish={async (values) => {
console.log(values);
postInterfaces(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
});
props.handleModal();
return true;
}}
>
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_name"
label={
<FormattedMessage
id="device.interface_manage.table.list.name"
defaultMessage="接口名称"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.name',
defaultMessage: '接口名称',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.name"
defaultMessage="接口名称为必填项"
/>
),
},
]}
/>
<div style={{ width: proFormSmallItemStyleProps.width }}>
<div style={{ marginBottom: 8 }}></div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<ProFormSelect
width={250}
options={[
{
value: 'pull',
label: '文件拉取',
},
{
value: 'upload',
label: '文件上传',
},
]}
onChange={handleChangeFileType}
initialValue={fileMethod}
name="fileType"
// label="获取方式"
/>
<ProFormSelect
width={250}
options={[
{
value: '0',
label: 'FTP',
},
{
value: '1',
label: '文件系统',
},
{
value: '2',
label: 'FTP上传',
},
]}
initialValue={methodName}
onChange={handleChangeFile}
name="file"
// label="获取方式"
/>
</div>
</div>
{/* <ProFormText
width={proFormSmallItemStyleProps.width - 96}
name="device_ip"
label={
<FormattedMessage id="device.interface_manage.table.list.ip" defaultMessage="IP地址" />
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.ip',
defaultMessage: 'IP地址',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.ip"
defaultMessage="IP地址为必填项"
/>
),
},
]}
addonAfter={
<Button
style={{ width:86,height:32,border:'1px solid #081FA8',borderRadius:4,fontSize: 14,color:'#081FA8' }}
loading={loading}
onClick={() => connection()}>
{ loading ? '' : '连接测试'}
</Button>
}
/> */}
{fileType === '1' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.ip"
defaultMessage="IP地址"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.ip',
defaultMessage: '接口地址',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.ip"
defaultMessage="接口地址为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
defaultMessage="端口"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.port',
defaultMessage: '端口',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.port"
defaultMessage="端口为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
defaultMessage="登录名"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.loginName',
defaultMessage: '登录名',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.loginName"
defaultMessage="登录名为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
defaultMessage="密码"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.password',
defaultMessage: '密码',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.password"
defaultMessage="密码为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"
defaultMessage="文件目录"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.fileDirectory',
defaultMessage: '文件目录',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.fileDirectory"
defaultMessage="文件目录为必填项"
/>
),
},
]}
/>
</ProForm.Group>
)}
{fileType === '2' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestAddress"
defaultMessage="请求地址"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.requestAddress',
defaultMessage: '请求地址',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.requestAddress"
defaultMessage="请求地址为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestKey"
defaultMessage="请求Key"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.requestKey',
defaultMessage: '请求Key',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.requestKey"
defaultMessage="请求Key为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.secretKey"
defaultMessage="秘钥"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.secretKey',
defaultMessage: '秘钥',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.secretKey"
defaultMessage="秘钥为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.bucket"
defaultMessage="Bucket"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.bucket',
defaultMessage: 'Bucket',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.bucket"
defaultMessage="Bucket为必填项"
/>
),
},
]}
/>
</ProForm.Group>
)}
{fileType === '3' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.Code"
defaultMessage="Code"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.Code',
defaultMessage: 'Code',
})}`}
disabled
required={true}
initialValue={'123'}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.Code"
defaultMessage="Code为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
defaultMessage="端口"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.port',
defaultMessage: '端口',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.port"
defaultMessage="端口为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
defaultMessage="登录名"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.loginName',
defaultMessage: '登录名',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.loginName"
defaultMessage="登录名为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
defaultMessage="密码"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.password',
defaultMessage: '密码',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.password"
defaultMessage="密码为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"
defaultMessage="文件目录"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.fileDirectory',
defaultMessage: '文件目录',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.fileDirectory"
defaultMessage="文件目录为必填项"
/>
),
},
]}
/>
</ProForm.Group>
)}
<ProFormTextArea
width={proFormSmallItemStyleProps.width}
name="note"
label={
<FormattedMessage
id="device.interface_manage.table.list.remark"
defaultMessage="备注"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.remark',
defaultMessage: '备注',
})}`}
required={false}
/>
</ProForm.Group>
</ModalForm>
);
};
export default CreateForm;

@ -0,0 +1,674 @@
/*
* @Author: zhoux zhouxia@supervision.ltd
* @Date: 2023-11-01 13:56:33
* @LastEditors: zhoux zhouxia@supervision.ltd
* @LastEditTime: 2023-12-26 15:01:08
* @FilePath: \general-ai-platform-web\src\pages\Device\DeviceCategoryList\components\UpdateForm.tsx
* @Description: ,`customMade`, koroFileHeader : https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory';
import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup';
import { postInterfaces, postTestDevice } from '@/services/alarm/Interfaces';
import { ModalForm, ProForm, ProFormFieldSet, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Button, Form, message } from 'antd';
import React, { useEffect, useState } from 'react';
import {
proFormSmallItemStyleProps,
proFormSmallModelWidth,
} from '../../../../../config/defaultForm';
export type FormValueType = {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
} & Partial<API.UpdateInterfacesParams>;
export type UpdateFormProps = {
updateModalOpen: boolean;
handleModal: () => void;
values: Partial<API.UpdateInterfacesParams>;
reload: any;
};
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const intl = useIntl();
const [form] = Form.useForm<API.UpdateInterfacesParams>();
const [loading, setLoading] = useState<boolean>(false);
const [fileType, setFileType] = useState<string>('1');
const [fileMethod, setFileMethod] = useState<string>('pull');
const [methodName, setMethodName] = useState<string>('0');
const connection = () => {
setLoading(true);
console.log(props.values);
postTestDevice({
device_ip: form.getFieldsValue().device_ip,
id: props.values.id,
})
.then((res) => {
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
// props.reload();
console.log(res);
if(res.success) {
message.success(res.msg);
}
setLoading(false);
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
setLoading(false);
});
};
const handleChangeFileType = (value: string) => {
setFileMethod(value);
};
const handleChangeFile = (value: string) => {
setMethodName(value);
};
useEffect(() => {
if (fileMethod === 'upload' && methodName === '2') {
setFileType(() => {
return '3';
});
} else if (fileMethod === 'pull' && methodName === '1') {
setFileType(() => {
return '2';
});
} else {
setFileType(() => {
return '1';
});
}
}, [methodName, fileMethod]);
return (
<ModalForm<any>
width={proFormSmallModelWidth}
title={intl.formatMessage({
id: 'device.interface_manage.table.list.updatVideoSource',
defaultMessage: `编辑${props.values.device_name}`,
})}
open={props.updateModalOpen}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => {
setLoading(false)
props.handleModal()
},
okText: intl.formatMessage({ id: 'common.okText', defaultMessage: '确认' }),
cancelText: intl.formatMessage({ id: 'common.cancelText', defaultMessage: '取消' }),
}}
submitTimeout={2000}
onFinish={async (values) => {
console.log(values);
values.id = props.values.id
postInterfaces(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
});
props.handleModal();
return true;
}}
>
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_name"
label={
<FormattedMessage
id="device.interface_manage.table.list.name"
defaultMessage="接口名称"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.name',
defaultMessage: '接口名称',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.name"
defaultMessage="接口名称为必填项"
/>
),
},
]}
/>
<div style={{ width: proFormSmallItemStyleProps.width }}>
<div style={{ marginBottom: 8 }}></div>
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<ProFormSelect
width={250}
options={[
{
value: 'pull',
label: '文件拉取',
},
{
value: 'upload',
label: '文件上传',
},
]}
onChange={handleChangeFileType}
initialValue={fileMethod}
name="fileType"
// label="获取方式"
/>
<ProFormSelect
width={250}
options={[
{
value: '0',
label: 'FTP',
},
{
value: '1',
label: '文件系统',
},
{
value: '2',
label: 'FTP上传',
},
]}
initialValue={methodName}
onChange={handleChangeFile}
name="file"
// label="获取方式"
/>
</div>
</div>
{/* <ProFormText
width={proFormSmallItemStyleProps.width - 96}
name="device_ip"
label={
<FormattedMessage id="device.interface_manage.table.list.ip" defaultMessage="IP地址" />
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.ip',
defaultMessage: 'IP地址',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.ip"
defaultMessage="IP地址为必填项"
/>
),
},
]}
addonAfter={
<Button
style={{ width:86,height:32,border:'1px solid #081FA8',borderRadius:4,fontSize: 14,color:'#081FA8' }}
loading={loading}
onClick={() => connection()}>
{ loading ? '' : '连接测试'}
</Button>
}
/> */}
{fileType === '1' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.ip"
defaultMessage="IP地址"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.ip',
defaultMessage: '接口地址',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.ip"
defaultMessage="接口地址为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
defaultMessage="端口"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.port',
defaultMessage: '端口',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.port"
defaultMessage="端口为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
defaultMessage="登录名"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.loginName',
defaultMessage: '登录名',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.loginName"
defaultMessage="登录名为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
defaultMessage="密码"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.password',
defaultMessage: '密码',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.password"
defaultMessage="密码为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"
defaultMessage="文件目录"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.fileDirectory',
defaultMessage: '文件目录',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.fileDirectory"
defaultMessage="文件目录为必填项"
/>
),
},
]}
/>
</ProForm.Group>
)}
{fileType === '2' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestAddress"
defaultMessage="请求地址"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.requestAddress',
defaultMessage: '请求地址',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.requestAddress"
defaultMessage="请求地址为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestKey"
defaultMessage="请求Key"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.requestKey',
defaultMessage: '请求Key',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.requestKey"
defaultMessage="请求Key为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.secretKey"
defaultMessage="秘钥"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.secretKey',
defaultMessage: '秘钥',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.secretKey"
defaultMessage="秘钥为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.bucket"
defaultMessage="Bucket"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.bucket',
defaultMessage: 'Bucket',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.bucket"
defaultMessage="Bucket为必填项"
/>
),
},
]}
/>
</ProForm.Group>
)}
{fileType === '3' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.Code"
defaultMessage="Code"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.Code',
defaultMessage: 'Code',
})}`}
disabled
required={true}
initialValue={'123'}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.Code"
defaultMessage="Code为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
defaultMessage="端口"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.port',
defaultMessage: '端口',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.port"
defaultMessage="端口为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
defaultMessage="登录名"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.loginName',
defaultMessage: '登录名',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.loginName"
defaultMessage="登录名为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
defaultMessage="密码"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.password',
defaultMessage: '密码',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.password"
defaultMessage="密码为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"
defaultMessage="文件目录"
/>
}
disabled
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.fileDirectory',
defaultMessage: '文件目录',
})}`}
required={true}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.fileDirectory"
defaultMessage="文件目录为必填项"
/>
),
},
]}
/>
</ProForm.Group>
)}
<ProFormTextArea
width={proFormSmallItemStyleProps.width}
name="note"
label={
<FormattedMessage
id="device.interface_manage.table.list.remark"
defaultMessage="备注"
/>
}
placeholder={`${intl.formatMessage({
id: 'common.please_input',
defaultMessage: '请输入',
})}${intl.formatMessage({
id: 'device.interface_manage.table.list.remark',
defaultMessage: '备注',
})}`}
required={false}
/>
</ProForm.Group>
</ModalForm>
);
};
export default UpdateForm;

@ -0,0 +1,327 @@
import AlarmLevelBox from '@/components/DictionaryBox/alarmLevel';
import TableActionCard from '@/components/TableActionCard';
import IsDelete from '@/components/TableActionCard/isDelete';
import { alarmLevelStatusEnum } from '@/enums/status';
import {
deleteDeviceCategoryDeleteDeviceCategory,
postDeviceCategoryGetDeviceCategoryList,
} from '@/services/device/DeviceCategory';
import { getInterfaces, postInterfaces, postTestDevice } from '@/services/alarm/Interfaces'
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { PageContainer, ProTable } from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { Button, Space, Tag, message } from 'antd';
import React, { useRef, useState } from 'react';
import { proTablePaginationOptions } from '../../../../config/defaultTable';
import { proIconForTableActionStyle } from '../../../../config/defaultIcon';
import { EditOutlined, InstagramOutlined, RedoOutlined } from '@ant-design/icons';
import CreateForm from './components/CreateForm';
import UpdateForm from './components/UpdateForm';
import CaptureForm from './components/CaptureForm';
import CaptureButton from './components/CaptureButton';
import moment from 'moment';
const RealTimeInterfaceManageList: React.FC = () => {
/**
* @en-US International configuration
* @zh-CN
* */
const intl = useIntl();
const actionRef = useRef<ActionType>();
// 动态设置每页数量
const [currentPageSize, setCurrentPageSize] = useState<number>(10);
const handleDestroy = async (selectedRow: API.UpdateInterfacesParams) => {
postInterfaces({ id: selectedRow.id, device_status: '3' } )
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
actionRef.current?.reload();
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
});
};
const [currentRow, setCurrentRow] = useState<API.UpdateInterfacesParams>();
/**
* @en-US Pop-up window of new window
* @zh-CN
* */
const [createModalOpen, setCreateModalOpen] = useState<boolean>(false);
const handleCreateModal = () => {
if (createModalOpen) {
setCreateModalOpen(false);
setCurrentRow(undefined);
} else {
setCreateModalOpen(true);
}
};
// 编辑弹框
const [updateModalOpen, setUpdateModalOpen] = useState<boolean>(false);
const handleUpdateModal = () => {
if (updateModalOpen) {
setUpdateModalOpen(false);
setCurrentRow(undefined);
} else {
setUpdateModalOpen(true);
}
};
// 最近拍摄
const [captureModalOpen, setCaptureModalOpen] = useState<boolean>(false);
const handleCaptureModal = () => {
console.log(captureModalOpen);
if (captureModalOpen) {
setCaptureModalOpen(false);
setCurrentRow(undefined);
} else {
setCaptureModalOpen(true);
}
};
// 测试连接
const [loading, setLoading] = useState<boolean>(false);
const connection = (value: any) => {
setLoading(true);
postTestDevice({
device_ip: value.device_ip,
id: value.id,
})
.then((res) => {
if(res.success) {
message.success(res.msg);
}
setLoading(false);
})
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
setLoading(false);
});
};
const columns: ProColumns<API.UpdateInterfacesParams>[] = [
{
title: <FormattedMessage id="device.interface_manage.table.list.videoName" defaultMessage="接口名称" />,
dataIndex: 'device_name',
hideInSearch: true,
},
{
title: <FormattedMessage id="device.interface_manage.table.list.obtainMode" defaultMessage="获取方式" />,
dataIndex: 'device_ip',
hideInSearch: true,
},
{
title: <FormattedMessage id="device.interface_manage.table.list.obtainStatus" defaultMessage="设备状态" />,
dataIndex: 'test_result',
hideInSearch: true,
render: (dom,entity) => {
return (
<div>
<Tag bordered={false} color={dom === 1? "success": ""} style={{
// fontSize:14,
color: dom === 1? '#52C41A': "#999"
}}>
{dom === 1 ? '获取成功' : '获取失败'}
</Tag>
<span>{moment(entity.appear_time).format('YYYY-MM-DD hh:mm:ss')}</span>
{/* <Button
type="link"
icon={<RedoOutlined />}
loading={loading}
onClick={() => {
connection(entity)
}}
/> */}
</div>
// <CaptureButton
// values={entity || {}}
// reload={actionRef.current?.reload}
// />
);
},
},
// {
// title: <FormattedMessage id="device.interface_manage.table.list.address" defaultMessage="接口地址" />,
// dataIndex: 'device_api',
// hideInSearch: true,
// },
// {
// title: <FormattedMessage id="device.interface_manage.table.list.testTime" defaultMessage="状态查询时间" />,
// dataIndex: 'test_time',
// sorter: true,
// hideInSearch: true,
// valueType: 'dateTime',
// },
{
title: <FormattedMessage id="device.interface_manage.table.list.createTime" defaultMessage="创建时间" />,
dataIndex: 'create_time',
sorter: true,
hideInSearch: true,
valueType: 'dateTime',
},
{
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
dataIndex: 'option',
valueType: 'option',
width: '260px',
fixed: 'right',
render: (_, record) => [
<TableActionCard
key="TableActionCardRef"
renderActions={[
// {
// key: 'capture',
// renderDom: (
// <Button
// key="capture"
// type="link"
// size="small"
// style={{
// color:"#081FA8",
// }}
// icon={<InstagramOutlined style={{
// marginRight: 3
// }} />}
// onClick={() => {
// console.log('11');
// setCaptureModalOpen(true);
// setCurrentRow(record);
// }}
// >
// {/* 最近拍摄 */}
// <FormattedMessage id="device.interface_manage.table.list.capture" defaultMessage="最近拍摄" />
// </Button>
// ),
// },
{
key: 'update',
renderDom: (
<Button
key="update"
type="link"
size="small"
style={{
color:"#081FA8",
}}
icon={<EditOutlined style={{
marginRight: 3
}} />}
onClick={() => {
setUpdateModalOpen(true);
setCurrentRow(record);
}}
>
<FormattedMessage id="common.edit" defaultMessage="编辑" />
</Button>
),
},
{
key: 'destroy',
renderDom: (
<IsDelete
deleteApi={() => {
handleDestroy(record).then(() => {});
}}
></IsDelete>
),
},
]}
></TableActionCard>,
],
},
];
return (
<PageContainer
title={false}
content={
<div style={{
display: 'flex',
justifyContent: 'space-between'
}}>
<div style={{
fontWeight: 600,
fontSize: 20,
color: '#333'
}}>线</div>
<Button type="primary"
onClick={() => {
setCreateModalOpen(true);
}}
>
<FormattedMessage id="device.interface_manage.table.list.addVideoSource" defaultMessage="新建视频源" />
</Button>
</div>
}
>
<ProTable<API.DeviceCategory>
cardProps={{
bodyStyle: {
padding: 20
}
}}
options={{ fullScreen: false, setting: false, density: false, reload: false }}
actionRef={actionRef}
rowKey="key"
search={false}
showSorterTooltip={false}
pagination={{
...proTablePaginationOptions,
pageSize: currentPageSize,
onChange: (page, pageSize) => setCurrentPageSize(pageSize),
}}
columnsState={{
persistenceKey: 'device_category_list',
persistenceType: 'localStorage',
}}
request={async (params = {}, sort) => {
const { current, ...rest } = params;
const reqParams = {
page: current,
desc: false,
orderKey: '',
...rest,
};
if (sort && Object.keys(sort).length) {
reqParams.orderKey = Object.keys(sort)[0];
let sort_select = sort[reqParams.orderKey];
reqParams.desc = sort_select === 'descend';
}
// let resp = await postDeviceCategoryGetDeviceCategoryList({ ...reqParams });
let resp = await getInterfaces({ ...reqParams });
return {
data: resp.data.results.map((v: API.DeviceCategory) => {
return { ...v, key: v.id };
}),
success: resp.success,
total: resp.data.count,
current: resp.data.page,
pageSize: resp.data.pageSize,
};
}}
columns={columns}
/>
<CreateForm
createModalOpen={createModalOpen}
values={currentRow || {}}
handleModal={handleCreateModal}
reload={actionRef.current?.reload}
/>
<UpdateForm
updateModalOpen={updateModalOpen}
values={currentRow || {}}
handleModal={handleUpdateModal}
reload={actionRef.current?.reload}
/>
<CaptureForm
captureModalOpen={captureModalOpen}
values={currentRow || {}}
handleModal={handleCaptureModal}
reload={actionRef.current?.reload}
/>
</PageContainer>
);
};
export default RealTimeInterfaceManageList;

@ -19,7 +19,6 @@ import CreateForm from './components/CreateForm';
import UpdateForm from './components/UpdateForm';
import CaptureForm from './components/CaptureForm';
import CaptureButton from './components/CaptureButton';
import moment from 'moment';
const InterfaceManageList: React.FC = () => {
/**
* @en-US International configuration
@ -239,7 +238,7 @@ const InterfaceManageList: React.FC = () => {
fontWeight: 600,
fontSize: 20,
color: '#333'
}}></div>
}}></div>
<Button type="primary"
onClick={() => {
setCreateModalOpen(true);

@ -183,6 +183,16 @@ const Login: React.FC = () => {
"path": "/realTime/involved-list",
"routes": [],
"title": "告警汇总",
},
{
"access": "",
"component": "Setting/interfaceManage",
"icon": "",
"key": "",
"name": "interfaceManage",
"path": "/realTime/interfaceManage",
"routes": [],
"title": "接口管理",
}
]
},
@ -254,19 +264,29 @@ const Login: React.FC = () => {
"path": "/offline/involved-list-upload",
"routes": [],
"title": "告警汇总",
},
{
"access": "",
"component": "Setting/RealTimeInterfaceManage",
"icon": "",
"key": "",
"name": "RealTimeInterfaceManage",
"path": "/offline/RealTimeInterfaceManage",
"routes": [],
"title": "设备管理",
}
]
},
{
"path": "interfaceManage",
"key": "",
"name": "interfaceManage",
"icon": "BranchesOutlined",
"access": "",
"component": "Hidden",
"title": "接口管理",
"routes": []
},
// {
// "path": "interfaceManage",
// "key": "",
// "name": "interfaceManage",
// "icon": "BranchesOutlined",
// "access": "",
// "component": "Hidden",
// "title": "接口管理",
// "routes": []
// },
// {
// "path": "userList",
// "key": "",

@ -69,14 +69,15 @@
.alarmImgContent {
box-sizing: border-box;
margin-bottom: 24px;
padding: 16px;
padding: 16px 0 16px 16px;
width: 784px;
// height: 172px;
background: #F7F7F7;
border-radius: 4px;
border: 1px dashed #DCDCDC;
display: flex;
justify-content: center;
justify-content: flex-start;
flex-wrap: wrap;
}
}
.myButtonDisabled{

@ -61,7 +61,7 @@ const ImageSinglePopover: React.FC<ImageSinglePopoverProps> = ({ src, involved,
// };
return (
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 160, marginRight: 12 }}>
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 170, marginRight: 12 }}>
<Image
style={{ borderRadius: 4 }}
width={140}

@ -59,7 +59,7 @@ const ImageWithPopover: React.FC<ImageWithPopoverProps> = ({ src, involved, inde
};
return (
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 160, marginRight: 12 }}>
<div style={{ position: 'relative', boxSizing: 'border-box', width: 140, height: 170, marginRight: 12 }}>
<Image
style={{ borderRadius: 4 }}
width={140}
@ -83,7 +83,7 @@ const ImageWithPopover: React.FC<ImageWithPopoverProps> = ({ src, involved, inde
onOpenChange={handleOpenChange}
>
<Button
style={{ position: 'absolute', bottom: 20, right: 0 }}
style={{ position: 'absolute', bottom: 30, right: 0 }}
type="text"
icon={<EllipsisOutlined style={{ color: '#fff', fontSize: 24, transform: 'rotate(90deg)' }} />}
/>

@ -2,7 +2,7 @@
/* eslint-disable */
import { request } from '@umijs/max';
/** 告警列表 */
/** 告警规则 */
export async function getAlarmRules(
params: API.SearchAlarmRulesParams,
options?: { [key: string]: any },
@ -22,7 +22,7 @@ export async function getAlarmRules(
);
}
/** 更新告警列表 */
/** 更新告警规则 */
export async function postAlarmRules(
body: API.UpdateAlarmRulesParams,
options?: { [key: string]: any },
@ -39,3 +39,41 @@ export async function postAlarmRules(
},
);
}
/** 离线告警规则 */
export async function getOfflineAlarmRules(
params: API.SearchAlarmRulesParams,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(
`/api/upload_warning_rule/`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
params: {
...params,
},
...(options || {}),
},
);
}
/** 离线更新告警规则 */
export async function postOfflineAlarmRules(
body: API.UpdateAlarmRulesParams,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(
`/api/upload_warning_rule/`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
},
);
}

Loading…
Cancel
Save