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

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

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