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
da6f5f6b
Commit
da6f5f6b
authored
Jul 29, 2022
by
皮倩雯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: '数据库初始化交互优化'
parent
23602c5d
Pipeline
#56579
waiting for manual action with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
149 additions
and
142 deletions
+149
-142
DatabaseInitialization.jsx
...atabase/databaseInitialization/DatabaseInitialization.jsx
+149
-142
No files found.
src/pages/database/databaseInitialization/DatabaseInitialization.jsx
View file @
da6f5f6b
...
...
@@ -46,6 +46,7 @@ import {
import
{
BarcodeOutlined
,
EditOutlined
}
from
'@ant-design/icons'
;
import
styles
from
'./DatabaseInitialization.less'
;
import
styles1
from
'../InitDataBase/InitDataBase.less'
;
import
{
objectOf
}
from
'prop-types'
;
const
CheckboxGroup
=
Checkbox
.
Group
;
const
{
Option
}
=
Select
;
...
...
@@ -260,14 +261,11 @@ const DatabaseInitialization = props => {
});
};
const
GetDb
=
e
=>
{
const
GetDb
=
()
=>
{
// let obj = form.getFieldsValue();
GetDbProduct
().
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
if
(
!
e
)
{
form
.
setFieldsValue
(
res
.
data
.
DbInfo
);
}
form
.
setFieldsValue
(
res
.
data
.
DbInfo
);
if
(
res
.
data
.
Project
[
0
])
{
setkeepNumber
(
res
.
data
.
Project
[
0
].
license
);
setkeepMsg
(
res
.
data
.
Project
[
0
].
projectName
);
...
...
@@ -323,46 +321,101 @@ const DatabaseInitialization = props => {
}
setDbExists
(
res
.
data
.
DBExists
);
setKeepDb
(
res
.
data
);
if
(
!
e
)
{
if
(
res
.
data
.
DBExists
)
{
if
(
res
.
data
.
DBExists
)
{
setCheckboxFlag
(
1
);
setMsg
(
'当前数据库已存在不可初始化'
);
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'当前数据库已存在不可初始化'
,
});
}
else
if
(
!
res
.
data
.
DBExists
&&
!
res
.
data
.
Project
[
0
])
{
setCheckboxFlag
(
0
);
setMsg
(
''
);
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'未检测到License,自主选择产品进行数据库初始化'
,
});
}
else
if
(
!
res
.
data
.
DBExists
&&
res
.
data
.
Project
[
0
])
{
setCheckboxFlag
(
1
);
notification
.
success
({
message
:
'提示'
,
duration
:
5
,
description
:
'已检测到License,需初始化数据库'
,
});
setMsg
(
''
);
}
}
else
{
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
res
.
msg
,
});
}
});
};
const
GetDbChange
=
()
=>
{
let
obj
=
form
.
getFieldsValue
();
GetDbProduct
({
...
obj
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
if
(
res
.
data
.
Project
[
0
])
{
setkeepNumber
(
res
.
data
.
Project
[
0
].
license
);
setkeepMsg
(
res
.
data
.
Project
[
0
].
projectName
);
setkeepNa
(
res
.
data
.
Project
[
0
].
applicantName
);
setkeepCo
(
res
.
data
.
Project
[
0
].
jobNumber
);
}
else
{
setkeepNumber
(
''
);
setkeepMsg
(
''
);
setkeepNa
(
''
);
setkeepCo
(
''
);
}
if
(
res
.
data
.
Product
)
{
let
aa
=
[];
res
.
data
.
Product
.
map
(
i
=>
{
aa
.
push
(
i
.
name
);
});
if
(
res
.
data
.
IsAuthorize
||
res
.
data
.
DBExists
)
{
setCheckboxFlag
(
1
);
setMsg
(
'当前数据库已存在不可初始化'
);
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'当前数据库已存在不可初始化'
,
});
}
else
if
(
!
res
.
data
.
DBExists
&&
!
res
.
data
.
Project
[
0
])
{
}
else
{
setCheckboxFlag
(
0
);
setMsg
(
''
);
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'未检测到License,自主选择产品进行数据库初始化'
,
}
console
.
log
(
aa
);
if
(
aa
.
length
>
0
)
{
let
dd
=
[];
aa
.
map
(
i
=>
{
keepData
.
map
(
j
=>
{
if
(
j
.
name
===
i
)
{
dd
.
push
(
j
);
}
});
});
}
else
if
(
!
res
.
data
.
DBExists
&&
res
.
data
.
Project
[
0
])
{
setCheckboxFlag
(
1
);
notification
.
success
({
message
:
'提示'
,
duration
:
5
,
description
:
'已检测到License,需初始化数据库'
,
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
);
});
arr
[
i
]
=
list
;
});
setMsg
(
''
);
console
.
log
(
arr
);
setProduct
(
arr
);
setKeepValue
(
arr
);
}
console
.
log
(
newArr
);
let
newArr
=
Array
.
from
(
new
Set
(
aa
));
setKeepProduct
(
newArr
);
setKeepCode
(
newArr
);
setValue
(
newArr
);
}
// if (!res.data.DBExists) {
// setMsg('');
// } else if (res.data.DBExists && res.data.Product.length > 0) {
// setMsg('');
// } else {
// setMsg('当前数据库不可初始化');
// notification.warning({
// message: '提示',
// duration: 5,
// description: '当前数据库不可初始化',
// });
// }
setDbExists
(
res
.
data
.
DBExists
);
setKeepDb
(
res
.
data
);
}
else
{
notification
.
warning
({
message
:
'提示'
,
...
...
@@ -465,13 +518,16 @@ const DatabaseInitialization = props => {
setTotalProduct
(
''
);
setValue
(
''
);
setKeepProduct
([]);
// GetDb(1);
setKeepValue
([]);
setProduct
([]);
onCheck
();
// GetDb();
// deleteInitDBLogNew();
};
const
onChange1
=
(
e
,
item
)
=>
{
console
.
log
(
e
);
console
.
log
(
item
);
console
.
log
(
product
);
if
(
product
[
item
])
{
// 过滤已初始化的产品但不存在于产品列表中的数据,避免组件出错
product
[
item
].
map
(
i
=>
{
...
...
@@ -521,16 +577,15 @@ const DatabaseInitialization = props => {
};
const
onCheck
=
()
=>
{
console
.
log
(
99999999
);
let
obj
=
form
.
getFieldsValue
();
GetDbChange
();
deleteInitDBLogNew
();
CheckDatabaseIsExist
({
...
obj
}).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
// 数据库不存在
if
(
res
.
data
===
false
)
{
console
.
log
(
555
);
// 有授权码
if
(
keepNumber
)
{
GetDb
(
1
);
setCheckboxFlag
(
1
);
setDbExists
(
false
);
setMsg
(
''
);
...
...
@@ -560,7 +615,8 @@ const DatabaseInitialization = props => {
}
}
else
{
setMsg
(
res
.
msg
);
notification
.
warning
({
setCheckboxFlag
(
1
);
notification
.
error
({
message
:
'提示'
,
duration
:
5
,
description
:
res
.
msg
,
...
...
@@ -573,41 +629,64 @@ const DatabaseInitialization = props => {
let
obj
=
form
.
getFieldsValue
();
CheckDatabaseIsExist
({
...
obj
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
setDbExists
(
false
);
setMsg
(
''
);
if
(
msg
)
{
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'当前数据库不可初始化'
,
});
}
else
if
(
obj
.
ip
==
''
||
obj
.
userName
==
''
||
obj
.
password
==
''
||
obj
.
dbName
==
''
)
{
if
(
res
.
data
===
true
)
{
setCheckboxFlag
(
1
);
setMsg
(
'当前数据库已存在不可初始化'
);
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'
请输入完整数据库信息
'
,
description
:
'
当前数据库已存在不可初始化
'
,
});
}
else
{
console
.
log
(
valu
e
);
let
arr
=
[]
;
if
(
checkboxFlag
==
0
)
{
keepData
.
map
(
i
=>
{
if
(
value
.
indexOf
(
i
.
name
)
!=
-
1
)
{
arr
.
push
(
i
);
}
setDbExists
(
fals
e
);
setMsg
(
''
)
;
if
(
msg
)
{
notification
.
warning
(
{
message
:
'提示'
,
duration
:
5
,
description
:
'当前数据库不可初始化'
,
});
}
else
{
keepData
.
map
(
i
=>
{
if
(
keepCode
.
indexOf
(
i
.
name
)
!=
-
1
)
{
arr
.
push
(
i
);
}
}
else
if
(
obj
.
ip
==
''
||
obj
.
userName
==
''
||
obj
.
password
==
''
||
obj
.
dbName
==
''
)
{
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'请输入完整数据库信息'
,
});
}
else
if
(
checkboxFlag
==
0
&&
value
.
length
==
0
)
{
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'请勾选产品'
,
});
}
else
if
(
checkboxFlag
==
1
&&
keepProduct
.
length
==
0
)
{
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'请勾选产品'
,
});
}
else
{
console
.
log
(
value
);
let
arr
=
[];
if
(
checkboxFlag
==
0
)
{
keepData
.
map
(
i
=>
{
if
(
value
.
indexOf
(
i
.
name
)
!=
-
1
)
{
arr
.
push
(
i
);
}
});
}
else
{
keepData
.
map
(
i
=>
{
if
(
keepCode
.
indexOf
(
i
.
name
)
!=
-
1
)
{
arr
.
push
(
i
);
}
});
}
console
.
log
(
arr
);
onOK
(
arr
,
code
);
}
console
.
log
(
arr
);
onOK
(
arr
,
code
);
}
}
else
{
setMsg
(
res
.
msg
);
setCheckboxFlag
(
1
);
notification
.
error
({
message
:
'提示'
,
duration
:
5
,
...
...
@@ -638,14 +717,12 @@ const DatabaseInitialization = props => {
<
div
style=
{
{
width
:
'30%'
}
}
>
<
Card
>
<
div
style=
{
{
height
:
'calc(100vh - 108px)'
,
paddingTop
:
'13px'
}
}
>
{
/* <div className={styles.tableTitle}>数据库初始化</div> */
}
<
Form
className=
{
styles
.
mgTop20
}
layout=
"horizontal"
labelAlign=
"left"
labelCol=
{
{
span
:
6
}
}
form=
{
form
}
// onFinish={onFinish}
onValuesChange=
{
onValuesChange
}
>
<
Form
.
Item
...
...
@@ -657,14 +734,6 @@ const DatabaseInitialization = props => {
if
(
form
.
getFieldValue
().
ip
==
''
)
{
return
Promise
.
reject
(
'ip必填'
);
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
...
...
@@ -684,14 +753,6 @@ const DatabaseInitialization = props => {
if
(
form
.
getFieldValue
().
userName
==
''
)
{
return
Promise
.
reject
(
'用户名称必填'
);
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
...
...
@@ -712,14 +773,6 @@ const DatabaseInitialization = props => {
if
(
form
.
getFieldValue
().
password
==
''
)
{
return
Promise
.
reject
(
'用户密码必填'
);
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
...
...
@@ -743,14 +796,6 @@ const DatabaseInitialization = props => {
)
{
return
Promise
.
reject
(
'数据库名称必填'
);
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
...
...
@@ -760,34 +805,6 @@ const DatabaseInitialization = props => {
]
}
>
<
Input
placeholder=
"请输入数据库名称"
/>
{
/* <Select
showSearch
mode="tags"
placeholder="请选择数据库"
optionFilterProp="children"
onFocus={() => {
selectFocus();
}}
onChange={e => {
onChange(e);
}}
// eslint-disable-next-line no-shadow
filterOption={(input, option) => {
console.log(option);
return (
option.children &&
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
);
}}
>
{option &&
option.length > 0 &&
option.map((item, index) => (
<Option value={item.value} key={item.value + index}>
{item.value}
</Option>
))}
</Select> */
}
</
Form
.
Item
>
</
Form
>
<
div
style=
{
{
float
:
'right'
}
}
>
...
...
@@ -912,13 +929,7 @@ const DatabaseInitialization = props => {
deleteInitDBLogNew
();
}
}
>
<
Button
type=
"primary"
disabled=
{
msg
==
''
?
false
:
true
}
// onClick={() => {
// onCheck();
// }}
>
<
Button
type=
"primary"
disabled=
{
msg
==
''
?
false
:
true
}
>
数据库初始化
</
Button
>
</
Popconfirm
>
...
...
@@ -933,10 +944,6 @@ const DatabaseInitialization = props => {
onCancel=
{
()
=>
{
setInitVisible
(
false
);
setInitContent
(
''
);
// deleteInitDBLog(
{
// _version: 9999,
// _dc: Date.now(),
//
});
deleteInitDBLogNew
();
}
}
width=
{
800
}
...
...
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