Commit ca30c991 authored by 张烨's avatar 张烨

style: fix lint

parent 3717c68a
...@@ -96,6 +96,9 @@ module.exports = { ...@@ -96,6 +96,9 @@ module.exports = {
'redux-saga/no-yield-in-race': 2, 'redux-saga/no-yield-in-race': 2,
'redux-saga/yield-effects': 2, 'redux-saga/yield-effects': 2,
'require-yield': 0, 'require-yield': 0,
'no-param-reassign': 0,
'prefer-const': 0,
'button-has-type': 1,
}, },
settings: { settings: {
'import/resolver': { 'import/resolver': {
......
import React,{ useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Card, Form, Input, Button, Select, Table, Tag, Space, notification } from 'antd'; import {
Card,
Form,
Input,
Button,
Select,
Table,
Tag,
Space,
notification,
} from 'antd';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { get, post } from 'services'; import { get, post } from 'services';
const { Option } = Select const { Option } = Select;
const formLables = { const formLables = {
ip:'服务器名或IP地址', ip: '服务器名或IP地址',
userName:'数据库用户名称', userName: '数据库用户名称',
password:'数据库用户密码', password: '数据库用户密码',
dbName:'数据库名称', dbName: '数据库名称',
} };
const InitDataBase = (props) =>{ const InitDataBase = props => {
const [form] = Form.useForm() const [form] = Form.useForm();
const onFinish = (e) =>{ const onFinish = e => {};
} const [tableLoading, setTableLoading] = useState(false);
const [tableLoading, setTableLoading] = useState(false) const [dbForm, setDbForm] = useState({
const [dbForm,setDbForm] = useState({ ip: '',
ip:'', dbName: '',
dbName:'', password: '',
password:'', userName: '',
userName:'', inUse: '',
inUse:'', });
}) const [data, setData] = useState([]); //数据库链接记录
const [data, setData ] = useState([]) //数据库链接记录 const [option, setOption] = useState([]); //下拉列表数据
const [option, setOption] =useState([]) //下拉列表数据 console.log(window.location.host);
console.log(window.location.host)
//获取数据库链接记录 //获取数据库链接记录
useEffect( () =>{ useEffect(() => {
setTableLoading(true) setTableLoading(true);
get(`/Cityinterface/rest/services/OMS.svc/S_GetConnRecord`,{ get(`/Cityinterface/rest/services/OMS.svc/S_GetConnRecord`, {
_version:9999, _version: 9999,
dc:1603334559186 dc: 1603334559186,
}).then(res =>{
setTableLoading(false)
if(res.length>0){
let arr = res.map( (item,index) =>{
item.key = index
return item
}) })
setData(arr) .then(res => {
setTableLoading(false);
if (res.length > 0) {
let arr = res.map((item, index) => {
item.key = index;
return item;
});
setData(arr);
} }
}).catch(err =>{
setTableLoading(false)
console.error(err)
}) })
},[]) .catch(err => {
setTableLoading(false);
console.error(err);
});
}, []);
//获取数据库配置信息 //获取数据库配置信息
useEffect( () =>{ useEffect(() => {
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseConfig`,{ get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseConfig`, {
_version:9999, _version: 9999,
dc:1603334559186 dc: 1603334559186,
}).then(res =>{
console.log(res)
if(res.success){
let obj ={}
for( let k in dbForm){
obj[k]=res[k]
}
form.setFieldsValue(obj)
setDbForm((val)=>{
return {...val,...obj}
}) })
.then(res => {
console.log(res);
if (res.success) {
let obj = {};
for (let k in dbForm) {
obj[k] = res[k];
} }
}).catch(err =>{ form.setFieldsValue(obj);
console.error(err) setDbForm(val => {
}) return { ...val, ...obj };
},[]) });
const testChlick = () =>{
} }
const onValuesChange =(value,b)=>{ })
form.setFieldsValue(value) .catch(err => {
} console.error(err);
const onChange = (value) => { });
}, []);
const testChlick = () => {};
const onValuesChange = (value, b) => {
form.setFieldsValue(value);
};
const onChange = value => {
form.setFieldsValue({ form.setFieldsValue({
dbName:value dbName: value,
});
};
const onCheck = e => {
console.log(dbForm);
console.log(form.getFieldValue());
console.log(form.getFieldsValue());
};
const selectFocus = e => {
setOption([]);
let params = form.getFieldsValue();
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`, {
_version: 9999,
_dc: 1603334559186,
userName: params['userName'] || '',
password: params['password'] || '',
ip: params['ip'] || '',
}) })
} .then(res => {
const onCheck = (e) =>{ if (res.success) {
console.log(dbForm) setOption(res.root);
console.log(form.getFieldValue()) } else {
console.log(form.getFieldsValue())
}
const selectFocus = (e) =>{
setOption([])
let params =form.getFieldsValue()
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`,{
_version:9999,
_dc:1603334559186,
userName:params['userName']||'',
password:params['password']||'',
ip:params['ip']||'',
}).then(res =>{
if(res.success){
setOption(res.root)
}else{
notification.error({ notification.error({
message:'通知', message: '通知',
duration:3, duration: 3,
description:res.message description: res.message,
}) });
setOption([]) setOption([]);
} }
console.log(res) console.log(res);
}).catch(err =>{
console.error(err)
}) })
.catch(err => {
} console.error(err);
});
};
//点击表格回显到表单 //点击表格回显到表单
const tableClick = (item) => { const tableClick = item => {
let obj = {...dbForm} let obj = { ...dbForm };
for(let k in obj){ for (let k in obj) {
obj[k] = item[k] obj[k] = item[k];
}
form.setFieldsValue(obj)
} }
form.setFieldsValue(obj);
};
const columns = [ const columns = [
{ {
title: '服务器名或IP地址', title: '服务器名或IP地址',
...@@ -147,67 +159,76 @@ const InitDataBase = (props) =>{ ...@@ -147,67 +159,76 @@ const InitDataBase = (props) =>{
title: '修改描述', title: '修改描述',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: () =>{ render: () => {
return ( return <button>修改描述</button>;
<button>修改描述</button> },
)
}
}, },
{ {
title: '删除', title: '删除',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: () =>{ render: () => {
return ( return <button>删除</button>;
<button>删除</button> },
)
}
}, },
] ];
return ( return (
<> <>
<PageContainer> <PageContainer>
<Card> <Card>
<div>数据库初始化</div> <div>数据库初始化</div>
<div></div> <div />
<Form <Form
layout="horizontal" layout="horizontal"
labelAlign='left' labelAlign="left"
labelCol={{span:3}} labelCol={{ span: 3 }}
form={form} form={form}
onFinish={onFinish} onFinish={onFinish}
onValuesChange= {onValuesChange} onValuesChange={onValuesChange}
> >
<Form.Item label={`${formLables.ip}:`} name='ip'> <Form.Item label={`${formLables.ip}:`} name="ip">
<Input placeholder="请输入" /> <Input placeholder="请输入" />
</Form.Item> </Form.Item>
<Form.Item label={`${formLables.userName}:`} name='userName'> <Form.Item label={`${formLables.userName}:`} name="userName">
<Input placeholder="请输入" /> <Input placeholder="请输入" />
</Form.Item> </Form.Item>
<Form.Item label={`${formLables.password}:`} name = 'password'> <Form.Item label={`${formLables.password}:`} name="password">
<Input placeholder="请输入" /> <Input placeholder="请输入" />
</Form.Item> </Form.Item>
<Form.Item label={`${formLables.dbName}:`} name = 'dbName'> <Form.Item label={`${formLables.dbName}:`} name="dbName">
<Select <Select
showSearch showSearch
placeholder="请选择" placeholder="请选择"
optionFilterProp="children" optionFilterProp="children"
onFocus = {()=>{selectFocus()}} onFocus={() => {
onChange={(e) =>{onChange(e)}} selectFocus();
}}
onChange={e => {
onChange(e);
}}
filterOption={(input, option) => filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 option.children.toLowerCase().indexOf(input.toLowerCase()) >=
0
} }
> >
{option && option.length>0 &&option.map( (item, index) =>{ {option &&
return (<Option value={item.value} key={index}>{item.value}</Option>) option.length > 0 &&
option.map((item, index) => {
return (
<Option value={item.value} key={index}>
{item.value}
</Option>
);
})} })}
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item > <Form.Item>
<Space size='large'> <Space size="large">
<Button onClick={onCheck}>测试连接</Button> <Button onClick={onCheck}>测试连接</Button>
<Button htmlType='submit'>保存连接</Button> <Button htmlType="submit">保存连接</Button>
<Button htmlType='reset' onClick = { testChlick}>数据库初始化</Button> <Button htmlType="reset" onClick={testChlick}>
数据库初始化
</Button>
</Space> </Space>
<span>{dbForm.inUse}</span> <span>{dbForm.inUse}</span>
</Form.Item> </Form.Item>
...@@ -222,17 +243,23 @@ const InitDataBase = (props) =>{ ...@@ -222,17 +243,23 @@ const InitDataBase = (props) =>{
<Card> <Card>
<div>近期保存的数据库连接</div> <div>近期保存的数据库连接</div>
<Table columns={columns} dataSource={data} bordered loading={tableLoading} <Table
columns={columns}
dataSource={data}
bordered
loading={tableLoading}
onRow={record => { onRow={record => {
return { return {
onClick: () => { tableClick(record)}, // 点击行 onClick: () => {
tableClick(record);
}, // 点击行
}; };
}} }}
/> />
</Card> </Card>
</PageContainer> </PageContainer>
</> </>
) );
} };
export default connect()(InitDataBase); export default connect()(InitDataBase);
import React,{ useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Card, Form, Input, Button, Select, Table, Tag, Space, Modal} from 'antd'; import { Card, Button, Table, Space, Modal } from 'antd';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { connect } from 'react-redux'; import { get } from 'services';
import { get, post } from 'services';
const ManagementDataBase = () => { const ManagementDataBase = () => {
const [autoCheckList, setAutoCheckList] = useState([]) const [autoCheckList, setAutoCheckList] = useState([]);
const [checkList, setCheckList] = useState([]) const [checkList, setCheckList] = useState([]);
const [logList, setLogList] = useState([]) const [logList, setLogList] = useState([]);
const [checkLoading, setCheckLoading] = useState(false) const [checkLoading, setCheckLoading] = useState(false);
const [logLoading, setLogLoading] = useState(false) const [logLoading, setLogLoading] = useState(false);
const [modalVisible, setModalVisible] = useState(false) //弹窗 const [modalVisible, setModalVisible] = useState(false); //弹窗
const [content, setContent] = useState(null) const [content, setContent] = useState(null);
//检查数据库表 //检查数据库表
useEffect( () => { useEffect(() => {
setCheckLoading(true) setCheckLoading(true);
get(`/Cityinterface/rest/services/OMS.svc/TableCheck`,{ get(`/Cityinterface/rest/services/OMS.svc/TableCheck`, {
_version:9999, _version: 9999,
_dc:new Date().getTime() _dc: new Date().getTime(),
}).then(res =>{
setCheckLoading(false)
console.log(res)
if(res.sucess){
const { list, messageList } = res
//自动检测列表
let arr = list.map((item,index) => {
item.key=index
return item
}) })
//手动检查列表 .then(res => {
let arr2 = messageList.map((item,index) => { setCheckLoading(false);
item.key=index console.log(res);
return item if (res.sucess) {
}) const { list, messageList } = res;
console.log(arr) // 自动检测列表
setAutoCheckList(arr) let arr = list.map((item, index) => {
setCheckList(arr2) item.key = index;
return item;
});
// 手动检查列表
let arr2 = messageList.map((item, index) => {
item.key = index;
return item;
});
console.log(arr);
setAutoCheckList(arr);
setCheckList(arr2);
} }
}).catch(err =>{
setCheckLoading(false)
console.error(err)
}) })
},[]) .catch(err => {
setCheckLoading(false);
console.error(err);
});
}, []);
//获取数据库升级记录 //获取数据库升级记录
useEffect( () => { useEffect(() => {
setLogLoading(true) setLogLoading(true);
get(`/Cityinterface/rest/services/OMS.svc/DatabaseStandard_GetLog`,{ get(`/Cityinterface/rest/services/OMS.svc/DatabaseStandard_GetLog`, {
_version:9999, _version: 9999,
_dc:new Date().getTime() _dc: new Date().getTime(),
}).then(res =>{
setLogLoading(false)
console.log(res)
if(res){
let arr = []
res.map((item,index)=>{
item.key = index
arr.push(item)
}) })
setLogList(res) .then(res => {
setLogLoading(false);
console.log(res);
if (res) {
let arr = [];
res.map((item, index) => {
item.key = index;
arr.push(item);
});
setLogList(res);
} }
}).catch(err =>{
setLogLoading(false)
console.error(err)
}) })
},[]) .catch(err => {
const handleCheck = () =>{ setLogLoading(false);
console.log('check DB') console.error(err);
} });
const handleUpdate = () =>{ }, []);
console.log('updatedb') const handleCheck = () => {
} console.log('check DB');
const handleLog = (text) =>{ };
setModalVisible(true) const handleUpdate = () => {
setContent(text) console.log('updatedb');
} };
const handleLog = text => {
setModalVisible(true);
setContent(text);
};
const autoCheckColumns = [ const autoCheckColumns = [
{ {
title:'表名称', title: '表名称',
dataIndex: 'tableName', dataIndex: 'tableName',
key: 'tableName', key: 'tableName',
}, },
{ {
title:'类型', title: '类型',
dataIndex: 'type', dataIndex: 'type',
key: 'type', key: 'type',
}, },
{ {
title:'差异比较', title: '差异比较',
dataIndex: 'message', dataIndex: 'message',
key: 'message', key: 'message',
}, },
]; ];
const checkColumns = [ const checkColumns = [
{ {
title:'表名称', title: '表名称',
dataIndex: 'tableName', dataIndex: 'tableName',
key: 'tableName', key: 'tableName',
width:200 width: 200,
}, },
// { // {
// title:'类型', // title:'类型',
...@@ -105,93 +107,123 @@ const ManagementDataBase = () => { ...@@ -105,93 +107,123 @@ const ManagementDataBase = () => {
// key: 'type', // key: 'type',
// }, // },
{ {
title:'差异比较', title: '差异比较',
dataIndex: 'message', dataIndex: 'message',
key: 'message', key: 'message',
ellipsis:true, ellipsis: true,
// width:80 // width:80
}, },
]; ];
const logColumns = [ const logColumns = [
{ {
title:'登录名', title: '登录名',
dataIndex: 'updateBy', dataIndex: 'updateBy',
key: 'updateBy', key: 'updateBy',
}, },
{ {
title:'数据库名称', title: '数据库名称',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
}, },
{ {
title:'数据库版本', title: '数据库版本',
dataIndex: 'version', dataIndex: 'version',
key: 'version', key: 'version',
}, },
{ {
title:'升级时间', title: '升级时间',
dataIndex: 'updateTime', dataIndex: 'updateTime',
key: 'updateTime', key: 'updateTime',
}, },
{ {
title:'版本日志', title: '版本日志',
dataIndex: 'despersion', dataIndex: 'despersion',
key: 'despersion', key: 'despersion',
render: (text) =>{ render: text => {
return ( return (
<button onClick ={()=>{handleLog(text)}}>日志</button> <button
) onClick={() => {
} handleLog(text);
}}
>
日志
</button>
);
},
}, },
{ {
title:'升级内容', title: '升级内容',
dataIndex: 'content', dataIndex: 'content',
key: 'content', key: 'content',
ellipsis:true, ellipsis: true,
render: (text) =>{ render: text => {
return ( return (
<button onClick ={()=>{handleLog(text)}}>升级内容</button> <button
) onClick={() => {
} handleLog(text);
}}
>
升级内容
</button>
);
},
}, },
] ];
return ( return (
<> <>
<PageContainer> <PageContainer>
<Card> <Card>
<div>表结构自动化修复</div> <div>表结构自动化修复</div>
<Table columns={ autoCheckColumns } dataSource={autoCheckList} bordered loading={checkLoading}></Table> <Table
columns={autoCheckColumns}
dataSource={autoCheckList}
bordered
loading={checkLoading}
/>
<Space> <Space>
<Button onClick= {handleCheck}>检查</Button> <Button onClick={handleCheck}>检查</Button>
<Button onClick= {handleUpdate}>升级</Button> <Button onClick={handleUpdate}>升级</Button>
</Space> </Space>
</Card> </Card>
<Card> <Card>
<div>表字段手动修复 (字段长度不统一,请手动修改差异,数据可能会截断,请谨慎操作)</div> <div>
<Table columns={ checkColumns } dataSource={checkList} bordered loading={checkLoading}></Table> 表字段手动修复
(字段长度不统一,请手动修改差异,数据可能会截断,请谨慎操作)
</div>
<Table
columns={checkColumns}
dataSource={checkList}
bordered
loading={checkLoading}
/>
</Card> </Card>
<Card> <Card>
<div>数据库升级记录</div> <div>数据库升级记录</div>
<Table columns={ logColumns } dataSource={logList} bordered loading={logLoading}></Table> <Table
columns={logColumns}
dataSource={logList}
bordered
loading={logLoading}
/>
</Card> </Card>
</PageContainer> </PageContainer>
<Modal <Modal
title='详细信息' title="详细信息"
visible={modalVisible} visible={modalVisible}
keyboard={false} maskClosable keyboard={false}
maskClosable
onOk={() => setModalVisible(false)} onOk={() => setModalVisible(false)}
onCancel={() => setModalVisible(false)} onCancel={() => setModalVisible(false)}
footer={[ footer={[
<Button onClick={ () => setModalVisible(false)}>关闭窗口</Button> <Button onClick={() => setModalVisible(false)}>关闭窗口</Button>,
]}> ]}
>
{content} {content}
</Modal> </Modal>
</> </>
) );
};
}
export default ManagementDataBase export default ManagementDataBase;
\ No newline at end of file
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