修改后端下拉框

dev
陈博文 3 years ago
parent 870de2fe74
commit 2c4cf97d5b

@ -1,4 +1,5 @@
import { Effect, Reducer } from 'umi';
import { getSelectData } from '@/service/index';
export interface BasicInfo {
resource: string;
@ -44,6 +45,7 @@ export interface CertificateInfo {
export interface BasicInfoModelState {
basicInfo: BasicInfo;
certificateInfo: CertificateInfo;
initData: any;
}
export interface BasicModelType {
@ -52,6 +54,7 @@ export interface BasicModelType {
effects: {
setActionData: Effect;
setCertificateInfo: Effect;
getSelectData: Effect;
};
reducers: {
save: Reducer<any>;
@ -100,16 +103,28 @@ const BasicModel: BasicModelType = {
importCertFile2: '',
result: [],
},
initData: [],
},
effects: {
*setActionData({ payload }, { call, put, select }) {
*getSelectData({ payload }, { call, put }): any {
const response = yield call(getSelectData, payload);
if (response?.result === 'success') {
yield put({
type: 'save',
payload: { initData: response?.data?.[0] },
});
}
return response;
},
*setActionData({ payload }, { call, put, select }): any {
const basicInfo = yield select((state: any) => state.basic.basicInfo);
yield put({
type: 'save',
payload: { basicInfo: { ...basicInfo, ...payload } },
});
},
*setCertificateInfo({ payload }, { call, put, select }) {
*setCertificateInfo({ payload }, { call, put, select }): any {
const certificateInfo = yield select(
(state: any) => state.basic.certificateInfo,
);

@ -3,6 +3,7 @@ import { Input, Button, Row, Form, Select, message } from 'antd';
import { FC } from 'react';
import { connect, Dispatch, BasicInfoModelState } from 'umi';
import Fetch from '@/utils/fetch';
import { getInitData } from '@/utils/util';
interface PageProps {
basic: BasicInfoModelState;
@ -14,8 +15,6 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
const { certificateInfo } = basic;
const { step } = certificateInfo;
console.log(certificateInfo, 'certificateInfo');
const handleValuesChange = (v: any) => {
dispatch({
type: 'basic/setCertificateInfo',
@ -83,9 +82,9 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
]}
>
<Select>
<Select.Option key={'ORACEL'}>ORACEL</Select.Option>
<Select.Option key={'SQL'}>SQL</Select.Option>
<Select.Option key={'SERVER'}>SERVER</Select.Option>
{getInitData('dbTypeList')?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item

@ -10,6 +10,7 @@ import {
history,
} from 'umi';
import { cloneDeep } from 'lodash';
import { getInitData } from '@/utils/util';
interface PageProps extends ConnectProps {
basic: BasicInfoModelState;
@ -200,9 +201,9 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
}}
style={{ width: 255, margin: '20px 10px' }}
>
<Select.Option key={'公司一级'}></Select.Option>
<Select.Option key={'公司二级'}></Select.Option>
<Select.Option key={'公司三级'}></Select.Option>
{getInitData('supportUnitList')?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</Row>
</Row>
@ -218,16 +219,10 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
}}
style={{ width: 255, margin: '20px 10px' }}
>
<Select.Option key={'公司节点一'}></Select.Option>
<Select.Option key={'公司节点二'}></Select.Option>
<Select.Option key={'公司节点三'}></Select.Option>
{getInitData('managerNodeList')?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
{/* <Input
value={managerNode}
onChange={(e) => handleInput('managerNode', e.target.value)}
size="large"
style={{ width: 255, margin: '20px 10px' }}
/> */}
</Row>
</Row>
<div className={styles.box3}>

@ -11,6 +11,7 @@ import {
} from 'umi';
import { downLoadLink } from '@/utils/download';
import url from '@/utils/url';
import { getInitData } from '@/utils/util';
interface PageProps extends ConnectProps {
basic: BasicInfoModelState;
@ -140,9 +141,9 @@ const Page: FC<PageProps> = ({ basic, dispatch }) => {
}}
style={{ width: 240, marginLeft: 10 }}
>
<Select.Option key={'2020'}>2020</Select.Option>
<Select.Option key={'2021'}>2021</Select.Option>
<Select.Option key={'2022'}>2022</Select.Option>
{getInitData('firstUnitList')?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</div>
<Row align="middle">

@ -13,16 +13,17 @@ import {
} from 'antd';
import Fetch from '@/utils/fetch';
import { useEffect, useState, FC, useRef } from 'react';
import { Link, history } from 'umi';
import { Link, history, connect, BasicInfoModelState } from 'umi';
import { downLoadLink } from '@/utils/download';
import url from '@/utils/url';
import { getInitData } from '@/utils/util';
interface PageProps {}
const Page: FC<PageProps> = () => {
const [type, setType] = useState<string>('1');
const [algorithm, setAlgorithm] = useState<string>('0');
const [length, setLength] = useState<any>('2');
const [algorithm, setAlgorithm] = useState<string>('');
const [length, setLength] = useState<any>('');
const [file, setFile] = useState<any>([]);
const item: any = [
@ -70,10 +71,14 @@ const Page: FC<PageProps> = () => {
message.warn('请选择导入文件');
return;
}
// if (type !== '2' && !length) {
// message.warn('请输入密钥长度');
// return;
// }
if (type !== '2' && !length) {
message.warn('请输入密钥长度');
return;
}
if (type === '2' && !algorithm) {
message.warn('请输入算法类型');
return;
}
downLoadLink(
`${url}/openi/secretKey/encryption?type=${type}&algorithm=${algorithm}&length=${length}&count=${file.length}`,
);
@ -88,7 +93,6 @@ const Page: FC<PageProps> = () => {
};
const title = item.find((e: any) => e.key === type).name;
return (
<div className={styles.page}>
<div className={styles.left}>
@ -98,13 +102,9 @@ const Page: FC<PageProps> = () => {
className={type === e.key ? styles.active : ''}
onClick={() => {
setType(e.key);
setLength('2');
setLength('');
setFile([]);
if (e.key === '2') {
setAlgorithm('1');
} else {
setAlgorithm('0');
}
setAlgorithm('');
}}
>
<b />
@ -141,8 +141,9 @@ const Page: FC<PageProps> = () => {
onChange={(k) => setAlgorithm(k)}
style={{ width: 400 }}
>
<Select.Option key="1">{'ECC359'}</Select.Option>
<Select.Option key="2">{'ECC281'}</Select.Option>
{getInitData('algorithmList')?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</div>
)}
@ -156,11 +157,9 @@ const Page: FC<PageProps> = () => {
onChange={(k) => setLength(k)}
style={{ width: 400 }}
>
<Select.Option key={'2'}>2</Select.Option>
<Select.Option key={'4'}>4</Select.Option>
<Select.Option key={'8'}>8</Select.Option>
<Select.Option key={'16'}>16</Select.Option>
<Select.Option key={'32'}>32</Select.Option>
{getInitData('keyLengthList')?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</div>
)}
@ -179,4 +178,6 @@ const Page: FC<PageProps> = () => {
</div>
);
};
export default Page;
export default connect(({ basic }: { basic: BasicInfoModelState }) => ({
basic,
}))(Page);

@ -18,11 +18,15 @@ import { downLoadLink } from '@/utils/download';
import url from '@/utils/url';
import moment from 'moment';
import { ColumnsType } from 'antd/lib/table';
import { getInitData } from '@/utils/util';
import { Link, BasicInfoModelState, connect } from 'umi';
const RangePicker: any = DatePicker.RangePicker;
interface PageProps {}
const Page: FC<PageProps> = () => {
const distributionNode = getInitData('distributionNodeList');
const [data, setData] = useState<any>([]);
const [loading, setLoading] = useState<boolean>(true);
const [total, setTotal] = useState<number>(0);
@ -414,8 +418,9 @@ const Page: FC<PageProps> = () => {
]}
>
<Select>
<Select.Option key="节点一">{'节点一'}</Select.Option>
<Select.Option key="节点二">{'节点二'}</Select.Option>
{distributionNode?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</Form.Item>
</Col>
@ -589,4 +594,6 @@ const Page: FC<PageProps> = () => {
</div>
);
};
export default Page;
export default connect(({ basic }: { basic: BasicInfoModelState }) => ({
basic,
}))(Page);

@ -13,21 +13,24 @@ import {
} from 'antd';
import Fetch from '@/utils/fetch';
import { useEffect, useState, FC, useRef } from 'react';
import { Link } from 'umi';
import { Link, BasicInfoModelState, connect } from 'umi';
import { downLoadLink } from '@/utils/download';
import url from '@/utils/url';
import ReactEcharts from 'echarts-for-react';
import { getInitData } from '@/utils/util';
interface PageProps {}
const Page: FC<PageProps> = () => {
const algorithmList = getInitData('algorithmList');
const keyLengthList = getInitData('keyLengthList');
const keyNodeList = getInitData('keyNodeList');
const [type, setType] = useState<string>('1');
const [algorithm, setAlgorithm] = useState<string>('0');
const [length, setLength] = useState<string>('2');
const [pushNode, setPushNode] = useState<string>('节点一');
const [algorithm, setAlgorithm] = useState<string>('');
const [length, setLength] = useState<string>('');
const [pushNode, setPushNode] = useState<string>('');
const [count, setCount] = useState<number>(1000);
const [data, setData] = useState<any>([]);
useEffect(() => {
getData();
}, [type]);
@ -97,16 +100,16 @@ const Page: FC<PageProps> = () => {
const title = item.find((e: any) => e.key === type).name;
const items = [
{
key: '1',
name: 'ECC359',
},
{
key: '2',
name: 'ECC281',
},
];
// const items = [
// {
// key: '1',
// name: 'ECC359',
// },
// {
// key: '2',
// name: 'ECC281',
// },
// ];
const option = {
tooltip: {
@ -132,7 +135,7 @@ const Page: FC<PageProps> = () => {
if (type !== '2') {
return e.length;
}
return items.find((k: any) => k.key === e.algorithm)?.name;
return e.algorithm;
}),
},
series: [
@ -150,6 +153,18 @@ const Page: FC<PageProps> = () => {
message.warn('推送组数不能为空');
return;
}
if (!algorithm && type === '2') {
message.warn('算法类型不能为空');
return;
}
if (!length) {
message.warn('密码长度不能为空');
return;
}
if (!pushNode) {
message.warn('推送节点不能为空');
return;
}
const res = await Fetch('/openi/secretKey/pushKey', {
method: 'post',
data: {
@ -181,11 +196,6 @@ const Page: FC<PageProps> = () => {
className={type === e.key ? styles.active : ''}
onClick={() => {
setType(e.key);
if (e.key === '2') {
setAlgorithm('1');
} else {
setAlgorithm('0');
}
}}
>
<b />
@ -226,11 +236,9 @@ const Page: FC<PageProps> = () => {
value={length}
onChange={(k) => setLength(k)}
>
<Select.Option key={'2'}>2</Select.Option>
<Select.Option key={'4'}>4</Select.Option>
<Select.Option key={'8'}>8</Select.Option>
<Select.Option key={'16'}>16</Select.Option>
<Select.Option key={'32'}>32</Select.Option>
{keyLengthList?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</Row>
<Row align="middle" className={mr}>
@ -240,8 +248,9 @@ const Page: FC<PageProps> = () => {
value={pushNode}
onChange={(k) => setPushNode(k)}
>
<Select.Option key="节点一">{'节点一'}</Select.Option>
<Select.Option key="节点二">{'节点二'}</Select.Option>
{keyNodeList?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</Row>
{type === '2' && (
@ -252,8 +261,8 @@ const Page: FC<PageProps> = () => {
onChange={(k) => setAlgorithm(k)}
style={{ width: 100 }}
>
{items.map((e: any) => (
<Select.Option key={e.key}>{e.name}</Select.Option>
{algorithmList?.map((e: any) => (
<Select.Option key={e}>{e}</Select.Option>
))}
</Select>
</Row>
@ -275,4 +284,6 @@ const Page: FC<PageProps> = () => {
</div>
);
};
export default Page;
export default connect(({ basic }: { basic: BasicInfoModelState }) => ({
basic,
}))(Page);

@ -1,5 +1,5 @@
import { useEffect } from 'react';
import { history } from 'umi';
import { history, getDvaApp } from 'umi';
import { ConfigProvider } from 'antd';
import zhCN from 'antd/es/locale/zh_CN';
import '@/styles/base.less';
@ -12,6 +12,10 @@ const IndexPage = ({ ...props }) => {
if (basic.includes(props.location.pathname)) {
history.replace('/basic');
}
getDvaApp()._store.dispatch({
type: 'basic/getSelectData',
payload: {},
});
}, []);
return <ConfigProvider locale={zhCN}>{props.children}</ConfigProvider>;

@ -0,0 +1,8 @@
import Fetch from '@/utils/fetch';
export async function getSelectData(params: any) {
return Fetch(`/openi/sysDict/all`, {
method: 'get',
params,
});
}

@ -0,0 +1,9 @@
import { getDvaApp } from 'umi';
export const getInitData = (type: string) => {
const { basic }: any = getDvaApp()._store.getState();
const { initData }: any = basic;
const param = { ...initData[0], ...initData[1], ...initData[2] };
console.log(param, param[type], type, 'initData');
return param[type];
};
Loading…
Cancel
Save