Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CivManage
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
CivManage
Commits
98fc1424
Commit
98fc1424
authored
Aug 05, 2022
by
皮倩雯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: '数据库初始化优化'
parent
4da9285c
Pipeline
#56953
failed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
137 deletions
+104
-137
DatabaseInitialization.jsx
...atabase/databaseInitialization/DatabaseInitialization.jsx
+104
-137
No files found.
src/pages/database/databaseInitialization/DatabaseInitialization.jsx
View file @
98fc1424
...
...
@@ -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,76 +280,75 @@ const DatabaseInitialization = props => {
setkeepNa
(
''
);
setkeepCo
(
''
);
}
if
(
res
.
data
.
Product
)
{
let
aa
=
[];
res
.
data
.
Product
.
map
(
i
=>
{
aa
.
push
(
i
.
name
);
});
if
(
res
.
data
.
IsAuthorize
)
{
setCheckboxFlag
(
1
);
}
else
{
setCheckboxFlag
(
0
);
}
console
.
log
(
aa
);
if
(
aa
.
length
>
0
)
{
let
dd
=
[];
aa
.
map
(
i
=>
{
keepData
.
map
(
j
=>
{
if
(
j
.
name
===
i
)
{
dd
.
push
(
j
);
}
});
// 有License的情况下首次进入展示数据
if
(
res
.
data
.
IsAuthorize
)
{
if
(
res
.
data
.
Product
)
{
let
aa
=
[];
res
.
data
.
Product
.
map
(
i
=>
{
aa
.
push
(
i
.
name
);
});
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
=>
{
let
list
=
[];
arr
[
i
].
map
(
j
=>
{
list
.
push
(
j
.
name
);
if
(
res
.
data
.
IsAuthorize
)
{
setCheckboxFlag
(
1
);
}
else
{
setCheckboxFlag
(
0
);
}
if
(
aa
.
length
>
0
)
{
let
dd
=
[];
aa
.
map
(
i
=>
{
keepData
.
map
(
j
=>
{
if
(
j
.
name
===
i
)
{
dd
.
push
(
j
);
}
});
});
arr
[
i
]
=
list
;
});
console
.
log
(
arr
);
setProduct
(
arr
);
setKeepValue
(
arr
);
let
Arr
=
Array
.
from
(
new
Set
(
dd
));
let
arr
=
formateArrDataA
(
Arr
,
'productName'
);
let
a
=
Object
.
keys
(
arr
);
a
.
map
(
i
=>
{
let
list
=
[];
arr
[
i
].
map
(
j
=>
{
list
.
push
(
j
.
name
);
});
arr
[
i
]
=
list
;
});
setProduct
(
arr
);
setKeepValue
(
arr
);
}
let
newArr
=
Array
.
from
(
new
Set
(
aa
));
setKeepProduct
(
newArr
);
setKeepCode
(
newArr
);
setValue
(
newArr
);
}
console
.
log
(
newArr
);
let
newArr
=
Array
.
from
(
new
Set
(
aa
));
setKeepProduct
(
newArr
);
setKeepCode
(
newArr
);
setValue
(
newArr
);
setDbExists
(
res
.
data
.
DBExists
);
setKeepDb
(
res
.
data
);
}
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,15 +403,16 @@ 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
);
setValue
(
newArr
);
// 当前数据库已存在和上一个已存在数据库值重新赋值
if
(
newArr
.
length
>
0
||
dbExists
)
{
setKeepProduct
(
newArr
);
setKeepCode
(
newArr
);
setValue
(
newArr
);
}
}
setDbExists
(
res
.
data
.
DBExists
);
setKeepDb
(
res
.
data
);
...
...
@@ -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)'
}
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment