Commit 86f2ec75 authored by Maofei94's avatar Maofei94

perf(pages/database): a perf

parent 7f2f4bf6
......@@ -15,6 +15,7 @@ import {
import { PageContainer } from '@ant-design/pro-layout';
import { connect } from 'react-redux';
import { get, post } from '../../services';
import { setTableSQLDirName, deleteConn } from '@/services/database/api'
import styles from './InitDataBase.less';
const { Option } = Select;
......@@ -38,6 +39,8 @@ const InitDataBase = props => {
const [upData, setUpData] = useState(1); // 列表刷新标记
const [option, setOption] = useState([]); // 下拉列表数据
const [desc, setDesc] = useState(''); // 修改描述
const [allSqlDir, setAllSqulDir] = useState([]) //修改产品方案
const [defaultSqlDir, setDefaultSqlDir] = useState('') //修改产品方案默认值
const [modalVisible, setModalVisible] = useState(false);
console.log(window.location.host);
// 获取数据库链接记录
......@@ -77,6 +80,8 @@ const InitDataBase = props => {
});
form.setFieldsValue(obj);
setDbForm(val => ({ ...val, ...obj }));
setAllSqulDir(res.allSqlDir)
setDefaultSqlDir(res.tableSQLDirName)
}
})
.catch(err => {
......@@ -203,6 +208,30 @@ const InitDataBase = props => {
});
form.setFieldsValue(obj);
};
// 产品方案选择框回调
const handleSelect = (value) =>{
setTableSQLDirName({
dirName:value,
_version:9999,
_dc:new Date().getTime()
}).then(res =>{
if(res.success){
notification.success({
message: '提示',
duration: 3,
description: `已切换初始化脚本为:${value}`,
});
}else{
notification.error({
message: '提示',
duration: 3,
description: res.message,
});
}
}).catch(err =>{
console.error(err)
})
}
// 展示修改描述
const changeDesc = () => {
setModalVisible(true);
......@@ -236,6 +265,34 @@ const InitDataBase = props => {
setModalVisible(false);
});
};
//删除数据库连接记录
const delConn = (value)=>{
setTableLoading(true)
const { key='' } =value
deleteConn({
rowIndex:key,
_version:9999,
_dc:new Date().getTime()
}).then(res =>{
setTableLoading(false)
if(res.success){
setUpData(upData + 1);
notification.success({
message:'提示',
duration:3,
description:'操作成功'
})
}else{
notification.error({
message:'提示',
duration:3,
description:res.message
})
}
}).catch(err => {
setTableLoading(false)
console.error(err)})
}
const columns = [
{
title: '服务器名或IP地址',
......@@ -280,11 +337,12 @@ const InitDataBase = props => {
},
{
title: '删除',
dataIndex: 'name',
key: 'name',
render: () => (
<Button size="small" danger>
dataIndex: 'del',
key: 'del',
render: (text,record) => (
<Button size="small" danger
onClick={() => delConn(record)}
>
删除
</Button>
),
......@@ -360,7 +418,20 @@ const InitDataBase = props => {
>
数据库初始化
</Button>
<span>{dbForm.inUse}</span>
{defaultSqlDir && <Select
placeholder='请选择解决方案'
style={
{width:'200px'}
}
defaultValue={defaultSqlDir}
onChange = { (e)=>{ handleSelect(e)}}
>
{allSqlDir && allSqlDir.map( (item, index) => {
console.log(defaultSqlDir)
return <Option value={item} key={index}> {item} </Option>
}) }
</Select>}
{/* <span>{dbForm.inUse}</span> */}
</Space>
</div>
</Form.Item>
......@@ -389,19 +460,20 @@ const InitDataBase = props => {
maskClosable
onOk={() => modalOkCallback()}
onCancel={() => setModalVisible(false)}
width="1000px"
width="800px"
bodyStyle={{
minHeight: '100px',
}}
cancelText="取消"
okText="确认修改"
destroyOnClose
destroyOnClose={true}
>
<Row>
<Col span={1} className={styles.decsBox}>
<Col span={2} className={styles.decsBox}>
描述:
</Col>
<Col span={11}>
<Col span={22}>
<Input
placeholder="请输入描述"
onChange={value => {
......
......@@ -41,7 +41,7 @@ const DelModal = (props) =>{
return(
<SiteModal {...props} title='删除站点'
bodyStyle ={{width:"100%",minHeight:"50px",}}
style= {{top:'500px'}}
style= {{top:200}}
width="400px"
destroyOnClose={true}
cancelText='取消'
......
import { get, post } from '@/services/index';
// 修改产品解决方案
export const setTableSQLDirName = params =>
get('/Cityinterface/rest/services/OMS.svc/S_SetTableSQLDirName', params);
// 删除数据库连接记录
export const deleteConn = params =>
get('/Cityinterface/rest/services/OMS.svc/S_DeleteConn', params);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment