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

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

parent 325eef2c
Pipeline #57759 passed with stages
......@@ -7,7 +7,7 @@
* @Description:
* @Author: leizhe
* @Date: 2022-07-13 16:13:03
* @LastEditTime: 2022-08-01 09:59:17
* @LastEditTime: 2022-08-16 09:59:34
* @LastEditors: leizhe
*/
import React, { useState, useEffect } from 'react';
......@@ -67,48 +67,47 @@ const InitModal = props => {
}, [listVisible]);
const getProductList = () => {
GetProductList().then(res => {
if (res.code === 0) {
setKeepData(res.data);
if (keepProduct.length > 0) {
let dd = [];
keepProduct.map(i => {
res.data.map(j => {
if (j.name === i) {
dd.push(j);
}
});
});
let arr = formateArrDataA(dd, 'productName');
let aa = Object.keys(arr);
aa.map(i => {
let list = [];
arr[i].map(j => {
list.push(j.name);
});
arr[i] = list;
});
console.log(arr);
setProduct(arr);
setKeepValue(arr);
}
let arr = formateArrDataA(res.data, 'productName');
let aa = Object.keys(arr);
aa.map(i => {
let list = [];
arr[i].map(j => {
list.push(j.name);
});
arr[i] = list;
});
console.log(aa);
console.log(arr);
console.log(keepProduct);
setTitle(aa);
setData(arr);
}
});
// GetProductList().then(res => {
// if (res.code === 0) {
// setKeepData(res.data);
// if (keepProduct.length > 0) {
// let dd = [];
// keepProduct.map(i => {
// res.data.map(j => {
// if (j.name === i) {
// dd.push(j);
// }
// });
// });
// let arr = formateArrDataA(dd, 'productName');
// let aa = Object.keys(arr);
// aa.map(i => {
// let list = [];
// arr[i].map(j => {
// list.push(j.name);
// });
// arr[i] = list;
// });
// console.log(arr);
// setProduct(arr);
// setKeepValue(arr);
// }
// let arr = formateArrDataA(res.data, 'productName');
// let aa = Object.keys(arr);
// aa.map(i => {
// let list = [];
// arr[i].map(j => {
// list.push(j.name);
// });
// arr[i] = list;
// });
// console.log(aa);
// console.log(arr);
// console.log(keepProduct);
// setTitle(aa);
// setData(arr);
// }
// });
};
const formateArrDataA = (initialArr, name) => {
......
......@@ -115,6 +115,7 @@ const DatabaseInitialization = props => {
const [isAuthorize, setIsAuthorize] = useState(false);
const [licen, setLicen] = useState('');
const [showDetali, setShowDetali] = useState(false);
const [keepLast, setKeepLast] = useState('');
// 获取数据库配置信息
useEffect(() => {
......@@ -408,7 +409,6 @@ const DatabaseInitialization = props => {
const GetDbChange = e => {
let obj = form.getFieldsValue();
setCardLoading(true);
GetDbProduct({ ...obj }).then(res => {
setCardLoading(false);
if (res.code === 0) {
......@@ -552,18 +552,12 @@ const DatabaseInitialization = props => {
if (value.length > 0) {
setKeepProduct(value);
}
// setMsg('当前数据库已存在不可初始化');
setbeforeColor('red');
setResult('检测到License已被使用');
// setbeforeColor('red');
// setResult('检测到License已被使用');
setMsg('检测到License已被使用');
setCheckboxFlag(1);
setfirstColor('green');
SetAdminMenuToRole().then(resdata => {
if (resdata.code === 0) {
setLastColor('green');
}
});
setDataResult('成功');
notification.success({
message: '提示',
......@@ -578,7 +572,6 @@ const DatabaseInitialization = props => {
// setkeepMsg('');
// setkeepCo('');
if (res.data.productPackageCount == 0) {
console.log(1212);
setProductResult('产品授权不包含已初始化的产品');
setsecordColor('#eda625');
} else {
......@@ -586,6 +579,15 @@ const DatabaseInitialization = props => {
}
setTotalProduct(res.data.productPackageSumCount);
setSimpleProduct(res.data.productPackageCount);
SetAdminMenuToRole().then(resdata => {
if (resdata.code === 0) {
setLastColor('green');
setKeepLast('');
} else {
setLastColor('red');
setKeepLast(res.data.msg);
}
});
} else {
setDataResult(res.msg);
setFinish(true);
......@@ -667,7 +669,31 @@ const DatabaseInitialization = props => {
if (obj.ip && obj.userName && obj.password && obj.dbName) {
// setKeepValue([]);
setProduct([]);
GetDbChange();
setCardLoading(true);
GetProductList({ ...obj }).then(res => {
if (res.code === 0) {
console.log(res.data);
GetDbChange();
setKeepData(res.data);
let arr = formateArrDataA(res.data, 'productName');
let aa = Object.keys(arr);
aa.map(i => {
let list = [];
arr[i].map(j => {
list.push(j.name);
});
arr[i] = list;
});
setAllLength(res.data.length);
console.log(arr);
console.log(aa);
setTitle(aa);
setData(arr);
} else {
setCardLoading(false);
}
});
deleteInitDBLogNew();
} else {
setbeforeColor('red');
......@@ -718,7 +744,29 @@ const DatabaseInitialization = props => {
const Submit = () => {
let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName) {
GetDbChange(1);
GetProductList({ ...obj }).then(res => {
setCardLoading(false);
if (res.code === 0) {
console.log(res.data);
GetDbChange(1);
setKeepData(res.data);
let arr = formateArrDataA(res.data, 'productName');
let aa = Object.keys(arr);
aa.map(i => {
let list = [];
arr[i].map(j => {
list.push(j.name);
});
arr[i] = list;
});
setAllLength(res.data.length);
console.log(arr);
console.log(aa);
setTitle(aa);
setData(arr);
}
});
setCardLoading(true);
} else {
setbeforeColor('red');
......@@ -1090,18 +1138,33 @@ const DatabaseInitialization = props => {
</Timeline.Item>
<Timeline.Item color={lastColor}>
<span>平台管理员赋权使用</span>
{lastColor == 'green' ? (
<>
<CheckCircleOutlined style={{ color: 'green', marginLeft: '10px' }} />
<br />
<spsn>登录名:panda</spsn>
<br />
{password ? <span>初始密码:panda666</span> : <></>}
</>
) : (
<></>
)}
{(() => {
switch (lastColor) {
case 'gray':
return <></>;
case 'green':
return (
<>
<CheckCircleOutlined
style={{ color: 'green', marginLeft: '10px' }}
/>
<br />
<spsn>登录名:panda</spsn>
<br />
{password ? <span>初始密码:panda666</span> : <></>}
</>
);
default:
return (
<>
<CloseCircleOutlined style={{ color: 'red', marginLeft: '10px' }} />
<span style={{ color: 'rgb(24 144 255)', marginLeft: '5px' }}>
{keepLast}
</span>
</>
);
}
})()}
</Timeline.Item>
</Timeline>
</div>
......
......@@ -190,7 +190,7 @@ export const AddUserAuthSetting = params =>
export const GetUserAuthSet = params => get(`${PUBLISH_SERVICE}/WebSite/GetUserAuthSet`, params);
// 获取产品列表
export const GetProductList = params => get(`${PUBLISH_SERVICE}/DBManager/GetProductList`, params);
export const GetProductList = params => post(`${PUBLISH_SERVICE}/DBManager/GetProductList`, params);
// 获取产品列表清单
export const GetProductListByLicense = params =>
get(`${PUBLISH_SERVICE}/DBManager/GetProductListByLicense`, params);
......
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