Commit a2316832 authored by mayongxin's avatar mayongxin

add:宿主管理-消息平台

parent 33191327
Pipeline #24575 passed with stages
in 17 minutes 8 seconds
import React, { useEffect, useState } from 'react'
import { Card, Form, Input, Button, Select, message } from 'antd'
import styles from './IotConfig.less'
import { GetIOTPlatformVersion, GetTCPConfigInfo, PingIOTPlatform,SaveTcpAddress } from '../../../../services/platform/hostmanager'
import { GetIOTPlatformVersion, GetTCPConfigInfo, PingIOTPlatform,SaveTcpAddress } from '@/services/platform/hostmanager'
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 16 },
......
......@@ -3,6 +3,7 @@ import { Tabs } from 'antd';
import PageContainer from '@/components/BasePageContainer';
import BaseConfig from './baseConfig/BaseConfig'
import IotConfig from './IotConfig/IotConfig'
import MessageConfig from './messageConfig/messageConfig'
const { TabPane } = Tabs;
......@@ -23,7 +24,7 @@ const HostManager = () => {
<IotConfig/>
</TabPane>
<TabPane tab="消息配置" key="3">
Content of Tab Pane 3
<MessageConfig/>
</TabPane>
<TabPane tab="代理配置" key="4">
Content of Tab Pane 3
......
import React, { useEffect, useState } from 'react'
import { Card, Form, Input, Button, Select, message } from 'antd'
import styles from './messageConfig.less';
import { GetMessageConfigInfo, SaveSystemInfo, ConnectMessPlatform, GetBasicInfo, GetDataBaseConfig } from '@/services/platform/hostmanager'
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 16 },
};
const tailLayout = {
wrapperCol: { offset: 8, span: 16 },
};
const MessageConfig = () => {
const [currentAddress, setCurrentAddress] = useState("")
const [currentDataBase, setCurrentDataBase] = useState({});
const [currentSiteInfo, setcurrentSiteInfo] = useState("");
const [form] = Form.useForm();
const onFinish = (values) => {
//先测试连接再保存
//1.测试链接
ConnectMessPlatform({
messAddress: values.messageAddress,
sqlServerIP: currentDataBase.ip,
loginName: currentDataBase.userName,
password: currentDataBase.password,
sqlName: currentDataBase.dbName,
siteCode: currentSiteInfo
}).then(res => {
if (res.code === 0) {
//2.保存连接
SaveSystemInfo({
configName: "消息平台连接地址",
configValue: values.messageAddress
}).then(
res => {
if (res.code === 0) {
message.info("配置保存成功")
} else {
message.errorInfo(res.msg)
}
}
)
} else {
message.errorInfo(res.msg)
}
})
};
const onFinishFailed = (errorInfo) => {
console.log('Failed:', errorInfo);
};
useEffect(() => {
GetMessageConfigInfo().then(
res => {
if (res.code == 0) {
setCurrentAddress(res.data)
form.setFieldsValue({ messageAddress: res.data });
GetDataBaseConfig().then(
res => {
if (res.code === 0) {
setCurrentDataBase(res.data)
GetBasicInfo().then(
res => {
if (res.code === 0) {
setcurrentSiteInfo(res.data)
}
}
)
}
}
)
} else {
message.info("获取消息平台配置失败!")
}
}
)
}, [])
return (
<div className={styles.message_container}>
<Card title={`消息平台`} style={{ width: 430 }}>
<Form
{...layout}
form={form}
name="basic"
initialValues={{ remember: true }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
>
<Form.Item
label="服务器地址(平台)"
name="messageAddress"
rules={[{ required: true, message: '请输入服务器地址!' }]}
>
<Input />
</Form.Item>
<Form.Item {...tailLayout}>
<Button type="primary" htmlType="submit" disabled={currentSiteInfo.length > 0 ? false : true}>
保存连接
</Button>
</Form.Item>
</Form>
</Card>
</div>
)
}
export default MessageConfig
\ No newline at end of file
.message_container{
display: flex;
height: 100%;
width: 100%;
flex-direction: row;
justify-content: flex-start;
}
\ No newline at end of file
......@@ -19,4 +19,10 @@ export const PingIOTPlatform = param =>
get(`${PUBLISH_SERVICE}/HostManager/PingIOTPlatform`, param);
export const SaveTcpAddress = param =>
get(`${PUBLISH_SERVICE}/HostManager/SaveTcpAddress`, param);
export const GetMessageConfigInfo = param =>
get(`${PUBLISH_SERVICE}/HostManager/GetMessageConfigInfo`, param);
export const ConnectMessPlatform = param =>
get(`${PUBLISH_SERVICE}/HostManager/ConnectMessagePlatform`, param);
export const SaveSystemInfo = param =>
get(`${PUBLISH_SERVICE}/HostManager/SaveSystemInfo`, param);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment