Commit a91c5070 authored by 皮倩雯's avatar 皮倩雯

fix: '数据库初始化优化'

parent 11a84781
Pipeline #57557 passed with stages
...@@ -106,6 +106,7 @@ const DatabaseInitialization = props => { ...@@ -106,6 +106,7 @@ 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('');
...@@ -358,12 +359,16 @@ const DatabaseInitialization = props => { ...@@ -358,12 +359,16 @@ const DatabaseInitialization = props => {
setKeepDb(res.data); setKeepDb(res.data);
setIsAuthorize(res.data.IsAuthorize); setIsAuthorize(res.data.IsAuthorize);
if (res.data.IsAuthorize) { if (res.data.IsAuthorize) {
setOldColor('green'); setMsg('');
} else { } else {
if (res.data.Project && res.data.Project[0]) { if (res.data.Project && res.data.Project[0]) {
setOldColor('#eda625'); setbeforeColor('red');
setResult('检测到License已被使用');
setMsg('检测到License已被使用');
} else { } else {
setOldColor('red'); setbeforeColor('red');
setResult('未检测到License');
setMsg('未检测到License');
} }
} }
// if (res.data.DBExists) { // if (res.data.DBExists) {
...@@ -401,18 +406,28 @@ const DatabaseInitialization = props => { ...@@ -401,18 +406,28 @@ const DatabaseInitialization = props => {
}); });
}; };
const GetDbChange = () => { const GetDbChange = e => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
setCardLoading(true);
GetDbProduct({ ...obj }).then(res => { GetDbProduct({ ...obj }).then(res => {
onCheckLaster(); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
if (res.data.IsAuthorize) { if (res.data.IsAuthorize) {
setOldColor('green'); // setMsg('');
if (e) {
findCheck();
} else {
onCheckLaster();
}
} else { } else {
if (res.data.Project && res.data.Project[0]) { if (res.data.Project && res.data.Project[0]) {
setOldColor('#eda625'); setbeforeColor('red');
setResult('检测到License已被使用');
setMsg('检测到License已被使用');
} else { } else {
setOldColor('red'); setbeforeColor('red');
setResult('未检测到License');
setMsg('未检测到License');
} }
} }
if (res.data.Project && res.data.Project.length > 0) { if (res.data.Project && res.data.Project.length > 0) {
...@@ -431,12 +446,13 @@ const DatabaseInitialization = props => { ...@@ -431,12 +446,13 @@ const DatabaseInitialization = props => {
res.data.Product.map(i => { res.data.Product.map(i => {
aa.push(i.name); aa.push(i.name);
}); });
if (res.data.IsAuthorize || res.data.DBExists) {
setCheckboxFlag(1);
} else {
setCheckboxFlag(0);
}
console.log(aa); console.log(aa);
// if (res.data.IsAuthorize || res.data.DBExists) {
// setCheckboxFlag(1);
// } else {
// setCheckboxFlag(0);
// }
// console.log(aa);
if (aa.length > 0) { if (aa.length > 0) {
let dd = []; let dd = [];
aa.map(i => { aa.map(i => {
...@@ -446,9 +462,13 @@ const DatabaseInitialization = props => { ...@@ -446,9 +462,13 @@ const DatabaseInitialization = props => {
} }
}); });
}); });
console.log(dd);
let Arr = Array.from(new Set(dd)); let Arr = Array.from(new Set(dd));
console.log(Arr);
let arr = formateArrDataA(Arr, 'productName'); let arr = formateArrDataA(Arr, 'productName');
console.log(arr);
let a = Object.keys(arr); let a = Object.keys(arr);
console.log(a);
a.map(i => { a.map(i => {
let list = []; let list = [];
arr[i].map(j => { arr[i].map(j => {
...@@ -461,6 +481,7 @@ const DatabaseInitialization = props => { ...@@ -461,6 +481,7 @@ const DatabaseInitialization = props => {
setKeepValue(arr); setKeepValue(arr);
} }
let newArr = Array.from(new Set(aa)); let newArr = Array.from(new Set(aa));
console.log(aa);
// 当前数据库已存在和上一个已存在数据库值重新赋值 // 当前数据库已存在和上一个已存在数据库值重新赋值
if (newArr.length > 0 || dbExists) { if (newArr.length > 0 || dbExists) {
setKeepProduct(newArr); setKeepProduct(newArr);
...@@ -531,8 +552,10 @@ const DatabaseInitialization = props => { ...@@ -531,8 +552,10 @@ const DatabaseInitialization = props => {
if (value.length > 0) { if (value.length > 0) {
setKeepProduct(value); setKeepProduct(value);
} }
setMsg('当前数据库已存在不可初始化'); // setMsg('当前数据库已存在不可初始化');
setOldColor('#eda625'); setbeforeColor('red');
setResult('检测到License已被使用');
setMsg('检测到License已被使用');
setCheckboxFlag(1); setCheckboxFlag(1);
setfirstColor('green'); setfirstColor('green');
...@@ -646,7 +669,6 @@ const DatabaseInitialization = props => { ...@@ -646,7 +669,6 @@ const DatabaseInitialization = props => {
setProduct([]); setProduct([]);
GetDbChange(); GetDbChange();
deleteInitDBLogNew(); deleteInitDBLogNew();
setCardLoading(true);
} else { } else {
setbeforeColor('red'); setbeforeColor('red');
setResult('请输入完整数据库信息'); setResult('请输入完整数据库信息');
...@@ -656,6 +678,7 @@ const DatabaseInitialization = props => { ...@@ -656,6 +678,7 @@ const DatabaseInitialization = props => {
}; };
const onCheckLaster = () => { const onCheckLaster = () => {
let obj = form.getFieldsValue(); let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj }).then(res => { CheckDatabaseIsExist({ ...obj }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code == 0) { if (res.code == 0) {
...@@ -695,7 +718,18 @@ const DatabaseInitialization = props => { ...@@ -695,7 +718,18 @@ const DatabaseInitialization = props => {
const Submit = () => { const Submit = () => {
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) {
GetDbChange(1);
setCardLoading(true); setCardLoading(true);
} else {
setbeforeColor('red');
setResult('请输入完整数据库信息');
setMsg('请输入完整数据库信息');
setCheckboxFlag(1);
}
};
const findCheck = () => {
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj }).then(res => { CheckDatabaseIsExist({ ...obj }).then(res => {
setCardLoading(false); setCardLoading(false);
if (res.code === 0) { if (res.code === 0) {
...@@ -703,10 +737,10 @@ const DatabaseInitialization = props => { ...@@ -703,10 +737,10 @@ const DatabaseInitialization = props => {
setbeforeColor('red'); setbeforeColor('red');
setPassword(false); setPassword(false);
setResult('当前数据库已存在 '); setResult('当前数据库已存在 ');
GetDbChange(); setMsg('当前数据库已存在');
deleteInitDBLogNew(); deleteInitDBLogNew();
setCheckboxFlag(1); setCheckboxFlag(1);
setMsg('当前数据库已存在');
} else { } else {
setPassword(true); setPassword(true);
setbeforeColor('green'); setbeforeColor('green');
...@@ -750,12 +784,6 @@ const DatabaseInitialization = props => { ...@@ -750,12 +784,6 @@ const DatabaseInitialization = props => {
setCheckboxFlag(1); setCheckboxFlag(1);
} }
}); });
} else {
setbeforeColor('red');
setResult('请输入完整数据库信息');
setMsg('请输入完整数据库信息');
setCheckboxFlag(1);
}
}; };
const save = () => { const save = () => {
...@@ -927,7 +955,7 @@ const DatabaseInitialization = props => { ...@@ -927,7 +955,7 @@ const DatabaseInitialization = props => {
</div> </div>
<div style={{ marginTop: '100px', transform: 'scal(1.5)' }}> <div style={{ marginTop: '100px', transform: 'scal(1.5)' }}>
<Timeline> <Timeline>
<Timeline.Item color={oldColor}> {/* <Timeline.Item color={oldColor}>
License检测 License检测
{(() => { {(() => {
switch (oldColor) { switch (oldColor) {
...@@ -948,7 +976,7 @@ const DatabaseInitialization = props => { ...@@ -948,7 +976,7 @@ const DatabaseInitialization = props => {
style={{ color: '#eda625', marginLeft: '10px' }} style={{ color: '#eda625', marginLeft: '10px' }}
/> />
<span style={{ color: 'rgb(24 144 255)', marginLeft: '10px' }}> <span style={{ color: 'rgb(24 144 255)', marginLeft: '10px' }}>
检测到License已被使用 {license}
</span> </span>
</> </>
); );
...@@ -957,13 +985,13 @@ const DatabaseInitialization = props => { ...@@ -957,13 +985,13 @@ const DatabaseInitialization = props => {
<> <>
<CloseCircleOutlined style={{ color: 'red', marginLeft: '10px' }} /> <CloseCircleOutlined style={{ color: 'red', marginLeft: '10px' }} />
<span style={{ color: 'rgb(24 144 255)', marginLeft: '5px' }}> <span style={{ color: 'rgb(24 144 255)', marginLeft: '5px' }}>
未检测到License {license}
</span> </span>
</> </>
); );
} }
})()} })()}
</Timeline.Item> </Timeline.Item> */}
<Timeline.Item color={beforeColor}> <Timeline.Item color={beforeColor}>
环境检查 环境检查
{(() => { {(() => {
...@@ -1175,7 +1203,7 @@ const DatabaseInitialization = props => { ...@@ -1175,7 +1203,7 @@ const DatabaseInitialization = props => {
<Space size="large" className={styles.btnBox}> <Space size="large" className={styles.btnBox}>
<Popconfirm <Popconfirm
placement="topLeft" placement="topLeft"
disabled={isAuthorize && msg == '' ? false : true} disabled={msg == '' ? false : true}
title={<span style={{ color: 'rgb(24 144 255)' }}>是否确认初始化!</span>} title={<span style={{ color: 'rgb(24 144 255)' }}>是否确认初始化!</span>}
okText="确认" okText="确认"
cancelText="取消" cancelText="取消"
...@@ -1184,12 +1212,12 @@ const DatabaseInitialization = props => { ...@@ -1184,12 +1212,12 @@ const DatabaseInitialization = props => {
deleteInitDBLogNew(); deleteInitDBLogNew();
}} }}
> >
{/* <Button type="primary" disabled={msg == '' ? false : true}> <Button type="primary" disabled={msg == '' ? false : true}>
数据库初始化
</Button> */}
<Button type="primary" disabled={isAuthorize && msg == '' ? false : true}>
初始化 初始化
</Button> </Button>
{/* <Button type="primary" disabled={isAuthorize && msg == '' ? false : true}>
初始化
</Button> */}
</Popconfirm> </Popconfirm>
</Space> </Space>
</div> </div>
......
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