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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
96 deletions
+103
-96
DatabaseInitialization.jsx
...atabase/databaseInitialization/DatabaseInitialization.jsx
+103
-96
No files found.
src/pages/database/databaseInitialization/DatabaseInitialization.jsx
View file @
da6f5f6b
...
@@ -46,6 +46,7 @@ import {
...
@@ -46,6 +46,7 @@ import {
import
{
BarcodeOutlined
,
EditOutlined
}
from
'@ant-design/icons'
;
import
{
BarcodeOutlined
,
EditOutlined
}
from
'@ant-design/icons'
;
import
styles
from
'./DatabaseInitialization.less'
;
import
styles
from
'./DatabaseInitialization.less'
;
import
styles1
from
'../InitDataBase/InitDataBase.less'
;
import
styles1
from
'../InitDataBase/InitDataBase.less'
;
import
{
objectOf
}
from
'prop-types'
;
const
CheckboxGroup
=
Checkbox
.
Group
;
const
CheckboxGroup
=
Checkbox
.
Group
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
...
@@ -260,14 +261,11 @@ const DatabaseInitialization = props => {
...
@@ -260,14 +261,11 @@ const DatabaseInitialization = props => {
});
});
};
};
const
GetDb
=
e
=>
{
const
GetDb
=
()
=>
{
// let obj = form.getFieldsValue();
// let obj = form.getFieldsValue();
GetDbProduct
().
then
(
res
=>
{
GetDbProduct
().
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
0
)
{
if
(
!
e
)
{
form
.
setFieldsValue
(
res
.
data
.
DbInfo
);
form
.
setFieldsValue
(
res
.
data
.
DbInfo
);
}
if
(
res
.
data
.
Project
[
0
])
{
if
(
res
.
data
.
Project
[
0
])
{
setkeepNumber
(
res
.
data
.
Project
[
0
].
license
);
setkeepNumber
(
res
.
data
.
Project
[
0
].
license
);
setkeepMsg
(
res
.
data
.
Project
[
0
].
projectName
);
setkeepMsg
(
res
.
data
.
Project
[
0
].
projectName
);
...
@@ -323,7 +321,7 @@ const DatabaseInitialization = props => {
...
@@ -323,7 +321,7 @@ const DatabaseInitialization = props => {
}
}
setDbExists
(
res
.
data
.
DBExists
);
setDbExists
(
res
.
data
.
DBExists
);
setKeepDb
(
res
.
data
);
setKeepDb
(
res
.
data
);
if
(
!
e
)
{
if
(
res
.
data
.
DBExists
)
{
if
(
res
.
data
.
DBExists
)
{
setCheckboxFlag
(
1
);
setCheckboxFlag
(
1
);
setMsg
(
'当前数据库已存在不可初始化'
);
setMsg
(
'当前数据库已存在不可初始化'
);
...
@@ -349,20 +347,75 @@ const DatabaseInitialization = props => {
...
@@ -349,20 +347,75 @@ const DatabaseInitialization = props => {
});
});
setMsg
(
''
);
setMsg
(
''
);
}
}
}
else
{
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
res
.
msg
,
});
}
}
});
};
// if (!res.data.DBExists) {
const
GetDbChange
=
()
=>
{
// setMsg('');
let
obj
=
form
.
getFieldsValue
();
// } else if (res.data.DBExists && res.data.Product.length > 0) {
GetDbProduct
({
...
obj
}).
then
(
res
=>
{
// setMsg('');
if
(
res
.
code
===
0
)
{
// } else {
if
(
res
.
data
.
Project
[
0
])
{
// setMsg('当前数据库不可初始化');
setkeepNumber
(
res
.
data
.
Project
[
0
].
license
);
// notification.warning({
setkeepMsg
(
res
.
data
.
Project
[
0
].
projectName
);
// message: '提示',
setkeepNa
(
res
.
data
.
Project
[
0
].
applicantName
);
// duration: 5,
setkeepCo
(
res
.
data
.
Project
[
0
].
jobNumber
);
// description: '当前数据库不可初始化',
}
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
);
}
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
);
}
});
});
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
;
});
console
.
log
(
arr
);
setProduct
(
arr
);
setKeepValue
(
arr
);
}
console
.
log
(
newArr
);
let
newArr
=
Array
.
from
(
new
Set
(
aa
));
setKeepProduct
(
newArr
);
setKeepCode
(
newArr
);
setValue
(
newArr
);
}
setDbExists
(
res
.
data
.
DBExists
);
setKeepDb
(
res
.
data
);
}
else
{
}
else
{
notification
.
warning
({
notification
.
warning
({
message
:
'提示'
,
message
:
'提示'
,
...
@@ -465,13 +518,16 @@ const DatabaseInitialization = props => {
...
@@ -465,13 +518,16 @@ const DatabaseInitialization = props => {
setTotalProduct
(
''
);
setTotalProduct
(
''
);
setValue
(
''
);
setValue
(
''
);
setKeepProduct
([]);
setKeepProduct
([]);
// GetDb(1);
setKeepValue
([]);
setProduct
([]);
onCheck
();
onCheck
();
// GetDb();
// deleteInitDBLogNew();
// deleteInitDBLogNew();
};
};
const
onChange1
=
(
e
,
item
)
=>
{
const
onChange1
=
(
e
,
item
)
=>
{
console
.
log
(
e
);
console
.
log
(
item
);
console
.
log
(
product
);
if
(
product
[
item
])
{
if
(
product
[
item
])
{
// 过滤已初始化的产品但不存在于产品列表中的数据,避免组件出错
// 过滤已初始化的产品但不存在于产品列表中的数据,避免组件出错
product
[
item
].
map
(
i
=>
{
product
[
item
].
map
(
i
=>
{
...
@@ -521,16 +577,15 @@ const DatabaseInitialization = props => {
...
@@ -521,16 +577,15 @@ const DatabaseInitialization = props => {
};
};
const
onCheck
=
()
=>
{
const
onCheck
=
()
=>
{
console
.
log
(
99999999
);
let
obj
=
form
.
getFieldsValue
();
let
obj
=
form
.
getFieldsValue
();
GetDbChange
();
deleteInitDBLogNew
();
CheckDatabaseIsExist
({
...
obj
}).
then
(
res
=>
{
CheckDatabaseIsExist
({
...
obj
}).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
if
(
res
.
code
==
0
)
{
// 数据库不存在
// 数据库不存在
if
(
res
.
data
===
false
)
{
if
(
res
.
data
===
false
)
{
console
.
log
(
555
);
// 有授权码
// 有授权码
if
(
keepNumber
)
{
if
(
keepNumber
)
{
GetDb
(
1
);
setCheckboxFlag
(
1
);
setCheckboxFlag
(
1
);
setDbExists
(
false
);
setDbExists
(
false
);
setMsg
(
''
);
setMsg
(
''
);
...
@@ -560,7 +615,8 @@ const DatabaseInitialization = props => {
...
@@ -560,7 +615,8 @@ const DatabaseInitialization = props => {
}
}
}
else
{
}
else
{
setMsg
(
res
.
msg
);
setMsg
(
res
.
msg
);
notification
.
warning
({
setCheckboxFlag
(
1
);
notification
.
error
({
message
:
'提示'
,
message
:
'提示'
,
duration
:
5
,
duration
:
5
,
description
:
res
.
msg
,
description
:
res
.
msg
,
...
@@ -573,6 +629,15 @@ const DatabaseInitialization = props => {
...
@@ -573,6 +629,15 @@ const DatabaseInitialization = props => {
let
obj
=
form
.
getFieldsValue
();
let
obj
=
form
.
getFieldsValue
();
CheckDatabaseIsExist
({
...
obj
}).
then
(
res
=>
{
CheckDatabaseIsExist
({
...
obj
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
0
)
{
if
(
res
.
data
===
true
)
{
setCheckboxFlag
(
1
);
setMsg
(
'当前数据库已存在不可初始化'
);
notification
.
warning
({
message
:
'提示'
,
duration
:
5
,
description
:
'当前数据库已存在不可初始化'
,
});
}
else
{
setDbExists
(
false
);
setDbExists
(
false
);
setMsg
(
''
);
setMsg
(
''
);
if
(
msg
)
{
if
(
msg
)
{
...
@@ -587,6 +652,18 @@ const DatabaseInitialization = props => {
...
@@ -587,6 +652,18 @@ const DatabaseInitialization = props => {
duration
:
5
,
duration
:
5
,
description
:
'请输入完整数据库信息'
,
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
{
}
else
{
console
.
log
(
value
);
console
.
log
(
value
);
let
arr
=
[];
let
arr
=
[];
...
@@ -606,8 +683,10 @@ const DatabaseInitialization = props => {
...
@@ -606,8 +683,10 @@ const DatabaseInitialization = props => {
console
.
log
(
arr
);
console
.
log
(
arr
);
onOK
(
arr
,
code
);
onOK
(
arr
,
code
);
}
}
}
}
else
{
}
else
{
setMsg
(
res
.
msg
);
setMsg
(
res
.
msg
);
setCheckboxFlag
(
1
);
notification
.
error
({
notification
.
error
({
message
:
'提示'
,
message
:
'提示'
,
duration
:
5
,
duration
:
5
,
...
@@ -638,14 +717,12 @@ const DatabaseInitialization = props => {
...
@@ -638,14 +717,12 @@ const DatabaseInitialization = props => {
<
div
style=
{
{
width
:
'30%'
}
}
>
<
div
style=
{
{
width
:
'30%'
}
}
>
<
Card
>
<
Card
>
<
div
style=
{
{
height
:
'calc(100vh - 108px)'
,
paddingTop
:
'13px'
}
}
>
<
div
style=
{
{
height
:
'calc(100vh - 108px)'
,
paddingTop
:
'13px'
}
}
>
{
/* <div className={styles.tableTitle}>数据库初始化</div> */
}
<
Form
<
Form
className=
{
styles
.
mgTop20
}
className=
{
styles
.
mgTop20
}
layout=
"horizontal"
layout=
"horizontal"
labelAlign=
"left"
labelAlign=
"left"
labelCol=
{
{
span
:
6
}
}
labelCol=
{
{
span
:
6
}
}
form=
{
form
}
form=
{
form
}
// onFinish={onFinish}
onValuesChange=
{
onValuesChange
}
onValuesChange=
{
onValuesChange
}
>
>
<
Form
.
Item
<
Form
.
Item
...
@@ -657,14 +734,6 @@ const DatabaseInitialization = props => {
...
@@ -657,14 +734,6 @@ const DatabaseInitialization = props => {
if
(
form
.
getFieldValue
().
ip
==
''
)
{
if
(
form
.
getFieldValue
().
ip
==
''
)
{
return
Promise
.
reject
(
'ip必填'
);
return
Promise
.
reject
(
'ip必填'
);
}
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
setLastColor
(
'gray'
);
...
@@ -684,14 +753,6 @@ const DatabaseInitialization = props => {
...
@@ -684,14 +753,6 @@ const DatabaseInitialization = props => {
if
(
form
.
getFieldValue
().
userName
==
''
)
{
if
(
form
.
getFieldValue
().
userName
==
''
)
{
return
Promise
.
reject
(
'用户名称必填'
);
return
Promise
.
reject
(
'用户名称必填'
);
}
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
setLastColor
(
'gray'
);
...
@@ -712,14 +773,6 @@ const DatabaseInitialization = props => {
...
@@ -712,14 +773,6 @@ const DatabaseInitialization = props => {
if
(
form
.
getFieldValue
().
password
==
''
)
{
if
(
form
.
getFieldValue
().
password
==
''
)
{
return
Promise
.
reject
(
'用户密码必填'
);
return
Promise
.
reject
(
'用户密码必填'
);
}
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
setLastColor
(
'gray'
);
...
@@ -743,14 +796,6 @@ const DatabaseInitialization = props => {
...
@@ -743,14 +796,6 @@ const DatabaseInitialization = props => {
)
{
)
{
return
Promise
.
reject
(
'数据库名称必填'
);
return
Promise
.
reject
(
'数据库名称必填'
);
}
}
// if (
// form.getFieldValue().ip &&
// form.getFieldValue().userName &&
// form.getFieldValue().password &&
// form.getFieldValue().dbName
// )
{
// flagChange();
//
}
setfirstColor
(
'gray'
);
setfirstColor
(
'gray'
);
setsecordColor
(
'gray'
);
setsecordColor
(
'gray'
);
setLastColor
(
'gray'
);
setLastColor
(
'gray'
);
...
@@ -760,34 +805,6 @@ const DatabaseInitialization = props => {
...
@@ -760,34 +805,6 @@ const DatabaseInitialization = props => {
]
}
]
}
>
>
<
Input
placeholder=
"请输入数据库名称"
/>
<
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
.
Item
>
</
Form
>
</
Form
>
<
div
style=
{
{
float
:
'right'
}
}
>
<
div
style=
{
{
float
:
'right'
}
}
>
...
@@ -912,13 +929,7 @@ const DatabaseInitialization = props => {
...
@@ -912,13 +929,7 @@ const DatabaseInitialization = props => {
deleteInitDBLogNew
();
deleteInitDBLogNew
();
}
}
}
}
>
>
<
Button
<
Button
type=
"primary"
disabled=
{
msg
==
''
?
false
:
true
}
>
type=
"primary"
disabled=
{
msg
==
''
?
false
:
true
}
// onClick={() => {
// onCheck();
// }}
>
数据库初始化
数据库初始化
</
Button
>
</
Button
>
</
Popconfirm
>
</
Popconfirm
>
...
@@ -933,10 +944,6 @@ const DatabaseInitialization = props => {
...
@@ -933,10 +944,6 @@ const DatabaseInitialization = props => {
onCancel=
{
()
=>
{
onCancel=
{
()
=>
{
setInitVisible
(
false
);
setInitVisible
(
false
);
setInitContent
(
''
);
setInitContent
(
''
);
// deleteInitDBLog(
{
// _version: 9999,
// _dc: Date.now(),
//
});
deleteInitDBLogNew
();
deleteInitDBLogNew
();
}
}
}
}
width=
{
800
}
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