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

fix: '数据库初始化日志优化升级'

parent b66e2495
Pipeline #56790 waiting for manual action with stages
......@@ -866,7 +866,7 @@ const InitDataBase = props => {
</Button>
</Space>
<Space>
<Button
{/* <Button
type="primary"
// onClick={() => {
// getInitList();
......@@ -877,7 +877,7 @@ const InitDataBase = props => {
}}
>
数据库初始化
</Button>
</Button> */}
</Space>
</Space>
</div>
......
......@@ -52,7 +52,7 @@ InitDataBaseContainer {
.initItemData1 {
height: calc(100vh - 190px);
overflow: scroll;
// overflow: scroll;
.btnBox {
display: flex !important;
justify-content: flex-end;
......@@ -62,6 +62,11 @@ InitDataBaseContainer {
margin-bottom: 10px;
margin-left: 8px;
}
// .ant-checkbox-wrapper {
// width: 298px;
// margin-bottom: 10px;
// margin-left: 8px;
// }
.view:hover {
cursor: not-allowed;
}
......@@ -75,7 +80,7 @@ InitDataBaseContainer {
justify-content: flex-end;
}
.ant-checkbox-wrapper {
width: 350px;
width: 269px;
margin-bottom: 10px;
margin-left: 8px;
}
......
......@@ -7,7 +7,7 @@
* @Description:
* @Author: leizhe
* @Date: 2022-07-13 16:13:03
* @LastEditTime: 2022-07-28 19:24:59
* @LastEditTime: 2022-08-01 09:59:17
* @LastEditors: leizhe
*/
import React, { useState, useEffect } from 'react';
......@@ -323,12 +323,12 @@ const InitModal = props => {
</Button>,
]}
>
<div className={styles.initItemData1}>
<div>
{visible && (
<div>
<div className={styles.initItemData1}>
{title &&
title.map((item, index) => (
<div className={styles.cardItemData} key={index}>
<div key={index}>
<Divider
orientation="center"
style={{
......
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable no-else-return */
/* eslint-disable spaced-comment */
/* eslint-disable eqeqeq */
......@@ -12,11 +13,8 @@ import {
notification,
Modal,
Spin,
Tabs,
Divider,
Checkbox,
Row,
Col,
Popconfirm,
Timeline,
} from 'antd';
......@@ -65,7 +63,9 @@ const DatabaseInitialization = props => {
initVisible: false, // 初始化选择产品弹窗
}); // 修改弹窗
const [initVisible, setInitVisible] = useState(false); // 数据库初始化弹窗
const [initVisibledetail, setinitVisibledetail] = useState(false); // 数据库初始化详细信息弹窗
const [initContent, setInitContent] = useState(''); // 数据库初始化内容
const [initContentdetail, setInitContentdetail] = useState(''); // 数据库初始化详细内容
const [cardLoading, setCardLoading] = useState(false); // 初始化card Loading
const [finish, setFinish] = useState(false);
const [initLoading, setInitLoading] = useState(false);
......@@ -92,11 +92,14 @@ const DatabaseInitialization = props => {
const [keepMsg, setkeepMsg] = useState('');
const [keepState, setKeepState] = useState(0);
const [allLength, setAllLength] = useState('');
const [beforeColor, setbeforeColor] = useState('gray');
const [firstColor, setfirstColor] = useState('gray');
const [secordColor, setsecordColor] = useState('gray');
const [lastColor, setLastColor] = useState('gray');
const [totalProduct, setTotalProduct] = useState('');
const [simpleProduct, setSimpleProduct] = useState('');
const [loads, setLoads] = useState(true);
const [show, setShow] = useState('hidden');
// 获取数据库配置信息
useEffect(() => {
......@@ -105,11 +108,11 @@ const DatabaseInitialization = props => {
// form.setFieldsValue({ ip: '127.0.0.1', password: 'sa', userName: 'sa' });
GetDb();
}, []);
const getProductList = () => {
GetProductList().then(res => {
setCardLoading(false);
if (res.code === 0) {
console.log(res.data);
setKeepData(res.data);
let arr = formateArrDataA(res.data, 'productName');
let aa = Object.keys(arr);
......@@ -120,9 +123,6 @@ const DatabaseInitialization = props => {
});
arr[i] = list;
});
console.log(aa);
console.log(arr);
console.log(keepProduct);
setAllLength(res.data.length);
setTitle(aa);
setData(arr);
......@@ -179,7 +179,6 @@ const DatabaseInitialization = props => {
.then(res => {
if (res.code === 0) {
if (res.data.content) {
setInitLoading(false);
let arr = [];
arr.push(
res.data.content.split(/(\r\n)|(\n)/).map((item, index) => (
......@@ -196,7 +195,9 @@ const DatabaseInitialization = props => {
doInitLog();
}, 600);
} else {
setLoads(false);
setInitLoading(false);
setShow('visible');
if (time) {
clearTimeout(time);
time = null;
......@@ -209,6 +210,30 @@ const DatabaseInitialization = props => {
});
};
// 获取详细日志
const doInitLogdetali = () => {
getInitDBLogNew({ isAllInitDBLog: true })
.then(res => {
if (res.code === 0) {
if (res.data.content) {
let arr = [];
arr.push(
res.data.content.split(/(\r\n)|(\n)/).map((item, index) => (
// eslint-disable-next-line react/no-danger
<p key={index} dangerouslySetInnerHTML={{ __html: item }} />
)),
);
console.log(arr);
setInitContentdetail(arr);
scroll.current.scrollTop = scroll.current.scrollHeight;
}
}
})
.catch(err => {
console.log(err);
});
};
const onValuesChange = (value, b) => {
form.setFieldsValue(value);
};
......@@ -219,6 +244,18 @@ const DatabaseInitialization = props => {
});
};
const handlelook = () => {
setinitVisibledetail(true);
doInitLogdetali();
};
// 关闭弹窗
const handleClickdetail = () => {
setinitVisibledetail(false);
setInitContentdetail('');
setFinish(false);
};
// 关闭弹窗
const handleClick = () => {
setInitVisible(false);
......@@ -324,9 +361,9 @@ const DatabaseInitialization = props => {
if (res.data.DBExists) {
setCheckboxFlag(1);
setMsg('当前数据库已存在不可初始化');
notification.warning({
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: '当前数据库已存在不可初始化',
});
} else if (!res.data.DBExists && !res.data.Project[0]) {
......@@ -334,22 +371,22 @@ const DatabaseInitialization = props => {
setMsg('');
notification.warning({
message: '提示',
duration: 5,
duration: 3,
description: '未检测到License,自主选择产品进行数据库初始化',
});
} else if (!res.data.DBExists && res.data.Project[0]) {
setCheckboxFlag(1);
notification.success({
message: '提示',
duration: 5,
duration: 3,
description: '已检测到License,需初始化数据库',
});
setMsg('');
}
} else {
notification.warning({
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: res.msg,
});
}
......@@ -416,9 +453,9 @@ const DatabaseInitialization = props => {
setDbExists(res.data.DBExists);
setKeepDb(res.data);
} else {
notification.warning({
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: res.msg,
});
}
......@@ -434,7 +471,6 @@ const DatabaseInitialization = props => {
let productSetting = e;
let obj = form.getFieldsValue();
// 数据库存在调用编辑接口否则调用新增接口
setInitLoading(true);
handleShowModal('initVisible', false);
setInitVisible(true);
doInitLog();
......@@ -469,11 +505,7 @@ const DatabaseInitialization = props => {
// return;
// }
NewInitAddDataBase({ ...obj, productSetting }).then(res => {
setInitLoading(false);
if (res.code === 0) {
console.log(value);
console.log(keepProduct);
console.log(123231);
if (value.length > 0) {
setKeepProduct(value);
}
......@@ -488,7 +520,7 @@ const DatabaseInitialization = props => {
});
notification.success({
message: '提示',
duration: 5,
duration: 3,
description: '数据库初始化成功',
});
setkeepNumber('');
......@@ -504,7 +536,7 @@ const DatabaseInitialization = props => {
setLastColor('gray');
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: res.msg,
});
}
......@@ -512,7 +544,10 @@ const DatabaseInitialization = props => {
};
const flagChange = () => {
console.log(888);
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
setSimpleProduct('');
setTotalProduct('');
setValue('');
......@@ -520,7 +555,6 @@ const DatabaseInitialization = props => {
setKeepValue([]);
setProduct([]);
onCheck();
// deleteInitDBLogNew();
};
const onChange1 = (e, item) => {
......@@ -585,14 +619,15 @@ const DatabaseInitialization = props => {
if (res.code == 0) {
// 数据库不存在
if (res.data === false) {
setbeforeColor('green');
// 有授权码
if (keepNumber) {
setCheckboxFlag(1);
setDbExists(false);
setMsg('');
notification.warning({
notification.success({
message: '提示',
duration: 5,
duration: 3,
description: '已检测到License,需初始化数据库',
});
} else {
......@@ -601,16 +636,17 @@ const DatabaseInitialization = props => {
setMsg('');
notification.warning({
message: '提示',
duration: 5,
duration: 3,
description: '未检测到License,自主选择产品进行数据库初始化',
});
}
} else {
setbeforeColor('red');
setCheckboxFlag(1);
setMsg('当前数据库已存在不可初始化');
notification.warning({
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: '当前数据库已存在不可初始化',
});
}
......@@ -619,7 +655,7 @@ const DatabaseInitialization = props => {
setCheckboxFlag(1);
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: res.msg,
});
}
......@@ -631,38 +667,42 @@ const DatabaseInitialization = props => {
CheckDatabaseIsExist({ ...obj }).then(res => {
if (res.code === 0) {
if (res.data === true) {
setbeforeColor('red');
GetDbChange();
deleteInitDBLogNew();
setCheckboxFlag(1);
setMsg('当前数据库已存在不可初始化');
notification.warning({
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: '当前数据库已存在不可初始化',
});
} else {
setbeforeColor('green');
setDbExists(false);
setMsg('');
if (msg) {
notification.warning({
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: '当前数据库不可初始化',
});
} else if (obj.ip == '' || obj.userName == '' || obj.password == '' || obj.dbName == '') {
notification.warning({
message: '提示',
duration: 5,
duration: 3,
description: '请输入完整数据库信息',
});
} else if (checkboxFlag == 0 && value.length == 0) {
notification.warning({
message: '提示',
duration: 5,
duration: 3,
description: '请勾选产品',
});
} else if (checkboxFlag == 1 && keepProduct.length == 0) {
notification.warning({
message: '提示',
duration: 5,
duration: 3,
description: '请勾选产品',
});
} else {
......@@ -690,7 +730,7 @@ const DatabaseInitialization = props => {
setCheckboxFlag(1);
notification.error({
message: '提示',
duration: 5,
duration: 3,
description: res.msg,
});
}
......@@ -701,16 +741,16 @@ const DatabaseInitialization = props => {
};
const save = () => {
if (
form.getFieldValue().ip &&
form.getFieldValue().userName &&
form.getFieldValue().password &&
form.getFieldValue().dbName
) {
flagChange();
}
flagChange();
};
useEffect(() => {
if (!initVisible) {
setLoads(true);
setShow('hidden');
}
}, [initVisible]);
return (
<>
<PageContainer className={styles.InitDataBaseContainer}>
......@@ -735,6 +775,7 @@ const DatabaseInitialization = props => {
if (form.getFieldValue().ip == '') {
return Promise.reject('ip必填');
}
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -754,6 +795,7 @@ const DatabaseInitialization = props => {
if (form.getFieldValue().userName == '') {
return Promise.reject('用户名称必填');
}
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -774,6 +816,7 @@ const DatabaseInitialization = props => {
if (form.getFieldValue().password == '') {
return Promise.reject('用户密码必填');
}
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -797,6 +840,7 @@ const DatabaseInitialization = props => {
) {
return Promise.reject('数据库名称必填');
}
setbeforeColor('gray');
setfirstColor('gray');
setsecordColor('gray');
setLastColor('gray');
......@@ -813,6 +857,7 @@ const DatabaseInitialization = props => {
</div>
<div style={{ marginTop: '100px', transform: 'scal(1.5)' }}>
<Timeline>
<Timeline.Item color={beforeColor}>环境检查通过</Timeline.Item>
<Timeline.Item color={firstColor}>数据库初始化完成</Timeline.Item>
<Timeline.Item color={secordColor}>
<p>产品授权打开已初始化的产品</p>
......@@ -880,7 +925,7 @@ const DatabaseInitialization = props => {
<div className={styles1.initItemData}>
{title &&
title.map((item, index) => (
<div key={index}>
<div key={index} style={{ marginBottom: '10px' }}>
<Divider
orientation="center"
style={{
......@@ -954,12 +999,21 @@ const DatabaseInitialization = props => {
// overflowY: 'auto',
}}
footer={[
<Button
style={{ visibility: show }}
onClick={() => {
handlelook();
}}
>
查看详细信息
</Button>,
<Button
onClick={() => {
handleClick();
}}
key="back"
type="primary"
loading={initLoading}
>
关闭窗口
</Button>,
......@@ -973,12 +1027,50 @@ const DatabaseInitialization = props => {
marginRight: ' -24px',
}}
>
{initContent || (
<Spin
spinning={initLoading}
tip="loading..."
style={{ width: '100%', marginTop: '40px' }}
/>
{initContent}
</div>
<div style={{ position: 'relative' }}>
<Spin
spinning={initLoading}
tip="loading..."
style={{ width: '100%', marginTop: '40px' }}
/>
</div>
</Modal>
<Modal
title="初始化数据库详细日志"
visible={initVisibledetail}
onCancel={() => {
setinitVisibledetail(false);
setInitContentdetail('');
}}
width={900}
maskClosable={false}
bodyStyle={{
height: '600px',
// overflowY: 'auto',
}}
footer={[
<Button
onClick={() => {
handleClickdetail();
}}
key="back"
>
关闭窗口
</Button>,
]}
>
<div
ref={scroll}
style={{
maxHeight: '560px',
overflowY: 'auto',
marginRight: ' -24px',
}}
>
{initContentdetail || (
<Spin tip="loading..." style={{ width: '100%', marginTop: '40px' }} />
)}
</div>
</Modal>
......
......@@ -2,7 +2,7 @@
* @Description:
* @Author: leizhe
* @Date: 2022-01-13 17:26:14
* @LastEditTime: 2022-03-22 16:22:07
* @LastEditTime: 2022-08-02 14:10:39
* @LastEditors: leizhe
*/
import React, { useState } from 'react';
......@@ -27,7 +27,7 @@ const AddModal = props => {
})
.then(res => {
setLoading(false);
if (res.msg === '') {
if (res.code === 0) {
form.resetFields();
notification.success({
message: '通知',
......@@ -39,7 +39,7 @@ const AddModal = props => {
notification.error({
message: '提示',
duration: 3,
description: res.message,
description: res.msg,
});
}
})
......
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