master_basic
鲁誉程 11 months ago
parent fffb8534e7
commit 9da2202f8a

@ -1,8 +1,10 @@
import ContentWarp from '@/components/ContentWarp';
import styles from '../../index.less';
import styles1 from './index.less';
import { Form, Input } from 'antd';
import { Form, Input, message } from 'antd';
import ButtonComp from '@/components/ButtonComp';
import { remoteFileConfiSendData, remoteFileConfigClean } from '@/services/gql';
import { subnetMaskValidator, validateIPAddress } from '@/utils/validate';
// 网络GLQ配置 --> 远程文件配置--> 网络参数
export default function Page() {
@ -10,9 +12,28 @@ export default function Page() {
const [form] = Form.useForm();
const onFinish = (values: any) => {
console.log('表单提交:', values);
remoteFileConfiSendData({
jsonStr: JSON.stringify(values),
type: 2
}).then( (res) => {
if (res?.result == "success") {
message.success('文件提交成功');
form.resetFields();
}else {
message.error(res?.errorMsg);
}
})
};
const clearInfo = () => {
remoteFileConfigClean({type: 2}).then(res => {
if (res?.result == "success") {
message.success('清除信息成功');
}else {
message.error(res?.errorMsg);
}
})
}
return (
<div className={`${styles.params_warp} ${styles1.params_warp1}`}>
@ -25,25 +46,26 @@ export default function Page() {
onFinish={onFinish}
>
<Form.Item
name="a3"
name="ipAddress"
label="IP地址"
rules={[
{ required: true, message: '请输入IP地址' },
{ validator: validateIPAddress }
]}
>
<Input style={{ width: '560px' }} />
</Form.Item>
<Form.Item
name="a2"
name="mask"
label="子网掩码"
rules={[
{ required: true, message: '请输入子网掩码' },
{ required: true, message: '请输入子网掩码' }
]}
>
<Input style={{ width: '560px' }} />
</Form.Item>
<Form.Item
name="a1"
name="defaultGateway"
label="默认网关"
rules={[
{ required: true, message: '请输入默认网关' },
@ -54,7 +76,7 @@ export default function Page() {
</Form>
<div className={styles.btn_warp}>
<ButtonComp style={{ marginRight: 20 }} text={'文件提交'} onClick={() => form.submit()} />
<ButtonComp type={'cancel'} text={'清空信息'} onClick={() => form.resetFields()} />
<ButtonComp type={'cancel'} text={'清空信息'} onClick={() => clearInfo()} />
</div>
</div>
</ContentWarp>

@ -1,18 +1,30 @@
import ContentWarp from '@/components/ContentWarp';
import styles from '../../index.less';
import { ConfigProvider, Form, Input, Table } from 'antd';
import { ConfigProvider, Form, Input, Table, message } from 'antd';
import ButtonComp from '@/components/ButtonComp';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { rowClassName } from '@/utils';
import { getTextSecretInfo } from '@/services/gql';
import { validateIPAddress } from '@/utils/validate';
// 网络GLQ配置 --> 远程文件配置--> 安全策略
export default function Page() {
const [form] = Form.useForm();
const [tableData, setTableData] = useState([]);
useEffect(() => {
form.setFieldsValue({ip: '114.114.114.114'})
}, [])
const onFinish = (values: any) => {
console.log('表单提交:', values);
getTextSecretInfo(values).then(res => {
if (res?.result == "success") {
message.success('获取成功');
} else {
message.error(res?.errorMsg);
}
})
};
const columns: any = [
@ -46,9 +58,12 @@ export default function Page() {
rowKey={(record: any) => record?.id}
rowClassName={rowClassName}
/>
<Form form={form} layout={'inline'} onFinish={onFinish} className='mt20'>
<Form.Item name="aaa" label="普密对外服务器IP仅Ⅱ型隔离器时需配置此项" rules={[{ required: true, message: '请输入普密对外服务器IP' }]} >
<Form.Item name="ip" label="普密对外服务器IP仅Ⅱ型隔离器时需配置此项" rules={[
{ required: true, message: '请输入普密对外服务器IP' },
{ validator: validateIPAddress }
]} >
<Input style={{ width: '280px' }} />
</Form.Item>
<ButtonComp style={{ marginRight: 20 }} text={'获取普密信息'} onClick={() => form.submit()} />

@ -46,6 +46,7 @@ export default function Page() {
}).then( (res) => {
if (res?.result == "success") {
message.success('发送数据成功');
form.resetFields();
}else {
message.error(res?.errorMsg);
}
@ -73,10 +74,16 @@ export default function Page() {
<Form.Item name="serviceName" label="服务名称" rules={[{ required: true, message: '请输入服务名称' }]} >
<Input style={{ width: '200px' }} />
</Form.Item>
<Form.Item name="serviceIP" label="服务IP" rules={[{ required: true, message: '请输入服务IP' },{ validator: validateIPAddress }]} >
<Form.Item name="serviceIP" label="服务IP" rules={[
{ required: true, message: '请输入服务IP' },
{ validator: validateIPAddress}
]} >
<Input style={{ width: '200px' }} />
</Form.Item>
<Form.Item name="servicePort" label="服务端口" rules={[{ required: true, message: '请输入服务端口' },{ validator: validatePort }]} >
<Form.Item name="servicePort" label="服务端口" rules={[
{ required: true, message: '请输入服务端口' },
{ validator: validatePort }
]} >
<Input style={{ width: '200px' }} />
</Form.Item>
<ButtonComp text={'提交'} onClick={() => form.submit()} />

@ -1,4 +1,4 @@
import { getRequest, postRequest, uploadFile } from "@/utils/request";
import { getRequest, postFormDataRequest, postRequest, uploadFile } from "@/utils/request";
// 参数设置
export async function setParameter(data: any) {
@ -48,4 +48,10 @@ export async function remoteFileConfiSendData(params: any) {
// @param type
export async function remoteFileConfigClean(params: any) {
return getRequest(`/xgd/netGlq/remoteFileConfigClean`, params);
}
// 获取普密信息
// @param ip
export async function getTextSecretInfo(data: any) {
return postFormDataRequest(`/xgd/netGlq/getTextSecretInfo`, data);
}

@ -52,6 +52,29 @@ export function postRequest(url: string, data: object) {
}
/**
* POST
* @param {string} url - URL
* @param {object} data -
* @returns {Promise} - Promise response error
*/
export function postFormDataRequest(url: string, data: object) {
const formData = new FormData();
for (const key in data) {
formData.append(key, data[key]);
}
return fetch(url, {
method: 'POST',
body: formData
})
.then(response => {
if (!response.ok) { throw new Error('请求失败'); }
return response.json();
})
.catch(error => console.error(error));
}
/**
* Delete
* @param {string} url - URL

@ -13,4 +13,13 @@ export const validateIPAddress = (_: any, value: any) => {
return Promise.reject(new Error('请输入正确的 IP 地址'));
}
return Promise.resolve();
};
// 校验子网掩码
export const subnetMaskValidator = (_: any, value: any) => {
const regex = /^(128|192|224|240|248|252|254)\.(0|128|192|224|240|248|252|254)\.(0|128|192|224|240|248|252|254)\.(0|128|192|224|240|248|252|254)$/;
if (!regex.test(value)) {
return Promise.reject(new Error('请输入有效的子网掩码'));
}
return Promise.resolve();
};
Loading…
Cancel
Save