fect: 离线设备接口联调

develop
JINGYJ 1 year ago
parent 61aceb63c5
commit 2a4525b4f7

@ -259,7 +259,7 @@ const AlarmList: React.FC = () => {
}
useEffect(() => {
getTabs();
initList();
// initList();
}, []);
useEffect(() => {
// 模拟异步请求数据

@ -2,7 +2,7 @@
*
*
*/
import { postInterfaces, postTestDevice } from '@/services/alarm/Interfaces';
import { postInterfacesUpload,getInterfacesUpload } from '@/services/alarm/Interfaces';
import {
ModalForm,
ProForm,
@ -36,43 +36,49 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
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) => {
const [fileMethod, setFileMethod] = useState<number>(2);
const [methodName, setMethodName] = useState<string>('1');
const handleChangeFileType = async (value: number) => {
setFileMethod(value);
// 根据选择的获取方式更新第二个下拉框的值
if (value === 2) {
setMethodName('1'); // 设置为初始值 '0'只展示FTP选项
form.setFieldsValue({
operate_mode: '1', // 设置第二个下拉框的值
device_ip: '',
device_port: '',
device_username: '',
device_password: '',
source_directory: '',
});
} else if (value === 1) {
setMethodName('2'); // 设置为 '2'只展示FTP上传选项
form.setFieldsValue({
operate_mode: '2', // 设置第二个下拉框的值
});
await getInterfacesUpload({ 'templet': true })
.then( (resp)=> {
const{ data } = resp
form.setFieldsValue({
device_ip: data.device_ip,
device_port: data.device_port,
device_username: data.device_username,
device_password: data.device_password,
destination_directory: data.destination_directory,
});
})
}
};
const handleChangeFile = (value: string) => {
setMethodName(value);
};
useEffect(() => {
if (fileMethod === 'upload' && methodName === '2') {
if (fileMethod === 1 && methodName === '2') {
setFileType(() => {
return '3';
});
} else if (fileMethod === 'pull' && methodName === '1') {
} else if (fileMethod === 2 && methodName === '3') {
setFileType(() => {
return '2';
});
@ -97,8 +103,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
destroyOnClose: true,
onCancel: () => {
setLoading(false);
setFileMethod('pull');
setMethodName('0');
setFileMethod(2);
setMethodName('1');
props.handleModal();
},
okText: intl.formatMessage({ id: 'common.okText', defaultMessage: '确认' }),
@ -107,7 +113,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
submitTimeout={2000}
onFinish={async (values) => {
console.log(values);
postInterfaces(values)
postInterfacesUpload(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();
@ -115,6 +121,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
.catch(() => {
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
});
setFileMethod(2);
setMethodName('1');
props.handleModal();
return true;
}}
@ -156,38 +164,55 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
width={250}
options={[
{
value: 'pull',
value: 2,
label: '文件拉取',
},
{
value: 'upload',
value: 1,
label: '文件上传',
},
]}
onChange={handleChangeFileType}
initialValue={fileMethod}
name="fileType"
name="upload_or_download"
// label="获取方式"
/>
{/* <ProFormSelect
width={250}
options={
fileMethod === '2'
? [
{
value: '0',
label: 'FTP',
},
{
value: '1',
label: '文件系统',
},
]
: [
{
value: '2',
label: 'FTP上传',
},
]
}
initialValue={methodName}
onChange={handleChangeFile}
name="file"
// label="获取方式"
/> */}
<ProFormSelect
width={250}
options={[
{
value: '0',
label: 'FTP',
},
{
value: '1',
label: '文件系统',
},
{
value: '2',
label: 'FTP上传',
},
]}
{ value: '1', label: 'FTP' },
{ value: '3', label: '文件系统' },
{ value: '2', label: 'FTP上传' },
].filter(option => (fileMethod === 2 ? option.value !== '2' : option.value === '2'))}
initialValue={methodName}
onChange={handleChangeFile}
name="file"
name="operate_mode"
// label="获取方式"
/>
</div>
@ -229,8 +254,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
{fileType === '1' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_ip"
label={
<FormattedMessage
id="device.interface_manage.table.list.ip"
@ -258,8 +283,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_port"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
@ -287,8 +312,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_username"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
@ -316,8 +341,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_password"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
@ -346,7 +371,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="source_directory"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"
@ -379,7 +404,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="device_ip"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestAddress"
@ -408,7 +433,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="access_key_id"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestKey"
@ -437,7 +462,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="access_key_secret"
label={
<FormattedMessage
id="device.interface_manage.table.list.secretKey"
@ -466,7 +491,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="bucket"
label={
<FormattedMessage
id="device.interface_manage.table.list.bucket"
@ -498,39 +523,38 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
{fileType === '3' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_ip"
label={
<FormattedMessage
id="device.interface_manage.table.list.Code"
defaultMessage="Code"
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.Code',
defaultMessage: 'Code',
id: 'device.interface_manage.table.list.ip',
defaultMessage: 'ip',
})}`}
disabled
required={true}
initialValue={'123'}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.Code"
defaultMessage="Code为必填项"
id="device.interface_manage.table.rule.required.ip"
defaultMessage="ip为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_port"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
@ -559,8 +583,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_username"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
@ -589,8 +613,8 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_password"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
@ -620,7 +644,7 @@ const CreateForm: React.FC<CreateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="destination_directory"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"

@ -8,7 +8,7 @@
*/
import { putDeviceCategoryUpdateDeviceCategory } from '@/services/device/DeviceCategory';
import { postDeviceGroupGetDeviceGroupFkSelect } from '@/services/device/DeviceGroup';
import { postInterfaces, postTestDevice } from '@/services/alarm/Interfaces';
import { postInterfacesUpload, getInterfacesUpload } 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';
@ -36,43 +36,50 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
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 [fileMethod, setFileMethod] = useState<number>(props.values.upload_or_download);
const [methodName, setMethodName] = useState<number>(props.values.operate_mode);
const handleChangeFileType = (value: string) => {
const handleChangeFileType = async (value: number) => {
setFileMethod(value);
// 根据选择的获取方式更新第二个下拉框的值
if (value === 2) {
setMethodName(1); // 设置为初始值 '0'只展示FTP选项
form.setFieldsValue({
operate_mode: 1, // 设置第二个下拉框的值
device_ip: props.values.device_ip,
device_port: props.values.device_port,
device_username: props.values.device_username,
device_password: props.values.device_password,
source_directory: props.values.source_directory,
});
} else if (value === 1) {
setMethodName(2); // 设置为 '2'只展示FTP上传选项
form.setFieldsValue({
operate_mode: 2, // 设置第二个下拉框的值
});
await getInterfacesUpload({ 'templet': true })
.then( (resp)=> {
const{ data } = resp
form.setFieldsValue({
device_ip: data.device_ip,
device_port: data.device_port,
device_username: data.device_username,
device_password: data.device_password,
destination_directory: data.destination_directory,
});
})
}
};
const handleChangeFile = (value: string) => {
const handleChangeFile = (value: number) => {
setMethodName(value);
};
useEffect(() => {
if (fileMethod === 'upload' && methodName === '2') {
if (fileMethod === 1 && methodName === 2) {
setFileType(() => {
return '3';
});
} else if (fileMethod === 'pull' && methodName === '1') {
} else if (fileMethod === 2 && methodName === 3) {
setFileType(() => {
return '2';
});
@ -82,6 +89,23 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
});
}
}, [methodName, fileMethod]);
useEffect(() => {
setFileMethod(props.values.upload_or_download);
setMethodName(props.values.operate_mode);
if (fileMethod === 1 && methodName === 2) {
setFileType(() => {
return '3';
});
} else if (fileMethod === 2 && methodName === 3) {
setFileType(() => {
return '2';
});
} else {
setFileType(() => {
return '1';
});
}
}, [props.updateModalOpen]);
return (
<ModalForm<any>
width={proFormSmallModelWidth}
@ -105,7 +129,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
onFinish={async (values) => {
console.log(values);
values.id = props.values.id
postInterfaces(values)
postInterfacesUpload(values)
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
props.reload();
@ -135,6 +159,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.name',
defaultMessage: '接口名称',
})}`}
initialValue={props.values.device_name}
required={true}
rules={[
{
@ -155,81 +180,64 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
width={250}
options={[
{
value: 'pull',
value: 2,
label: '文件拉取',
},
{
value: 'upload',
value: 1,
label: '文件上传',
},
]}
onChange={handleChangeFileType}
initialValue={fileMethod}
name="fileType"
initialValue={props.values.upload_or_download}
name="upload_or_download"
// label="获取方式"
/>
{/* <ProFormSelect
width={250}
options={
fileMethod === 2
? [
{
value: 0,
label: 'FTP',
},
{
value: 1,
label: '文件系统',
},
]
: [
{
value: 2,
label: 'FTP上传',
},
]
}
initialValue={props.values.operate_mode}
onChange={handleChangeFile}
name="file"
// label="获取方式"
/> */}
<ProFormSelect
width={250}
options={[
{
value: '0',
label: 'FTP',
},
{
value: '1',
label: '文件系统',
},
{
value: '2',
label: 'FTP上传',
},
]}
initialValue={methodName}
{ value: 1, label: 'FTP' },
{ value: 2, label: 'FTP上传' },
{ value: 3, label: '文件系统' },
].filter(option => (fileMethod === 2 ? option.value !== 2 : option.value === 2))}
initialValue={props.values.operate_mode}
onChange={handleChangeFile}
name="file"
name="operate_mode"
// 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"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_ip"
label={
<FormattedMessage
id="device.interface_manage.table.list.ip"
@ -244,6 +252,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
defaultMessage: '接口地址',
})}`}
required={true}
initialValue={props.values.device_ip}
rules={[
{
required: true,
@ -257,8 +266,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_port"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
@ -272,6 +281,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.port',
defaultMessage: '端口',
})}`}
initialValue={props.values.device_port}
required={true}
rules={[
{
@ -286,8 +296,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_username"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
@ -301,6 +311,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.loginName',
defaultMessage: '登录名',
})}`}
initialValue={props.values.device_username}
required={true}
rules={[
{
@ -315,8 +326,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_password"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
@ -330,6 +341,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.password',
defaultMessage: '密码',
})}`}
initialValue={props.values.device_password}
required={true}
rules={[
{
@ -345,7 +357,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="source_directory"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"
@ -359,6 +371,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.fileDirectory',
defaultMessage: '文件目录',
})}`}
initialValue={props.values.source_directory}
required={true}
rules={[
{
@ -378,7 +391,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="device_ip"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestAddress"
@ -392,6 +405,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.requestAddress',
defaultMessage: '请求地址',
})}`}
initialValue={props.values.device_ip}
required={true}
rules={[
{
@ -407,7 +421,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="access_key_id"
label={
<FormattedMessage
id="device.interface_manage.table.list.requestKey"
@ -421,6 +435,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.requestKey',
defaultMessage: '请求Key',
})}`}
initialValue={props.values.access_key_id}
required={true}
rules={[
{
@ -436,7 +451,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="access_key_secret"
label={
<FormattedMessage
id="device.interface_manage.table.list.secretKey"
@ -450,6 +465,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.secretKey',
defaultMessage: '秘钥',
})}`}
initialValue={props.values.access_key_secret}
required={true}
rules={[
{
@ -465,7 +481,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="bucket"
label={
<FormattedMessage
id="device.interface_manage.table.list.bucket"
@ -479,6 +495,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.bucket',
defaultMessage: 'Bucket',
})}`}
initialValue={props.values.bucket}
required={true}
rules={[
{
@ -497,39 +514,39 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
{fileType === '3' && (
<ProForm.Group>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_ip"
label={
<FormattedMessage
id="device.interface_manage.table.list.Code"
defaultMessage="Code"
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.Code',
defaultMessage: 'Code',
id: 'device.interface_manage.table.list.ip',
defaultMessage: 'ip',
})}`}
disabled
initialValue={props.values.device_ip}
required={true}
initialValue={'123'}
rules={[
{
required: true,
message: (
<FormattedMessage
id="device.interface_manage.table.rule.required.Code"
defaultMessage="Code为必填项"
id="device.interface_manage.table.rule.required.ip"
defaultMessage="ip为必填项"
/>
),
},
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_port"
label={
<FormattedMessage
id="device.interface_manage.table.list.port"
@ -544,6 +561,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.port',
defaultMessage: '端口',
})}`}
initialValue={props.values.device_port}
required={true}
rules={[
{
@ -558,8 +576,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_username"
label={
<FormattedMessage
id="device.interface_manage.table.list.loginName"
@ -574,6 +592,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.loginName',
defaultMessage: '登录名',
})}`}
initialValue={props.values.device_username}
required={true}
rules={[
{
@ -588,8 +607,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]}
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
width={proFormSmallItemStyleProps.width / 2 - 8}
name="device_password"
label={
<FormattedMessage
id="device.interface_manage.table.list.password"
@ -604,6 +623,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.password',
defaultMessage: '密码',
})}`}
initialValue={props.values.device_password}
required={true}
rules={[
{
@ -619,7 +639,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
/>
<ProFormText
width={proFormSmallItemStyleProps.width}
name="device_api"
name="destination_directory"
label={
<FormattedMessage
id="device.interface_manage.table.list.fileDirectory"
@ -634,6 +654,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.fileDirectory',
defaultMessage: '文件目录',
})}`}
initialValue={props.values.destination_directory}
required={true}
rules={[
{
@ -665,6 +686,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
id: 'device.interface_manage.table.list.remark',
defaultMessage: '备注',
})}`}
initialValue={props.values.note}
required={false}
/>
</ProForm.Group>

@ -6,7 +6,7 @@ import {
deleteDeviceCategoryDeleteDeviceCategory,
postDeviceCategoryGetDeviceCategoryList,
} from '@/services/device/DeviceCategory';
import { getInterfaces, postInterfaces, postTestDevice } from '@/services/alarm/Interfaces'
import { getInterfacesUpload, postInterfacesUpload, 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';
@ -31,7 +31,7 @@ const RealTimeInterfaceManageList: React.FC = () => {
const [currentPageSize, setCurrentPageSize] = useState<number>(10);
const handleDestroy = async (selectedRow: API.UpdateInterfacesParams) => {
postInterfaces({ id: selectedRow.id, device_status: '3' } )
postInterfacesUpload({ id: selectedRow.id, device_status: '3' } )
.then(() => {
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
actionRef.current?.reload();
@ -108,8 +108,17 @@ const RealTimeInterfaceManageList: React.FC = () => {
},
{
title: <FormattedMessage id="device.interface_manage.table.list.obtainMode" defaultMessage="获取方式" />,
dataIndex: 'device_ip',
dataIndex: 'operate_mode',
hideInSearch: true,
render: (dom) => {
return (
<div>
{dom === 1 && 'FTP'}
{dom === 2 && 'FTP上传'}
{dom === 3 && '文件系统'}
</div>
);
},
},
{
title: <FormattedMessage id="device.interface_manage.table.list.obtainStatus" defaultMessage="设备状态" />,
@ -124,7 +133,7 @@ const RealTimeInterfaceManageList: React.FC = () => {
}}>
{dom === 1 ? '获取成功' : '获取失败'}
</Tag>
<span>{moment(entity.appear_time).format('YYYY-MM-DD hh:mm:ss')}</span>
<span>{moment(entity.create_time).format('YYYY-MM-DD hh:mm:ss')}</span>
{/* <Button
type="link"
icon={<RedoOutlined />}
@ -289,7 +298,7 @@ const RealTimeInterfaceManageList: React.FC = () => {
reqParams.desc = sort_select === 'descend';
}
// let resp = await postDeviceCategoryGetDeviceCategoryList({ ...reqParams });
let resp = await getInterfaces({ ...reqParams });
let resp = await getInterfacesUpload({ ...reqParams });
return {
data: resp.data.results.map((v: API.DeviceCategory) => {
return { ...v, key: v.id };

@ -266,7 +266,7 @@ const VideoAnalysis: React.FC = () => {
};
useEffect(() => {
getTabs();
initList();
// initList();
}, []);
useEffect(() => {
// 模拟异步请求数据

@ -55,4 +55,42 @@ export async function postTestDevice(
...(options || {}),
},
);
}
/** 离线设备列表 */
export async function getInterfacesUpload(
params: API.SearchAlarmRulesParams | any,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(
`/api/upload_device/`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
params: {
...params,
},
...(options || {}),
},
);
}
/** 更新接口列表 */
export async function postInterfacesUpload(
body: API.UpdateInterfacesParams | any,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: API.PageResult; msg?: string }>(
`/api/upload_device/`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
},
);
}

@ -81,8 +81,20 @@ declare namespace API {
note?: string; // 备注
device_status?: string; // 设备状态
id?: string;
appear_time?: string; // 设备状态
appear_time?: string; //
test_time?: string; //
create_time?: string; //
picture_path?: string;
operate_mode?: any;
upload_or_download?: any;
device_port?: string;
device_username?: string;
device_password?: string;
source_directory?: string;
destination_directory?: string;
access_key_id?: string;
access_key_secret?: string;
bucket?: string;
}
type AlarmDetailsParams = {
warning_name?: string; // 设备名称

Loading…
Cancel
Save