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

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

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