Commit 98fc1424 authored by 皮倩雯's avatar 皮倩雯

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

parent 4da9285c
Pipeline #56953 failed with stages
......@@ -100,6 +100,8 @@ const DatabaseInitialization = props => {
const [simpleProduct, setSimpleProduct] = useState('');
const [loads, setLoads] = useState(true);
const [show, setShow] = useState('hidden');
const [keepInline, setKeepInline] = useState([]);
const [ifInline, setIfInline] = useState('hidden');
// 获取数据库配置信息
useEffect(() => {
......@@ -237,12 +239,6 @@ const DatabaseInitialization = props => {
const onValuesChange = (value, b) => {
form.setFieldsValue(value);
};
const onChange = value => {
const { length } = value;
form.setFieldsValue({
dbName: value[length - 1],
});
};
const handlelook = () => {
setinitVisibledetail(true);
......@@ -261,47 +257,18 @@ const DatabaseInitialization = props => {
setInitVisible(false);
setInitContent('');
setFinish(false);
// deleteInitDBLog({
// _version: 9999,
// _dc: Date.now(),
// });
deleteInitDBLogNew();
};
// 获取数据库列表
const selectFocus = e => {
//setOption([]);
let params = form.getFieldsValue();
getDataBaseList({
// _version: 9999,
// _dc: Date.now(),
userName: params.userName || '',
password: params.password || '',
ip: params.ip || '',
})
.then(res => {
if (res.code == 0) {
console.log(res.data.root);
setOption(res.data.root);
} else {
notification.error({
message: '提示',
duration: 15,
description: res.msg,
});
setOption([]);
}
})
.catch(err => {
console.error(err);
});
};
const GetDb = () => {
// let obj = form.getFieldsValue();
GetDbProduct().then(res => {
if (res.code === 0) {
form.setFieldsValue(res.data.DbInfo);
if (res.data.DbInfo.ip == '127.0.0.1' || !res.data.DbInfo.ip) {
setIfInline('hidden');
} else {
setIfInline('visible');
}
setKeepInline(res.data.DbInfo);
if (res.data.Project[0]) {
setkeepNumber(res.data.Project[0].license);
setkeepMsg(res.data.Project[0].projectName);
......@@ -313,6 +280,8 @@ const DatabaseInitialization = props => {
setkeepNa('');
setkeepCo('');
}
// 有License的情况下首次进入展示数据
if (res.data.IsAuthorize) {
if (res.data.Product) {
let aa = [];
res.data.Product.map(i => {
......@@ -323,7 +292,6 @@ const DatabaseInitialization = props => {
} else {
setCheckboxFlag(0);
}
console.log(aa);
if (aa.length > 0) {
let dd = [];
aa.map(i => {
......@@ -333,9 +301,7 @@ const DatabaseInitialization = props => {
}
});
});
console.log(dd);
let Arr = Array.from(new Set(dd));
console.log(Arr);
let arr = formateArrDataA(Arr, 'productName');
let a = Object.keys(arr);
a.map(i => {
......@@ -345,11 +311,10 @@ const DatabaseInitialization = props => {
});
arr[i] = list;
});
console.log(arr);
setProduct(arr);
setKeepValue(arr);
}
console.log(newArr);
let newArr = Array.from(new Set(aa));
setKeepProduct(newArr);
setKeepCode(newArr);
......@@ -357,32 +322,33 @@ const DatabaseInitialization = props => {
}
setDbExists(res.data.DBExists);
setKeepDb(res.data);
if (res.data.DBExists) {
setCheckboxFlag(1);
setMsg('当前数据库已存在不可初始化');
notification.error({
message: '提示',
duration: 3,
description: '当前数据库已存在不可初始化',
});
} else if (!res.data.DBExists && !res.data.Project[0]) {
setCheckboxFlag(0);
setMsg('');
notification.warning({
message: '提示',
duration: 3,
description: '未检测到License,自主选择产品进行数据库初始化',
});
} else if (!res.data.DBExists && res.data.Project[0]) {
setCheckboxFlag(1);
notification.success({
message: '提示',
duration: 3,
description: '已检测到License,需初始化数据库',
});
setMsg('');
}
// if (res.data.DBExists) {
// setCheckboxFlag(1);
// setMsg('当前数据库已存在不可初始化');
// notification.error({
// message: '提示',
// duration: 3,
// description: '当前数据库已存在不可初始化',
// });
// } else if (!res.data.DBExists && !res.data.Project[0]) {
// setCheckboxFlag(0);
// setMsg('');
// notification.warning({
// message: '提示',
// duration: 3,
// description: '未检测到License,自主选择产品进行数据库初始化',
// });
// } else if (!res.data.DBExists && res.data.Project[0]) {
// setCheckboxFlag(1);
// notification.success({
// message: '提示',
// duration: 3,
// description: '已检测到License,需初始化数据库',
// });
// setMsg('');
// }
} else {
notification.error({
message: '提示',
......@@ -418,7 +384,6 @@ const DatabaseInitialization = props => {
} else {
setCheckboxFlag(0);
}
console.log(aa);
if (aa.length > 0) {
let dd = [];
aa.map(i => {
......@@ -428,9 +393,7 @@ const DatabaseInitialization = props => {
}
});
});
console.log(dd);
let Arr = Array.from(new Set(dd));
console.log(Arr);
let arr = formateArrDataA(Arr, 'productName');
let a = Object.keys(arr);
a.map(i => {
......@@ -440,16 +403,17 @@ const DatabaseInitialization = props => {
});
arr[i] = list;
});
console.log(arr);
setProduct(arr);
setKeepValue(arr);
}
console.log(newArr);
let newArr = Array.from(new Set(aa));
// 当前数据库已存在和上一个已存在数据库值重新赋值
if (newArr.length > 0 || dbExists) {
setKeepProduct(newArr);
setKeepCode(newArr);
setValue(newArr);
}
}
setDbExists(res.data.DBExists);
setKeepDb(res.data);
} else {
......@@ -523,6 +487,7 @@ const DatabaseInitialization = props => {
duration: 3,
description: '数据库初始化成功',
});
setDbExists(true);
setkeepNumber('');
setkeepNa('');
setkeepMsg('');
......@@ -550,10 +515,10 @@ const DatabaseInitialization = props => {
setLastColor('gray');
setSimpleProduct('');
setTotalProduct('');
setValue('');
setKeepProduct([]);
setKeepValue([]);
setProduct([]);
// setValue([]);
// setKeepProduct([]);
onCheck();
};
......@@ -609,6 +574,10 @@ const DatabaseInitialization = props => {
}
};
useEffect(() => {
console.log(value);
}, [value]);
const onCheck = () => {
let obj = form.getFieldsValue();
GetDbChange();
......@@ -623,7 +592,7 @@ const DatabaseInitialization = props => {
// 有授权码
if (keepNumber) {
setCheckboxFlag(1);
setDbExists(false);
// setDbExists(false);
setMsg('');
notification.success({
message: '提示',
......@@ -632,7 +601,7 @@ const DatabaseInitialization = props => {
});
} else {
setCheckboxFlag(0);
setDbExists(false);
// setDbExists(false);
setMsg('');
notification.warning({
message: '提示',
......@@ -640,6 +609,7 @@ const DatabaseInitialization = props => {
description: '未检测到License,自主选择产品进行数据库初始化',
});
}
console.log(value);
} else {
setbeforeColor('red');
setCheckboxFlag(1);
......@@ -679,21 +649,9 @@ const DatabaseInitialization = props => {
});
} else {
setbeforeColor('green');
setDbExists(false);
// setDbExists(false);
setMsg('');
if (msg) {
notification.error({
message: '提示',
duration: 3,
description: '当前数据库不可初始化',
});
} else if (obj.ip == '' || obj.userName == '' || obj.password == '' || obj.dbName == '') {
notification.warning({
message: '提示',
duration: 3,
description: '请输入完整数据库信息',
});
} else if (checkboxFlag == 0 && value.length == 0) {
if (checkboxFlag == 0 && value.length == 0) {
notification.warning({
message: '提示',
duration: 3,
......@@ -706,7 +664,6 @@ const DatabaseInitialization = props => {
description: '请勾选产品',
});
} else {
console.log(value);
let arr = [];
if (checkboxFlag == 0) {
keepData.map(i => {
......@@ -721,7 +678,6 @@ const DatabaseInitialization = props => {
}
});
}
console.log(arr);
onOK(arr, code);
}
}
......@@ -735,9 +691,6 @@ const DatabaseInitialization = props => {
});
}
});
// callBackSubmit(arr, code);
// onCancel();
};
const save = () => {
......@@ -751,6 +704,10 @@ const DatabaseInitialization = props => {
}
}, [initVisible]);
const wirthValue = () => {
form.setFieldsValue(keepInline);
};
return (
<>
<PageContainer className={styles.InitDataBaseContainer}>
......@@ -772,9 +729,13 @@ const DatabaseInitialization = props => {
rules={[
{
validator: (rule, value) => {
let regCn = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/;
if (form.getFieldValue().ip == '') {
return Promise.reject('ip必填');
}
if (!regCn.test(form.getFieldValue().ip)) {
return Promise.reject('ip格式不正确');
}
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
......@@ -853,6 +814,12 @@ const DatabaseInitialization = props => {
</Form.Item>
</Form>
<div style={{ float: 'right' }}>
<Button
style={{ marginRight: '20px', visibility: ifInline }}
onClick={wirthValue}
>
当前数据库
</Button>
<Button onClick={save}>环境检查</Button>
</div>
<div style={{ marginTop: '100px', transform: 'scal(1.5)' }}>
......
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