BaseConfig.jsx 3.51 KB
Newer Older
mayongxin's avatar
mayongxin committed
1
import React, { useState, useEffect } from 'react'
2
import { Button, Descriptions, Input } from 'antd'
mayongxin's avatar
mayongxin committed
3
import styles from './BaseConfig.less'
mayongxin's avatar
mayongxin committed
4
import { S_GetDataBaseConfig, GetTCPConfigInfo, GetDataBaseConfig, GetBasicInfo } from '@/services/platform/hostmanager'
mayongxin's avatar
mayongxin committed
5

mayongxin's avatar
mayongxin committed
6 7 8 9 10 11



const BaseConfig = () => {


mayongxin's avatar
mayongxin committed
12
    const [currentDataBase, setCurrentDataBase] = useState({userName:"",password:"",dbName:"",ip:""});
mayongxin's avatar
mayongxin committed
13
    const [currentSiteInfo, setcurrentSiteInfo] = useState("");
mayongxin's avatar
mayongxin committed
14 15 16


    useEffect(() => {
mayongxin's avatar
mayongxin committed
17 18 19
        getCurrentConfig()
        getSiteCode()
    }, [])
mayongxin's avatar
mayongxin committed
20 21

    const getCurrentConfig = () => {
mayongxin's avatar
mayongxin committed
22

mayongxin's avatar
mayongxin committed
23
        GetDataBaseConfig().then(
mayongxin's avatar
mayongxin committed
24 25
            res => {
                if (res.code === 0) {
mayongxin's avatar
mayongxin committed
26
                    setCurrentDataBase(res.data)
mayongxin's avatar
mayongxin committed
27 28 29 30 31
                }
            }
        )
    }
    const getSiteCode = () => {
mayongxin's avatar
mayongxin committed
32
        GetBasicInfo().then(
mayongxin's avatar
mayongxin committed
33 34
            res => {
                if (res.code === 0) {
mayongxin's avatar
mayongxin committed
35
                    setcurrentSiteInfo(res.data)
mayongxin's avatar
mayongxin committed
36 37 38 39
                }
            }
        )
    }
mayongxin's avatar
mayongxin committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    // return (
    //     <div className={styles.base_container}>
    //         <Card title="数据库连接" style={{ width: 300 }}>
    //             <Card type="inner" title="服务器IP" style={{ margin: 10 }}>
    //                 {currentDataBase.ip}
    //             </Card>
    //             <Card type="inner" title="数据库名称" style={{ margin: 10 }}>
    //                 {currentDataBase.dbName}
    //             </Card>

    //         </Card>
    //         <Card title="权限验证" style={{ width: 300, marginLeft: 15 }}>
    //             <Card type="inner" title="登录名" style={{ margin: 10 }}>
    //                 {currentDataBase.userName}
    //             </Card>
    //             <Card type="inner" title="密码" style={{ margin: 10 }}>
    //                 {currentDataBase.password}
    //             </Card>
    //         </Card>
    //         <Card title="站点信息" style={{ width: 300, marginLeft: 15 }}>
    //             <Card type="inner" title="站点编号" style={{ margin: 10 }}>
    //                 {currentSiteInfo}
    //             </Card>
    //         </Card>
    //     </div>
    // )
    const encrypt = (word) => {
        let encryptStr = ""
        for(let i = 0;i < word.length;i++){
            encryptStr += "*"
        }
        return encryptStr
    }
mayongxin's avatar
mayongxin committed
73 74
    return (
        <div className={styles.base_container}>
75
            <div style={{ backgroundColor: "white", padding: "10px", width: "100%" }}>
mayongxin's avatar
mayongxin committed
76
                <Descriptions title="" bordered >
77 78
                    <Descriptions.Item label="站点编号" span={3}>
                        {
mayongxin's avatar
mayongxin committed
79
                            currentSiteInfo?<Input value={currentSiteInfo} disabled={true} style={{with:"200px"}}/>:<div>
mayongxin's avatar
mayongxin committed
80 81
                                <Input value={currentSiteInfo} style={{width:"200px"}} />
                               <Button style={{marginLeft:"10px"}}>生成编号</Button>
82 83 84
                            </div>
                        }
                    </Descriptions.Item>
mayongxin's avatar
mayongxin committed
85 86 87 88
                    <Descriptions.Item label="服务器IP" span={3}>{currentDataBase.ip}</Descriptions.Item>
                    <Descriptions.Item label="数据库名称" span={3}>{currentDataBase.dbName}</Descriptions.Item>
                    <Descriptions.Item label="登录名" span={1}>{currentDataBase.userName}</Descriptions.Item>
                    <Descriptions.Item label="密码" span={1}>{encrypt(currentDataBase.password)}</Descriptions.Item>
mayongxin's avatar
mayongxin committed
89

mayongxin's avatar
mayongxin committed
90 91
                </Descriptions>
            </div>
mayongxin's avatar
mayongxin committed
92 93 94 95 96 97
        </div>
    )

}
export default BaseConfig