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
65fff149
Commit
65fff149
authored
Jul 19, 2022
by
皮倩雯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: '数据库初始化'
parent
b957ac42
Pipeline
#55692
waiting for manual action with stages
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
176 additions
and
15 deletions
+176
-15
InitDataBase.jsx
src/pages/database/InitDataBase/InitDataBase.jsx
+158
-12
InitDataBase.less
src/pages/database/InitDataBase/InitDataBase.less
+12
-3
initModal.jsx
src/pages/database/InitDataBase/initModal.jsx
+0
-0
api.js
src/services/database/api.js
+6
-0
No files found.
src/pages/database/InitDataBase/InitDataBase.jsx
View file @
65fff149
...
@@ -39,6 +39,7 @@ import {
...
@@ -39,6 +39,7 @@ import {
InitEditDataBase
,
// 二次初始化
InitEditDataBase
,
// 二次初始化
}
from
'@/services/database/api'
;
}
from
'@/services/database/api'
;
import
styles
from
'./InitDataBase.less'
;
import
styles
from
'./InitDataBase.less'
;
import
InitModal
from
'./initModal'
;
const
{
TabPane
}
=
Tabs
;
const
{
TabPane
}
=
Tabs
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
...
@@ -77,7 +78,13 @@ const InitDataBase = props => {
...
@@ -77,7 +78,13 @@ const InitDataBase = props => {
const
[
initLoading
,
setInitLoading
]
=
useState
(
false
);
const
[
initLoading
,
setInitLoading
]
=
useState
(
false
);
const
[
initList
,
setInitList
]
=
useState
([]);
// 数据库初始化产品数据
const
[
initList
,
setInitList
]
=
useState
([]);
// 数据库初始化产品数据
const
[
dbExists
,
setDbExists
]
=
useState
(
false
);
// 数据库是否存在
const
[
dbExists
,
setDbExists
]
=
useState
(
false
);
// 数据库是否存在
const
[
visibleModel
,
setVisibleModel
]
=
useState
(
false
);
const
[
keepDb
,
setKeepDb
]
=
useState
([]);
const
[
keepProduct
,
setKeepProduct
]
=
useState
([]);
const
scroll
=
useRef
(
null
);
const
scroll
=
useRef
(
null
);
const
[
keep
,
setKeep
]
=
useState
([]);
const
[
flag
,
setFlag
]
=
useState
(
0
);
const
[
keepData
,
setKeepData
]
=
useState
({});
// 获取数据库配置信息
// 获取数据库配置信息
useEffect
(()
=>
{
useEffect
(()
=>
{
...
@@ -223,6 +230,13 @@ const InitDataBase = props => {
...
@@ -223,6 +230,13 @@ const InitDataBase = props => {
.
then
(
resnew
=>
{
.
then
(
resnew
=>
{
setCardLoading
(
false
);
setCardLoading
(
false
);
if
(
resnew
.
code
===
0
)
{
if
(
resnew
.
code
===
0
)
{
setFlag
(
flag
+
1
);
setKeepData
({
ip
:
obj
.
ip
,
dbName
:
obj
.
dbName
,
userName
:
obj
.
userName
,
password
:
obj
.
password
,
});
// setUpData(upData + 1);
// setUpData(upData + 1);
getConnRecordData
();
getConnRecordData
();
notification
.
success
({
notification
.
success
({
...
@@ -413,6 +427,44 @@ const InitDataBase = props => {
...
@@ -413,6 +427,44 @@ const InitDataBase = props => {
console
.
error
(
err
);
console
.
error
(
err
);
});
});
};
};
const
GetDb
=
()
=>
{
let
obj
=
form
.
getFieldsValue
();
GetDbProduct
({
...
obj
}).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
console
.
log
(
res
.
data
);
if
(
res
.
data
.
Product
)
{
console
.
log
(
res
.
data
.
Product
);
let
aa
=
[];
res
.
data
.
Product
.
map
(
i
=>
{
aa
.
push
(
i
.
name
);
});
console
.
log
(
aa
);
setKeep
(
res
.
data
.
Product
);
setKeepProduct
(
aa
);
}
setDbExists
(
res
.
data
.
DBExists
);
setKeepDb
(
res
.
data
);
if
(
!
res
.
data
.
DBExists
)
{
setVisibleModel
(
true
);
}
else
if
(
res
.
data
.
DBExists
&&
res
.
data
.
Product
.
length
>
0
)
{
setVisibleModel
(
true
);
}
else
{
notification
.
warning
({
message
:
'提示'
,
duration
:
15
,
description
:
'当前数据库不可初始化'
,
});
}
}
else
{
notification
.
warning
({
message
:
'提示'
,
duration
:
15
,
description
:
res
.
msg
,
});
}
});
};
// 获取数据库初始化回显列表
// 获取数据库初始化回显列表
const
getInitList
=
()
=>
{
const
getInitList
=
()
=>
{
setInitList
([]);
setInitList
([]);
...
@@ -553,17 +605,21 @@ const InitDataBase = props => {
...
@@ -553,17 +605,21 @@ const InitDataBase = props => {
return
list
;
return
list
;
});
});
};
};
const
onOK
=
(
arr
,
code
)
=>
{
initDatabasePro
(
arr
,
code
);
};
// 数据库初始化
// 数据库初始化
const
initDatabasePro
=
()
=>
{
const
initDatabasePro
=
(
e
,
j
)
=>
{
let
productSetting
=
initList
;
let
productSetting
=
e
;
let
obj
=
form
.
getFieldsValue
();
let
obj
=
form
.
getFieldsValue
();
// 数据库存在调用编辑接口否则调用新增接口
// 数据库存在调用编辑接口否则调用新增接口
setInitLoading
(
true
);
setInitLoading
(
true
);
setVisibleModel
(
false
);
handleShowModal
(
'initVisible'
,
false
);
handleShowModal
(
'initVisible'
,
false
);
setInitVisible
(
true
);
setInitVisible
(
true
);
doInitLog
();
doInitLog
();
if
(
dbExists
)
{
if
(
dbExists
)
{
InitEditDataBase
({
...
obj
,
productSetting
}).
then
(
res
=>
{
InitEditDataBase
({
...
obj
,
productSetting
,
license
:
j
}).
then
(
res
=>
{
setInitLoading
(
false
);
setInitLoading
(
false
);
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
0
)
{
notification
.
success
({
notification
.
success
({
...
@@ -574,14 +630,14 @@ const InitDataBase = props => {
...
@@ -574,14 +630,14 @@ const InitDataBase = props => {
}
else
{
}
else
{
notification
.
error
({
notification
.
error
({
message
:
'提示'
,
message
:
'提示'
,
duration
:
1
5
,
duration
:
5
,
description
:
res
.
msg
,
description
:
res
.
msg
,
});
});
}
}
});
});
return
;
return
;
}
}
InitAddDataBase
({
...
obj
,
productSetting
}).
then
(
res
=>
{
InitAddDataBase
({
...
obj
,
productSetting
,
license
:
j
}).
then
(
res
=>
{
setInitLoading
(
false
);
setInitLoading
(
false
);
if
(
res
.
code
===
0
)
{
if
(
res
.
code
===
0
)
{
notification
.
success
({
notification
.
success
({
...
@@ -592,7 +648,7 @@ const InitDataBase = props => {
...
@@ -592,7 +648,7 @@ const InitDataBase = props => {
}
else
{
}
else
{
notification
.
error
({
notification
.
error
({
message
:
'提示'
,
message
:
'提示'
,
duration
:
1
5
,
duration
:
5
,
description
:
res
.
msg
,
description
:
res
.
msg
,
});
});
}
}
...
@@ -668,6 +724,27 @@ const InitDataBase = props => {
...
@@ -668,6 +724,27 @@ const InitDataBase = props => {
),
),
},
},
];
];
const
flagChange
=
()
=>
{
const
obj
=
form
.
getFieldsValue
();
console
.
log
(
keepData
);
console
.
log
(
obj
);
if
(
keepData
.
ip
==
obj
.
ip
&&
keepData
.
dbName
==
obj
.
dbName
&&
keepData
.
userName
==
obj
.
userName
&&
keepData
.
password
==
obj
.
password
)
{
GetDb
();
deleteInitDBLogNew
();
}
else
{
notification
.
warning
({
message
:
'提示'
,
duration
:
15
,
description
:
'请先保存连接'
,
});
}
};
return
(
return
(
<>
<>
<
PageContainer
className=
{
styles
.
InitDataBaseContainer
}
>
<
PageContainer
className=
{
styles
.
InitDataBaseContainer
}
>
...
@@ -683,16 +760,73 @@ const InitDataBase = props => {
...
@@ -683,16 +760,73 @@ const InitDataBase = props => {
onFinish=
{
onFinish
}
onFinish=
{
onFinish
}
onValuesChange=
{
onValuesChange
}
onValuesChange=
{
onValuesChange
}
>
>
<
Form
.
Item
label=
{
`${formLables.ip}:`
}
name=
"ip"
>
<
Form
.
Item
label=
{
`${formLables.ip}:`
}
name=
"ip"
rules=
{
[
{
validator
:
(
rule
,
value
)
=>
{
if
(
form
.
getFieldValue
().
ip
==
''
)
{
return
Promise
.
reject
(
'ip必填'
);
}
return
Promise
.
resolve
();
},
},
]
}
>
<
Input
placeholder=
"请输入服务器名或IP地址"
/>
<
Input
placeholder=
"请输入服务器名或IP地址"
/>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
label=
{
`${formLables.userName}:`
}
name=
"userName"
>
<
Form
.
Item
label=
{
`${formLables.userName}:`
}
name=
"userName"
rules=
{
[
{
validator
:
(
rule
,
value
)
=>
{
if
(
form
.
getFieldValue
().
userName
==
''
)
{
return
Promise
.
reject
(
'用户名称必填'
);
}
return
Promise
.
resolve
();
},
},
]
}
>
<
Input
placeholder=
"请输入用户名称"
/>
<
Input
placeholder=
"请输入用户名称"
/>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
label=
{
`${formLables.password}:`
}
name=
"password"
>
<
Form
.
Item
label=
{
`${formLables.password}:`
}
name=
"password"
rules=
{
[
{
validator
:
(
rule
,
value
)
=>
{
console
.
log
(
form
.
getFieldValue
().
password
);
if
(
form
.
getFieldValue
().
password
==
''
)
{
return
Promise
.
reject
(
'用户密码必填'
);
}
return
Promise
.
resolve
();
},
},
]
}
>
<
Input
placeholder=
"请输入用户密码"
type=
"password"
/>
<
Input
placeholder=
"请输入用户密码"
type=
"password"
/>
</
Form
.
Item
>
</
Form
.
Item
>
<
Form
.
Item
label=
{
`${formLables.dbName}:`
}
name=
"dbName"
>
<
Form
.
Item
label=
{
`${formLables.dbName}:`
}
name=
"dbName"
rules=
{
[
{
validator
:
(
rule
,
value
)
=>
{
console
.
log
(
form
.
getFieldValue
().
dbName
);
if
(
form
.
getFieldValue
().
dbName
==
''
||
form
.
getFieldValue
().
dbName
==
undefined
)
{
return
Promise
.
reject
(
'数据库名称必填'
);
}
return
Promise
.
resolve
();
},
},
]
}
>
<
Select
<
Select
showSearch
showSearch
mode=
"tags"
mode=
"tags"
...
@@ -734,9 +868,12 @@ const InitDataBase = props => {
...
@@ -734,9 +868,12 @@ const InitDataBase = props => {
<
Space
>
<
Space
>
<
Button
<
Button
type=
"primary"
type=
"primary"
// onClick={() => {
// getInitList();
// deleteInitDBLogNew();
// }}
onClick=
{
()
=>
{
onClick=
{
()
=>
{
getInitList
();
flagChange
();
deleteInitDBLogNew
();
}
}
}
}
>
>
数据库初始化
数据库初始化
...
@@ -763,6 +900,7 @@ const InitDataBase = props => {
...
@@ -763,6 +900,7 @@ const InitDataBase = props => {
onRow=
{
record
=>
({
onRow=
{
record
=>
({
onClick
:
()
=>
{
onClick
:
()
=>
{
tableClick
(
record
);
tableClick
(
record
);
setFlag
(
0
);
},
// 点击行
},
// 点击行
})
}
})
}
/>
/>
...
@@ -845,6 +983,14 @@ const InitDataBase = props => {
...
@@ -845,6 +983,14 @@ const InitDataBase = props => {
</
Col
>
</
Col
>
</
Row
>
</
Row
>
</
Modal
>
</
Modal
>
<
InitModal
visible=
{
visibleModel
}
onCancel=
{
()
=>
setVisibleModel
(
false
)
}
keepDb=
{
keepDb
}
callBackSubmit=
{
onOK
}
keepProduct=
{
keepProduct
}
keep=
{
keep
}
/>
{
/* 初始化选择产品弹窗 */
}
{
/* 初始化选择产品弹窗 */
}
<
Modal
<
Modal
title=
"初始化"
title=
"初始化"
...
...
src/pages/database/InitDataBase/InitDataBase.less
View file @
65fff149
...
@@ -18,13 +18,12 @@
...
@@ -18,13 +18,12 @@
.ant-modal-header {
.ant-modal-header {
height: 70px;
height: 70px;
}
}
InitDataBaseContainer{
InitDataBaseContainer
{
.ant-card-body {
.ant-card-body {
padding-bottom: 0px !important;
padding-bottom: 0px !important;
}
}
}
}
.cardContainer {
.cardContainer {
margin-top: 10px;
margin-top: 10px;
border: 1px solid #ecf0fa;
border: 1px solid #ecf0fa;
...
@@ -47,5 +46,15 @@ InitDataBaseContainer{
...
@@ -47,5 +46,15 @@ InitDataBaseContainer{
padding-left: 20px;
padding-left: 20px;
box-sizing: border-box;
box-sizing: border-box;
}
}
}
.initItemData {
.ant-checkbox-wrapper {
width: 300px;
margin-bottom: 10px;
margin-left: 8px;
}
.view:hover {
cursor: not-allowed;
}
}
}
src/pages/database/InitDataBase/initModal.jsx
0 → 100644
View file @
65fff149
This diff is collapsed.
Click to expand it.
src/services/database/api.js
View file @
65fff149
...
@@ -191,6 +191,12 @@ export const GetUserAuthSet = params => get(`${PUBLISH_SERVICE}/WebSite/GetUserA
...
@@ -191,6 +191,12 @@ export const GetUserAuthSet = params => get(`${PUBLISH_SERVICE}/WebSite/GetUserA
// 获取产品列表
// 获取产品列表
export
const
GetProductList
=
params
=>
get
(
`
${
PUBLISH_SERVICE
}
/DBManager/GetProductList`
,
params
);
export
const
GetProductList
=
params
=>
get
(
`
${
PUBLISH_SERVICE
}
/DBManager/GetProductList`
,
params
);
// 获取产品列表清单
export
const
GetProductListByLicense
=
params
=>
get
(
`
${
PUBLISH_SERVICE
}
/DBManager/GetProductListByLicense`
,
params
);
// 判断License是否已使用
export
const
GetLicenseStatus
=
params
=>
get
(
`
${
PUBLISH_SERVICE
}
/DBManager/GetLicenseStatus`
,
params
);
// 获取产品方案配置
// 获取产品方案配置
export
const
GetDbProduct
=
params
=>
post
(
`
${
PUBLISH_SERVICE
}
/DBManager/GetDbProduct`
,
params
);
export
const
GetDbProduct
=
params
=>
post
(
`
${
PUBLISH_SERVICE
}
/DBManager/GetDbProduct`
,
params
);
// 数据库初始化
// 数据库初始化
...
...
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