Commit 9d819d1e authored by 皮倩雯's avatar 皮倩雯

fix: '首页操作数据库初始化'

parent 0e46664d
Pipeline #84341 waiting for manual action with stages
...@@ -22,6 +22,7 @@ import { ...@@ -22,6 +22,7 @@ import {
Tooltip, Tooltip,
Table, Table,
message, message,
Select,
} from 'antd'; } from 'antd';
import PageContainer from '@/components/BasePageContainer'; import PageContainer from '@/components/BasePageContainer';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
...@@ -64,6 +65,7 @@ const formLables = { ...@@ -64,6 +65,7 @@ const formLables = {
}; };
let time = null; let time = null;
const DatabaseInitialization = props => { const DatabaseInitialization = props => {
const { callBackSubmit = () => {}, visible } = props;
const [form] = Form.useForm(); const [form] = Form.useForm();
const [modalVisible, setModalVisible] = useState({ const [modalVisible, setModalVisible] = useState({
describeVisible: false, // 描述弹窗 describeVisible: false, // 描述弹窗
...@@ -95,7 +97,6 @@ const DatabaseInitialization = props => { ...@@ -95,7 +97,6 @@ const DatabaseInitialization = props => {
const [keepCo, setkeepCo] = useState(''); const [keepCo, setkeepCo] = useState('');
const [keepMsg, setkeepMsg] = useState(''); const [keepMsg, setkeepMsg] = useState('');
const [allLength, setAllLength] = useState(''); const [allLength, setAllLength] = useState('');
const [oldColor, setOldColor] = useState('gray');
const [beforeColor, setbeforeColor] = useState('gray'); const [beforeColor, setbeforeColor] = useState('gray');
const [firstColor, setfirstColor] = useState('gray'); const [firstColor, setfirstColor] = useState('gray');
const [secordColor, setsecordColor] = useState('gray'); const [secordColor, setsecordColor] = useState('gray');
...@@ -106,7 +107,6 @@ const DatabaseInitialization = props => { ...@@ -106,7 +107,6 @@ const DatabaseInitialization = props => {
const [keepInline, setKeepInline] = useState([]); const [keepInline, setKeepInline] = useState([]);
const [ifInline, setIfInline] = useState('hidden'); const [ifInline, setIfInline] = useState('hidden');
const [result, setResult] = useState(''); const [result, setResult] = useState('');
const [license, setLicense] = useState('');
const [dataResult, setDataResult] = useState(''); const [dataResult, setDataResult] = useState('');
const [productResult, setProductResult] = useState(''); const [productResult, setProductResult] = useState('');
const [keepInitContent, setKeepInitContent] = useState(''); const [keepInitContent, setKeepInitContent] = useState('');
...@@ -114,7 +114,6 @@ const DatabaseInitialization = props => { ...@@ -114,7 +114,6 @@ const DatabaseInitialization = props => {
const [keepinitVisible, setKeepInitVisible] = useState(false); const [keepinitVisible, setKeepInitVisible] = useState(false);
const [password, setPassword] = useState(false); const [password, setPassword] = useState(false);
const [isAuthorize, setIsAuthorize] = useState(false); const [isAuthorize, setIsAuthorize] = useState(false);
const [licen, setLicen] = useState('');
const [showDetali, setShowDetali] = useState(false); const [showDetali, setShowDetali] = useState(false);
const [keepLast, setKeepLast] = useState(''); const [keepLast, setKeepLast] = useState('');
const [appendVisible, setAppendVisible] = useState(false); const [appendVisible, setAppendVisible] = useState(false);
...@@ -156,8 +155,7 @@ const DatabaseInitialization = props => { ...@@ -156,8 +155,7 @@ const DatabaseInitialization = props => {
useEffect(() => { useEffect(() => {
setCardLoading(true); setCardLoading(true);
getProductList(); getProductList();
// form.setFieldsValue({ ip: '127.0.0.1', password: 'sa', userName: 'sa' }); }, [visible]);
}, []);
const getProductList = () => { const getProductList = () => {
GetProductList().then(res => { GetProductList().then(res => {
...@@ -244,18 +242,9 @@ const DatabaseInitialization = props => { ...@@ -244,18 +242,9 @@ const DatabaseInitialization = props => {
} }
if (!res.data.finish) { if (!res.data.finish) {
// if (!finish) {
time = setTimeout(() => { time = setTimeout(() => {
doInitLog(); doInitLog();
}, 600); }, 600);
// } else {
// setInitLoading(false);
// setShow('visible');
// if (time) {
// clearTimeout(time);
// time = null;
// }
// }
} else { } else {
setInitLoading(false); setInitLoading(false);
setShow('visible'); setShow('visible');
...@@ -368,6 +357,7 @@ const DatabaseInitialization = props => { ...@@ -368,6 +357,7 @@ const DatabaseInitialization = props => {
dbName: resdata.data.dbName, dbName: resdata.data.dbName,
userName: resdata.data.userName, userName: resdata.data.userName,
password: resdata.data.password, password: resdata.data.password,
providerType: resdata.data.providerType,
}); });
GetDbChangeFirst(kk); GetDbChangeFirst(kk);
// 有License的情况下首次进入展示数据 // 有License的情况下首次进入展示数据
...@@ -750,6 +740,9 @@ const DatabaseInitialization = props => { ...@@ -750,6 +740,9 @@ const DatabaseInitialization = props => {
setKeepLast(res.data.msg); setKeepLast(res.data.msg);
} }
}); });
if (visible) {
callBackSubmit({ ...obj, productSetting, password: pwd });
}
} else { } else {
setDataResult(res.msg); setDataResult(res.msg);
setFinish(true); setFinish(true);
...@@ -804,6 +797,12 @@ const DatabaseInitialization = props => { ...@@ -804,6 +797,12 @@ const DatabaseInitialization = props => {
setSimpleProduct(res.data.productPackageCount); setSimpleProduct(res.data.productPackageCount);
setLastColor('green'); setLastColor('green');
setKeepLast(''); setKeepLast('');
if (visible) {
callBackSubmit({
...obj,
password: pwd,
});
}
} else { } else {
setDataResult(res.msg); setDataResult(res.msg);
setFinish(true); setFinish(true);
...@@ -829,46 +828,9 @@ const DatabaseInitialization = props => { ...@@ -829,46 +828,9 @@ const DatabaseInitialization = props => {
onCheck(); onCheck();
}; };
const onChange1 = (e, item) => {
if (product[item]) {
// 过滤已初始化的产品但不存在于产品列表中的数据,避免组件出错
product[item].map(i => {
if (data[item].indexOf(i) == -1) {
product[item].splice(product[item].findIndex(j => j === i), 1);
}
});
let arr = product[item].find(i => e.indexOf(i) == -1);
let bb = keepProduct.indexOf(arr);
let aa = keepValue;
aa[item] = e;
let a = Object.keys(aa);
let list = [];
a.map(i => {
aa[i].map(j => {
list.push(j);
});
});
setKeepValue(aa);
setValue(list);
} else {
let aa = keepValue;
aa[item] = e;
let a = Object.keys(aa);
let list = [];
a.map(i => {
aa[i].map(j => {
list.push(j);
});
});
setKeepValue(aa);
setValue(list);
}
};
const onCheck = () => { const onCheck = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName) { if (obj.ip && obj.userName && obj.password && obj.dbName && obj.providerType) {
// setKeepValue([]); // setKeepValue([]);
setProduct([]); setProduct([]);
setCardLoading(true); setCardLoading(true);
...@@ -905,22 +867,6 @@ const DatabaseInitialization = props => { ...@@ -905,22 +867,6 @@ const DatabaseInitialization = props => {
setMsg('请输入完整数据库信息'); setMsg('请输入完整数据库信息');
} }
}; };
// 非授权模式下环境检查
const checkUnLicense = () => {
let obj = form.getFieldsValue();
let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password)
: obj.password;
CheckDatabaseIsExist({ ...obj, password: pwd }).then(res => {
setCardLoading(false);
if (res.code !== 0) {
setbeforeColor('red');
setResult(`${res.msg}`);
setMsg(res.msg);
}
});
};
const onCheckLaster = aa => { const onCheckLaster = aa => {
// 此时有授权码才能进入 // 此时有授权码才能进入
...@@ -959,10 +905,6 @@ const DatabaseInitialization = props => { ...@@ -959,10 +905,6 @@ const DatabaseInitialization = props => {
setAppend(''); setAppend('');
setAppendVisible(true); setAppendVisible(true);
setDataValue(form.getFieldsValue()); setDataValue(form.getFieldsValue());
// setbeforeColor('red');
// setResult('无法追加,该数据库为非授权初始化数据库,请直接升级数据库!');
// setMsg('无法追加,该数据库为非授权初始化数据库,请直接升级数据库!');
// setAppend('无需追加');
} }
} }
} else { } else {
...@@ -976,7 +918,7 @@ const DatabaseInitialization = props => { ...@@ -976,7 +918,7 @@ const DatabaseInitialization = props => {
const Submit = () => { const Submit = () => {
setAppendType('no'); setAppendType('no');
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName) { if (obj.ip && obj.userName && obj.password && obj.dbName && obj.providerType) {
let pwd = let pwd =
Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1 Decrypt(obj.password) === '' || Decrypt(obj.password).indexOf('\u0004') !== -1
? Encrypt(obj.password) ? Encrypt(obj.password)
...@@ -1035,12 +977,6 @@ const DatabaseInitialization = props => { ...@@ -1035,12 +977,6 @@ const DatabaseInitialization = props => {
setAppend(''); setAppend('');
setAppendVisible(true); setAppendVisible(true);
setDataValue(form.getFieldsValue()); setDataValue(form.getFieldsValue());
// setbeforeColor('red');
// setPassword(false);
// setResult('无法追加,该数据库为非授权初始化数据库,请直接升级数据库! ');
// setMsg('无法追加,该数据库为非授权初始化数据库,请直接升级数据库!');
// setAppend('无需追加');
// deleteInitDBLogNew();
} }
} else { } else {
setPassword(true); setPassword(true);
...@@ -1094,12 +1030,6 @@ const DatabaseInitialization = props => { ...@@ -1094,12 +1030,6 @@ const DatabaseInitialization = props => {
setAppend(''); setAppend('');
setAppendVisible(true); setAppendVisible(true);
setDataValue(form.getFieldsValue()); setDataValue(form.getFieldsValue());
// setbeforeColor('red');
// setPassword(false);
// setResult('无法追加,该数据库为非授权初始化数据库,请直接升级数据库! ');
// setMsg('无法追加,该数据库为非授权初始化数据库,请直接升级数据库!');
// setAppend('无需追加');
// deleteInitDBLogNew();
} }
} else { } else {
setPassword(true); setPassword(true);
...@@ -1135,17 +1065,6 @@ const DatabaseInitialization = props => { ...@@ -1135,17 +1065,6 @@ const DatabaseInitialization = props => {
} }
}, [initVisible]); }, [initVisible]);
const wirthValue = () => {
setResult('');
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
setSimpleProduct('');
setTotalProduct('');
form.setFieldsValue(keepInline);
};
const simple = e => { const simple = e => {
let aa = 0; let aa = 0;
if (keepValue && keepValue[e]) { if (keepValue && keepValue[e]) {
...@@ -1225,7 +1144,7 @@ const DatabaseInitialization = props => { ...@@ -1225,7 +1144,7 @@ const DatabaseInitialization = props => {
<div style={{ display: 'flex', alignItems: 'center', width: '100%' }}> <div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
<div style={{ width: '30%' }}> <div style={{ width: '30%' }}>
<Card> <Card>
<div style={{ height: 'calc(100vh - 101px)', paddingTop: '13px' }}> <div style={{ height: 'calc(100vh - 98px)', paddingTop: '13px' }}>
<Form <Form
className={styles.mgTop20} className={styles.mgTop20}
layout="horizontal" layout="horizontal"
...@@ -1234,6 +1153,25 @@ const DatabaseInitialization = props => { ...@@ -1234,6 +1153,25 @@ const DatabaseInitialization = props => {
form={form} form={form}
onValuesChange={onValuesChange} onValuesChange={onValuesChange}
> >
<Form.Item
label="数据库类型"
name="providerType"
rules={[
{
validator: (rule, value) => {
if (form.getFieldValue().providerType == '') {
return Promise.reject('ip必填');
}
return Promise.resolve();
},
},
]}
>
<Select placeholder="请选择数据库类型">
<Select.Option value="SqlServer">SqlServer</Select.Option>
<Select.Option value="Dm">Dm</Select.Option>
</Select>
</Form.Item>
<Form.Item <Form.Item
label={`${formLables.ip}:`} label={`${formLables.ip}:`}
name="ip" name="ip"
...@@ -1688,7 +1626,6 @@ const DatabaseInitialization = props => { ...@@ -1688,7 +1626,6 @@ const DatabaseInitialization = props => {
style={{ style={{
height: '470px', height: '470px',
overflowY: 'scroll', overflowY: 'scroll',
marginRight: ' -24px',
}} }}
> >
<Spin <Spin
...@@ -1749,7 +1686,6 @@ const DatabaseInitialization = props => { ...@@ -1749,7 +1686,6 @@ const DatabaseInitialization = props => {
style={{ style={{
maxHeight: '470px', maxHeight: '470px',
overflowY: 'auto', overflowY: 'auto',
marginRight: ' -24px',
}} }}
> >
{keepInitContent} {keepInitContent}
...@@ -1791,7 +1727,6 @@ const DatabaseInitialization = props => { ...@@ -1791,7 +1727,6 @@ const DatabaseInitialization = props => {
style={{ style={{
maxHeight: '470px', maxHeight: '470px',
overflowY: 'auto', overflowY: 'auto',
marginRight: ' -24px',
}} }}
> >
{keepInitContentDetail} {keepInitContentDetail}
...@@ -1878,7 +1813,6 @@ const DatabaseInitialization = props => { ...@@ -1878,7 +1813,6 @@ const DatabaseInitialization = props => {
style={{ style={{
maxHeight: '470px', maxHeight: '470px',
overflowY: 'auto', overflowY: 'auto',
marginRight: ' -24px',
}} }}
> >
{initContentdetail || ( {initContentdetail || (
......
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
Menu, Menu,
Empty, Empty,
Tabs, Tabs,
Modal,
} from 'antd'; } from 'antd';
import dengPao from '@/assets/images/icons/dengpao.png'; import dengPao from '@/assets/images/icons/dengpao.png';
import icon from '@/assets/images/icons/icon.png'; import icon from '@/assets/images/icons/icon.png';
...@@ -49,11 +50,13 @@ import { ...@@ -49,11 +50,13 @@ import {
getDataBaseConfigNew, getDataBaseConfigNew,
connectionTest, connectionTest,
changeSolution, changeSolution,
saveConnectionNew,
} from '@/services/database/api'; } from '@/services/database/api';
import ReactEcharts from 'echarts-for-react'; import ReactEcharts from 'echarts-for-react';
import { GetBasicInfo, GetGateWay } from '@/services/hostmanager/hostmanager'; import { GetBasicInfo, GetGateWay } from '@/services/hostmanager/hostmanager';
import { GetWebSiteConfig } from '@/services/gis/gis'; import { GetWebSiteConfig } from '@/services/gis/gis';
import { GetOMSDashboard, GetWayPages } from '@/services/homePage/api'; import { GetOMSDashboard, GetWayPages } from '@/services/homePage/api';
import DatabaseInitialization from '@/pages/database/databaseInitialization/DatabaseInitialization';
import { import {
GetVectorService, GetVectorService,
GetMaplayerByTerminalType, GetMaplayerByTerminalType,
...@@ -93,6 +96,7 @@ const HomePage = () => { ...@@ -93,6 +96,7 @@ const HomePage = () => {
const [loadingApi, setLoadingApi] = useState(false); const [loadingApi, setLoadingApi] = useState(false);
const [loadingDatabase, setLoadingDatabase] = useState(false); const [loadingDatabase, setLoadingDatabase] = useState(false);
const [loadingProduct, setLoadingProduct] = useState(false); const [loadingProduct, setLoadingProduct] = useState(false);
const [dataBaseVisible, setDataBaseVisible] = useState(false);
const [allTime, setAllTime] = useState([ const [allTime, setAllTime] = useState([
moment().startOf('month'), moment().startOf('month'),
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'), moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
...@@ -288,6 +292,7 @@ const HomePage = () => { ...@@ -288,6 +292,7 @@ const HomePage = () => {
}); });
} }
} else { } else {
setDataBaseVisible(true);
setState(false); setState(false);
notification.error({ notification.error({
message: '提示', message: '提示',
...@@ -829,6 +834,41 @@ const HomePage = () => { ...@@ -829,6 +834,41 @@ const HomePage = () => {
} }
}; };
// 数据库连接失败时弹窗系统初始化或跳转切换数据库连接界面
const onOk = value => {
// 在首页系统初始化完成直接保存连接刷新界面
saveConnectionNew({
ip: value.ip,
dbName: value.dbName,
userName: value.userName,
password: value.password,
providerType: value.providerType,
})
.then(resnew => {
if (resnew.code === 0) {
setFlag(flag + 1);
notification.success({
message: '提示',
duration: 3,
description: '保存成功',
});
} else {
notification.error({
message: '提示',
duration: 15,
description: resnew.msg,
});
}
})
.catch(err => {
notification.error({
message: '提示',
duration: 15,
description: err,
});
});
};
return ( return (
<div className={styles.homePage}> <div className={styles.homePage}>
<div className={styles.header}> <div className={styles.header}>
...@@ -1271,6 +1311,38 @@ const HomePage = () => { ...@@ -1271,6 +1311,38 @@ const HomePage = () => {
</Spin> </Spin>
</div> </div>
</div> </div>
<Modal
title={
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<div
style={{
width: '3px',
height: '15px',
backgroundColor: '#096dd9',
borderRadius: '10px',
marginRight: '10px',
}}
/>
<span>系统初始化</span>
</div>
<div style={{ marginRight: '30px', color: '#096dd9', fontSize: '12px' }}>
<span style={{ cursor: 'pointer' }} onClick={() => toDataCenter()}>
已有数据库?点击进行配置
</span>
</div>
</div>
}
visible={dataBaseVisible}
onCancel={() => setDataBaseVisible(false)}
width="1400px"
className={styles.dataBaseVisible}
footer={false}
maskClosable={false}
destroyOnClose={true}
>
<DatabaseInitialization callBackSubmit={onOk} visible={dataBaseVisible} />
</Modal>
</div> </div>
); );
}; };
......
...@@ -773,3 +773,14 @@ ...@@ -773,3 +773,14 @@
} }
} }
} }
.dataBaseVisible {
margin-top: -88px;
:global {
.ant-modal-body {
padding: 0;
}
.ant-modal-header {
height: 50px;
}
}
}
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