第一个系统完成

dev
陈博文 3 years ago
parent 2b74bdbce9
commit 8b9c4d08d7

@ -1,7 +1,8 @@
import { Effect, Reducer } from 'umi';
export interface BasicInfo {
text: string;
resource: string;
cert: string;
dataName: string;
dbPasswd: string;
dbServerIp: string;
@ -37,6 +38,7 @@ export interface CertificateInfo {
targetPort: string;
targetPasswd: string;
targetUserdn: string;
result: any;
}
export interface BasicInfoModelState {
@ -60,7 +62,8 @@ const BasicModel: BasicModelType = {
namespace: 'basic',
state: {
basicInfo: {
text: '',
resource: '',
cert: '',
dbUser: '',
dbPasswd: '',
dbServerIp: '',
@ -76,7 +79,7 @@ const BasicModel: BasicModelType = {
file4: null,
},
certificateInfo: {
step: 3,
step: 1,
company: '',
dbType: '',
dbDrive: '',
@ -85,7 +88,7 @@ const BasicModel: BasicModelType = {
dbName: '',
dbUser: '',
dbPasswd: '',
dbIsConn: true,
dbIsConn: false,
targetIp: '',
targetPort: '',
targetUserdn: '',
@ -95,6 +98,7 @@ const BasicModel: BasicModelType = {
certCycle: 0,
importCertFile1: '',
importCertFile2: '',
result: [],
},
},
effects: {

@ -1,7 +1,8 @@
import styles from './index.less';
import { Input, Button, Row, Form, Select } from 'antd';
import { Input, Button, Row, Form, Select, message } from 'antd';
import { FC } from 'react';
import { connect, Dispatch, BasicInfoModelState } from 'umi';
import Fetch from '@/utils/fetch';
interface PageProps {
basic: BasicInfoModelState;
@ -22,6 +23,32 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
});
};
const testLink = async () => {
const res = await Fetch('/openi/resource/dbTestConnection', {
method: 'post',
data: {
dbType: certificateInfo.dbType,
dbDrive: certificateInfo.dbDrive,
dbIp: certificateInfo.dbIp,
dbPort: certificateInfo.dbPort,
dbName: certificateInfo.dbName,
dbUser: certificateInfo.dbUser,
dbPasswd: certificateInfo.dbPasswd,
},
});
if (res.result === 'success') {
const data = res?.data?.[0];
dispatch({
type: 'basic/setCertificateInfo',
payload: {
dbIsConn: data?.isConn,
},
});
} else {
message.error(res.errorMsg);
}
};
return (
<div
style={{ display: step === 1 ? 'block' : 'none' }}
@ -135,7 +162,9 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
</Form.Item>
</Form>
<Row justify="end">
<Button type="primary"></Button>
<Button onClick={testLink} type="primary">
</Button>
<Button
type="primary"
ghost

@ -1,14 +1,8 @@
import styles from './index.less';
import { message, Input, Button, Row, Modal, Form, Select } from 'antd';
import { message, Button, Row, Form } from 'antd';
import Fetch from '@/utils/fetch';
import { useEffect, useState, FC } from 'react';
import {
connect,
ConnectProps,
Dispatch,
BasicInfoModelState,
history,
} from 'umi';
import { useState, FC } from 'react';
import { connect, Dispatch, BasicInfoModelState } from 'umi';
interface PageProps {
basic: BasicInfoModelState;
@ -16,7 +10,6 @@ interface PageProps {
}
const Page: FC<PageProps> = ({ basic, dispatch }) => {
const [form] = Form.useForm();
const { certificateInfo } = basic;
const { step, importCertFile1, importCertFile2 } = certificateInfo;
const [file1, setFile1] = useState<any>(null);
@ -45,7 +38,6 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
const data: any = new FormData();
data.append('files', file1);
data.append('files', file2);
data.append('resourceDir', '/cert');
const res = await Fetch('/openi/resource/importFiles', {
method: 'post',
data,
@ -64,6 +56,27 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
}
};
const skip = async () => {
const res = await Fetch('/openi/resource/getCertInfomation');
if (res.errorCode === 500) {
message.error(res?.errorMsg);
return;
}
if (res.result === 'success') {
const data = res?.data?.[0];
dispatch({
type: 'basic/setCertificateInfo',
payload: {
result: data,
},
});
dispatch({
type: 'basic/setCertificateInfo',
payload: { step: 4 },
});
}
};
return (
<div
style={{ display: step === 3 ? 'block' : 'none' }}
@ -114,8 +127,8 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
disabled={upload}
type="primary"
ghost
onClick={() => form.submit()}
className="ml20"
onClick={skip}
>
</Button>

@ -0,0 +1,71 @@
.page {
background-color: #fff;
width: 1200px;
margin: 0 auto;
min-height: 600px;
overflow: hidden;
padding-bottom: 20px;
.name {
display: flex;
align-items: center;
margin-bottom: 50px;
margin-top: 30px;
b {
width: 6px;
height: 20px;
background: #464f66;
border-radius: 4px;
display: inline-block;
margin-right: 4px;
}
span {
font-size: 24px;
font-weight: 500;
color: #232b40;
}
}
.title {
display: flex;
align-items: center;
margin-left: 60px;
margin-bottom: 10px;
b {
width: 4px;
height: 14px;
background: #464f66;
border-radius: 4px;
display: inline-block;
margin-right: 4px;
}
span {
font-size: 18px;
font-weight: 500;
color: #464f66;
}
}
.row {
display: flex;
align-items: center;
justify-content: center;
padding: 15px 0;
span {
margin: 0 10px;
width: 50%;
font-size: 14px;
color: #333;
}
span:first-child {
text-align: right;
color: #464f66;
}
}
}

@ -0,0 +1,106 @@
import styles from './index.less';
import { Button, Row, message } from 'antd';
import { FC } from 'react';
import Fetch from '@/utils/fetch';
import { connect, Dispatch, BasicInfoModelState, history } from 'umi';
interface PageProps {
basic: BasicInfoModelState;
dispatch: Dispatch;
}
const Page: FC<PageProps> = ({ basic, dispatch }) => {
const { certificateInfo } = basic;
const { step, result } = certificateInfo;
const handleClick = async () => {
const res = await Fetch('/openi/resource/openCertNow', {
method: 'post',
data: certificateInfo,
});
if (res.result === 'success') {
message.success('开通证书系统成功');
history.replace('/basic/login');
}
};
return (
<div
style={{ display: step === 4 ? 'block' : 'none' }}
className={styles.page}
>
<div className={styles.name}>
<b /> <span></span>
</div>
<div className={styles.title}>
<b /> <span>ECCDSA359</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[0]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[1]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[2]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[3]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[4]}</span>
</div>
<div className={styles.title}>
<b /> <span>ECCDSA281</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[5]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[6]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[7]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[8]}</span>
</div>
<div className={styles.row}>
<span></span>
<span>{result?.[9]}</span>
</div>
<Row justify="end">
<Button
onClick={() => {
dispatch({
type: 'basic/setCertificateInfo',
payload: { step: 3 },
});
}}
type="primary"
ghost
>
</Button>
<Button type="primary" ghost className="ml20" onClick={handleClick}>
</Button>
</Row>
</div>
);
};
export default connect(({ basic }: { basic: BasicInfoModelState }) => ({
basic,
}))(Page);

@ -3,6 +3,7 @@ import { FC } from 'react';
import Step1 from './Step1';
import Step2 from './Step2';
import Step3 from './Step3';
import Step4 from './Step4';
const Page: FC<{}> = () => {
return (
@ -10,6 +11,7 @@ const Page: FC<{}> = () => {
<Step1 />
<Step2 />
<Step3 />
<Step4 />
</div>
);
};

@ -21,7 +21,6 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
const { basicInfo } = basic;
const [uploadDisabled, setUploadDisabled] = useState<boolean>(false);
const {
text,
type,
dataName,
nodeName,
@ -137,7 +136,7 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
<b /> <span></span>
</div>
<div className={styles.status}>
<span>{text || '未开通'}</span>
<span>{'未开通'}</span>
</div>
<Tabs
activeKey={type}

@ -1,5 +1,5 @@
import styles from './index.less';
import { Select, Input, Button, Row, Modal, Form } from 'antd';
import { Select, Input, Button, Row, Modal, Form, message } from 'antd';
import Fetch from '@/utils/fetch';
import { useEffect, useState, FC } from 'react';
import {
@ -20,11 +20,15 @@ interface PageProps extends ConnectProps {
const Page: FC<PageProps> = ({ basic, dispatch }) => {
const [visible, setVisible] = useState<boolean>(false);
const [certSign, setCertSign] = useState<boolean>(false);
const [form] = Form.useForm();
const { basicInfo, certificateInfo } = basic;
const { dbUser, dbPasswd, dbServerIp, text } = basicInfo;
const { dbUser, dbPasswd, dbServerIp, resource, cert } = basicInfo;
const { company } = certificateInfo;
const isResource = resource === '已开通' || resource === '';
const isCert = cert === '已开通' || cert === '';
console.log(certificateInfo, 'certificateInfo');
useEffect(() => {
@ -34,11 +38,11 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
const getData = async () => {
const res = await Fetch('/openi/resource/getResourceStatus');
if (res.result === 'success') {
console.log(res.result?.data?.[0]?.resource, 444);
dispatch({
type: 'basic/setActionData',
payload: {
text: res?.data?.[0]?.resource ? '已开通' : '未开通',
resource: res?.data?.[0]?.resource ? '已开通' : '未开通',
cert: res?.data?.[0]?.cert ? '已开通' : '未开通',
},
});
}
@ -53,9 +57,17 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
};
const certificateOpen = async () => {
if (!company) {
message.warn('选择单位不能为空');
return;
}
if (!certSign) {
message.warn('请先下载证书');
return;
}
const res = await Fetch.post('/openi/resource/openCertSystem');
if (res.result === 'success') {
history.replace('/basic/device');
history.replace('/basic/certificate');
}
};
@ -69,8 +81,6 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
history.replace('/basic/device');
};
const disabled = text === '已开通';
return (
<div className={styles.login}>
<div className={styles.left}>
@ -79,10 +89,10 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
<span></span>
</div>
<div className={styles.status}>
<span>{text}</span>
<span>{resource}</span>
</div>
<Button
disabled={disabled}
disabled={isResource}
type="primary"
onClick={open}
className={styles.btn}
@ -100,11 +110,11 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
<span></span>
</div>
<div className={styles.status}>
<span>{text}</span>
<span>{cert}</span>
</div>
<Button
type="primary"
disabled={!disabled}
disabled={isCert}
onClick={certificateOpen}
className={styles.btn}
>
@ -113,7 +123,7 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
<div style={{ marginLeft: -66 }}>
<span></span>
<Select
disabled={!disabled}
disabled={isCert}
size="large"
value={company}
onChange={(k: any) => {
@ -132,13 +142,14 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
<Row align="middle">
<Button
onClick={() => {
setCertSign(true);
downLoadLink(url + '/openi/resource/downloadCertFile');
}}
className="mt20"
style={{ width: 240 }}
type="primary"
ghost
disabled={!disabled}
disabled={isCert}
size="large"
>

@ -8,7 +8,7 @@ import '@/styles/iconfont/iconfont.css';
const IndexPage = ({ ...props }) => {
//重定向页面
useEffect(() => {
const basic = ['/', '/basic/device'];
const basic = ['/', '/basic/device', '/basic/certificate'];
if (basic.includes(props.location.pathname)) {
history.replace('/basic/login');
}

Loading…
Cancel
Save