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
20da8a93
Commit
20da8a93
authored
Nov 03, 2020
by
张烨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style: fix lint
parent
40f1b6a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
174 additions
and
144 deletions
+174
-144
InitDataBase.jsx
src/pages/database/InitDataBase.jsx
+174
-144
No files found.
src/pages/database/InitDataBase.jsx
View file @
20da8a93
...
...
@@ -10,12 +10,12 @@ import {
notification
,
Modal
,
Row
,
Col
Col
,
}
from
'antd'
;
import
{
PageContainer
}
from
'@ant-design/pro-layout'
;
import
{
connect
}
from
'react-redux'
;
import
{
get
,
post
}
from
'../../services'
;
import
styles
from
'./InitDataBase.less'
import
styles
from
'./InitDataBase.less'
;
const
{
Option
}
=
Select
;
const
formLables
=
{
...
...
@@ -26,7 +26,7 @@ const formLables = {
};
const
InitDataBase
=
props
=>
{
const
[
form
]
=
Form
.
useForm
();
const
[
tableLoading
,
setTableLoading
]
=
useState
(
false
);
//
连接记录
const
[
tableLoading
,
setTableLoading
]
=
useState
(
false
);
//
连接记录
const
[
dbForm
,
setDbForm
]
=
useState
({
ip
:
''
,
dbName
:
''
,
...
...
@@ -34,13 +34,13 @@ const InitDataBase = props => {
userName
:
''
,
inUse
:
''
,
});
const
[
data
,
setData
]
=
useState
([]);
//数据库链接记录
const
[
upData
,
setUpData
]
=
useState
(
1
);
//
列表刷新标记
const
[
option
,
setOption
]
=
useState
([]);
//下拉列表数据
const
[
desc
,
setDesc
]
=
useState
(
''
);
//
修改描述
const
[
modalVisible
,
setModalVisible
]
=
useState
(
false
)
const
[
data
,
setData
]
=
useState
([]);
//
数据库链接记录
const
[
upData
,
setUpData
]
=
useState
(
1
);
//
列表刷新标记
const
[
option
,
setOption
]
=
useState
([]);
//
下拉列表数据
const
[
desc
,
setDesc
]
=
useState
(
''
);
//
修改描述
const
[
modalVisible
,
setModalVisible
]
=
useState
(
false
)
;
console
.
log
(
window
.
location
.
host
);
//获取数据库链接记录
//
获取数据库链接记录
useEffect
(()
=>
{
setTableLoading
(
true
);
get
(
`/Cityinterface/rest/services/OMS.svc/S_GetConnRecord`
,
{
...
...
@@ -62,30 +62,28 @@ const InitDataBase = props => {
console
.
error
(
err
);
});
},
[
upData
]);
//获取数据库配置信息
//
获取数据库配置信息
useEffect
(()
=>
{
get
(
`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseConfig`
,
{
_version
:
9999
,
dc
:
1603334559186
,
})
.
then
(
res
=>
{
console
.
log
(
res
,
'69res'
);
console
.
log
(
res
,
'69res'
);
if
(
res
.
success
)
{
let
obj
=
{};
for
(
let
k
in
dbForm
)
{
Object
.
keys
(
dbForm
).
forEach
(
k
=>
{
obj
[
k
]
=
res
[
k
];
}
form
.
setFieldsValue
(
obj
);
setDbForm
(
val
=>
{
return
{
...
val
,
...
obj
};
});
form
.
setFieldsValue
(
obj
);
setDbForm
(
val
=>
({
...
val
,
...
obj
}));
}
})
.
catch
(
err
=>
{
console
.
error
(
err
);
});
},
[]);
//数据库初始化
//
数据库初始化
const
initClick
=
()
=>
{};
const
onValuesChange
=
(
value
,
b
)
=>
{
form
.
setFieldsValue
(
value
);
...
...
@@ -95,75 +93,79 @@ const InitDataBase = props => {
dbName
:
value
,
});
};
//保存连接
//
保存连接
const
onFinish
=
values
=>
{
const
obj
=
values
get
(
'/Cityinterface/rest/services/OMS.svc/S_SaveConnection'
,{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
ip
:
obj
.
ip
,
dbName
:
obj
.
dbName
,
userName
:
obj
.
userName
,
password
:
obj
.
password
}).
then
(
res
=>
{
if
(
res
.
GetMe
===
true
){
setUpData
(
upData
+
1
)
notification
.
success
({
message
:
'通知'
,
duration
:
3
,
description
:
'保存成功'
,
});
}
else
{
const
obj
=
values
;
get
(
'/Cityinterface/rest/services/OMS.svc/S_SaveConnection'
,
{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
ip
:
obj
.
ip
,
dbName
:
obj
.
dbName
,
userName
:
obj
.
userName
,
password
:
obj
.
password
,
})
.
then
(
res
=>
{
if
(
res
.
GetMe
===
true
)
{
setUpData
(
upData
+
1
);
notification
.
success
({
message
:
'通知'
,
duration
:
3
,
description
:
'保存成功'
,
});
}
else
{
notification
.
error
({
message
:
'提示'
,
duration
:
3
,
description
:
res
.
Say
.
Message
||
'保存失败'
,
});
}
})
.
catch
(
err
=>
{
console
.
log
(
err
);
notification
.
error
({
message
:
'提示'
,
duration
:
3
,
description
:
res
.
Say
.
Message
||
'保存失败'
,
description
:
err
||
'保存失败'
,
});
}
}).
catch
(
err
=>
{
console
.
log
(
err
)
notification
.
error
({
message
:
'提示'
,
duration
:
3
,
description
:
err
||
'保存失败'
,
});
})
};
const
onCheck
=
e
=>
{
//测试连接
//
测试连接
console
.
log
(
dbForm
);
console
.
log
(
form
.
getFieldValue
());
console
.
log
(
form
.
getFieldsValue
());
const
obj
=
form
.
getFieldsValue
()
get
(
'/Cityinterface/rest/services/OMS.svc/S_GetConnectionTest'
,{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
ip
:
obj
.
ip
,
dbName
:
obj
.
dbName
,
userName
:
obj
.
userName
,
password
:
obj
.
password
}).
then
(
res
=>
{
if
(
res
.
GetMe
===
true
){
notification
.
success
({
message
:
'通知'
,
duration
:
3
,
description
:
'连接成功'
,
});
}
else
{
const
obj
=
form
.
getFieldsValue
();
get
(
'/Cityinterface/rest/services/OMS.svc/S_GetConnectionTest'
,
{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
ip
:
obj
.
ip
,
dbName
:
obj
.
dbName
,
userName
:
obj
.
userName
,
password
:
obj
.
password
,
})
.
then
(
res
=>
{
if
(
res
.
GetMe
===
true
)
{
notification
.
success
({
message
:
'通知'
,
duration
:
3
,
description
:
'连接成功'
,
});
}
else
{
notification
.
error
({
message
:
'提示'
,
duration
:
3
,
description
:
res
.
Say
.
Message
||
'连接失败'
,
});
}
})
.
catch
(
err
=>
{
console
.
log
(
err
);
notification
.
error
({
message
:
'提示'
,
duration
:
3
,
description
:
res
.
Say
.
Message
||
'连接失败'
,
description
:
err
||
'连接失败'
,
});
}
}).
catch
(
err
=>
{
console
.
log
(
err
)
notification
.
error
({
message
:
'提示'
,
duration
:
3
,
description
:
err
||
'连接失败'
,
});
})
};
const
selectFocus
=
e
=>
{
setOption
([]);
...
...
@@ -171,9 +173,9 @@ const InitDataBase = props => {
get
(
`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`
,
{
_version
:
9999
,
_dc
:
1603334559186
,
userName
:
params
[
'userName'
]
||
''
,
password
:
params
[
'password'
]
||
''
,
ip
:
params
[
'ip'
]
||
''
,
userName
:
params
.
userName
||
''
,
password
:
params
.
password
||
''
,
ip
:
params
.
ip
||
''
,
})
.
then
(
res
=>
{
if
(
res
.
success
)
{
...
...
@@ -192,45 +194,47 @@ const InitDataBase = props => {
console
.
error
(
err
);
});
};
//点击表格回显到表单
//
点击表格回显到表单
const
tableClick
=
item
=>
{
let
obj
=
{
...
dbForm
};
for
(
let
k
in
obj
)
{
Object
.
keys
(
obj
).
forEach
(
k
=>
{
obj
[
k
]
=
item
[
k
];
}
}
);
form
.
setFieldsValue
(
obj
);
};
//展示修改描述
//
展示修改描述
const
changeDesc
=
()
=>
{
setModalVisible
(
true
)
setDesc
(
''
)
}
const
descChange
=
(
e
)
=>
{
const
{
value
}
=
e
.
target
setDesc
(
value
)
}
//弹窗确认回调
const
modalOkCallback
=
()
=>
{
setModalVisible
(
true
)
;
setDesc
(
''
)
;
}
;
const
descChange
=
e
=>
{
const
{
value
}
=
e
.
target
;
setDesc
(
value
)
;
}
;
//
弹窗确认回调
const
modalOkCallback
=
()
=>
{
console
.
log
(
form
.
getFieldsValue
());
const
obj
=
form
.
getFieldsValue
()
//更新描述
get
(
'/Cityinterface/rest/services/OMS.svc/S_UpdateConnDesc'
,{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
ip
:
obj
.
ip
,
dbName
:
obj
.
dbName
,
userName
:
obj
.
userName
,
password
:
obj
.
password
,
desc
}).
then
(
res
=>
{
console
.
log
(
res
)
setModalVisible
(
false
)
setUpData
(
upData
+
1
)
}).
catch
(
err
=>
{
console
.
error
(
err
)
setModalVisible
(
false
)
const
obj
=
form
.
getFieldsValue
();
// 更新描述
get
(
'/Cityinterface/rest/services/OMS.svc/S_UpdateConnDesc'
,
{
_version
:
9999
,
_dc
:
new
Date
().
getTime
(),
ip
:
obj
.
ip
,
dbName
:
obj
.
dbName
,
userName
:
obj
.
userName
,
password
:
obj
.
password
,
desc
,
})
}
.
then
(
res
=>
{
console
.
log
(
res
);
setModalVisible
(
false
);
setUpData
(
upData
+
1
);
})
.
catch
(
err
=>
{
console
.
error
(
err
);
setModalVisible
(
false
);
});
};
const
columns
=
[
{
title
:
'服务器名或IP地址'
,
...
...
@@ -261,18 +265,28 @@ const InitDataBase = props => {
title
:
'修改描述'
,
dataIndex
:
'name'
,
key
:
'name'
,
render
:
()
=>
{
return
<
Button
type=
'primary'
size=
'small'
onClick=
{
()
=>
{
changeDesc
()}
}
>
修改描述
</
Button
>;
},
render
:
()
=>
(
<
Button
type=
"primary"
size=
"small"
onClick=
{
()
=>
{
changeDesc
();
}
}
>
修改描述
</
Button
>
),
},
{
title
:
'删除'
,
dataIndex
:
'name'
,
key
:
'name'
,
render
:
()
=>
{
return
<
Button
size=
'small'
danger
>
删除
</
Button
>;
},
render
:
()
=>
(
<
Button
size=
"small"
danger
>
删除
</
Button
>
),
},
];
return
(
...
...
@@ -309,6 +323,7 @@ const InitDataBase = props => {
onChange=
{
e
=>
{
onChange
(
e
);
}
}
// eslint-disable-next-line no-shadow
filterOption=
{
(
input
,
option
)
=>
option
.
children
.
toLowerCase
().
indexOf
(
input
.
toLowerCase
())
>=
0
...
...
@@ -316,26 +331,37 @@ const InitDataBase = props => {
>
{
option
&&
option
.
length
>
0
&&
option
.
map
((
item
,
index
)
=>
{
return
(
<
Option
value=
{
item
.
value
}
key=
{
index
}
>
{
item
.
value
}
</
Option
>
);
})
}
option
.
map
((
item
,
index
)
=>
(
<
Option
value=
{
item
.
value
}
key=
{
index
}
>
{
item
.
value
}
</
Option
>
))
}
</
Select
>
</
Form
.
Item
>
<
Form
.
Item
>
<
div
className=
{
styles
.
tCenter
}
>
<
Space
size=
"large"
>
<
Button
onClick=
{
onCheck
}
>
测试连接
</
Button
>
<
Button
type=
'primary'
htmlType=
"submit"
loading=
{
tableLoading
}
>
保存连接
</
Button
>
<
Button
type=
'primary'
danger
htmlType=
"reset"
onClick=
{
()
=>
{
initClick
()}
}
>
<
Button
onClick=
{
onCheck
}
>
测试连接
</
Button
>
<
Button
type=
"primary"
htmlType=
"submit"
loading=
{
tableLoading
}
>
保存连接
</
Button
>
<
Button
type=
"primary"
danger
htmlType=
"reset"
onClick=
{
()
=>
{
initClick
();
}
}
>
数据库初始化
</
Button
>
<
span
>
{
dbForm
.
inUse
}
</
span
>
</
Space
>
</
div
>
</
Space
>
</
div
>
</
Form
.
Item
>
</
Form
>
</
Card
>
...
...
@@ -343,41 +369,45 @@ const InitDataBase = props => {
<
Card
className=
{
styles
.
mgTop20
}
>
<
div
className=
{
styles
.
tableTitle
}
>
近期保存的数据库连接
</
div
>
<
Table
style=
{
{
marginTop
:
'20px'
}
}
style=
{
{
marginTop
:
'20px'
}
}
columns=
{
columns
}
dataSource=
{
data
}
bordered
loading=
{
tableLoading
}
size=
'small'
onRow=
{
record
=>
{
return
{
onClick
:
()
=>
{
tableClick
(
record
);
},
// 点击行
};
}
}
size=
"small"
onRow=
{
record
=>
({
onClick
:
()
=>
{
tableClick
(
record
);
},
// 点击行
})
}
/>
</
Card
>
<
Modal
title=
'修改链接描述'
title=
"修改链接描述"
visible=
{
modalVisible
}
maskClosable
onOk=
{
()
=>
modalOkCallback
()
}
onOk=
{
()
=>
modalOkCallback
()
}
onCancel=
{
()
=>
setModalVisible
(
false
)
}
width=
"1000px"
bodyStyle=
{
{
minHeight
:
'100px'
minHeight
:
'100px'
,
}
}
cancelText=
'取消'
okText=
'确认修改'
destroyOnClose
=
{
true
}
cancelText=
"取消"
okText=
"确认修改"
destroyOnClose
>
<
Row
>
<
Col
span=
{
1
}
className=
{
styles
.
decsBox
}
>
描述:
</
Col
>
<
Col
span=
{
11
}
>
<
Input
placeholder=
'请输入描述'
onChange=
{
(
value
)
=>
{
descChange
(
value
)
}
}
></
Input
></
Col
>
<
Row
>
<
Col
span=
{
1
}
className=
{
styles
.
decsBox
}
>
描述:
</
Col
>
<
Col
span=
{
11
}
>
<
Input
placeholder=
"请输入描述"
onChange=
{
value
=>
{
descChange
(
value
);
}
}
/>
</
Col
>
</
Row
>
</
Modal
>
</
PageContainer
>
...
...
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