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 [option, setOption] = useState([]); //下拉列表数据
console.log(window.location.host);
//获取数据库链接记录
useEffect(() => {
setTableLoading(true);
get(`/Cityinterface/rest/services/OMS.svc/S_GetConnRecord`, {
_version: 9999,
dc: 1603334559186,
}) })
const [data, setData ] = useState([]) //数据库链接记录 .then(res => {
const [option, setOption] =useState([]) //下拉列表数据 setTableLoading(false);
console.log(window.location.host) if (res.length > 0) {
//获取数据库链接记录 let arr = res.map((item, index) => {
useEffect( () =>{ item.key = index;
setTableLoading(true) return item;
get(`/Cityinterface/rest/services/OMS.svc/S_GetConnRecord`,{ });
_version:9999, setData(arr);
dc:1603334559186 }
}).then(res =>{ })
setTableLoading(false) .catch(err => {
if(res.length>0){ setTableLoading(false);
let arr = res.map( (item,index) =>{ console.error(err);
item.key = index });
return item }, []);
}) //获取数据库配置信息
setData(arr) useEffect(() => {
} get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseConfig`, {
}).catch(err =>{ _version: 9999,
setTableLoading(false) dc: 1603334559186,
console.error(err) })
}) .then(res => {
},[]) console.log(res);
//获取数据库配置信息 if (res.success) {
useEffect( () =>{ let obj = {};
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseConfig`,{ for (let k in dbForm) {
_version:9999, obj[k] = res[k];
dc:1603334559186 }
}).then(res =>{ form.setFieldsValue(obj);
console.log(res) setDbForm(val => {
if(res.success){ return { ...val, ...obj };
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) => {
}).catch(err =>{ form.setFieldsValue(value);
console.error(err) };
}) const onChange = value => {
},[]) form.setFieldsValue({
const testChlick = () =>{ dbName: value,
} });
const onValuesChange =(value,b)=>{ };
form.setFieldsValue(value) const onCheck = e => {
} console.log(dbForm);
const onChange = (value) => { console.log(form.getFieldValue());
form.setFieldsValue({ console.log(form.getFieldsValue());
dbName:value };
}) const selectFocus = e => {
} setOption([]);
const onCheck = (e) =>{ let params = form.getFieldsValue();
console.log(dbForm) get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`, {
console.log(form.getFieldValue()) _version: 9999,
console.log(form.getFieldsValue()) _dc: 1603334559186,
userName: params['userName'] || '',
} password: params['password'] || '',
const selectFocus = (e) =>{ ip: params['ip'] || '',
setOption([]) })
let params =form.getFieldsValue() .then(res => {
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`,{ if (res.success) {
_version:9999, setOption(res.root);
_dc:1603334559186, } else {
userName:params['userName']||'', notification.error({
password:params['password']||'', message: '通知',
ip:params['ip']||'', duration: 3,
}).then(res =>{ description: res.message,
if(res.success){ });
setOption(res.root) setOption([]);
}else{ }
notification.error({ console.log(res);
message:'通知', })
duration:3, .catch(err => {
description:res.message console.error(err);
}) });
setOption([]) };
} //点击表格回显到表单
console.log(res) const tableClick = item => {
}).catch(err =>{ let obj = { ...dbForm };
console.error(err) for (let k in obj) {
}) obj[k] = item[k];
}
//点击表格回显到表单
const tableClick = (item) => {
let obj = {...dbForm}
for(let k in obj){
obj[k] = item[k]
}
form.setFieldsValue(obj)
} }
const columns = [ form.setFieldsValue(obj);
{ };
title: '服务器名或IP地址', const columns = [
dataIndex: 'ip', {
key: 'ip', title: '服务器名或IP地址',
}, dataIndex: 'ip',
{ key: 'ip',
title: '数据库名称', },
dataIndex: 'dbName', {
key: 'dbName', title: '数据库名称',
}, dataIndex: 'dbName',
{ key: 'dbName',
title: '数据库用户名称', },
dataIndex: 'userName', {
key: 'userName', title: '数据库用户名称',
}, dataIndex: 'userName',
{ key: 'userName',
title: '保存时间', },
dataIndex: 'saveTime', {
key: 'saveTime', title: '保存时间',
}, dataIndex: 'saveTime',
{ key: 'saveTime',
title: '描述', },
dataIndex: 'desc', {
key: 'desc', title: '描述',
}, dataIndex: 'desc',
{ key: 'desc',
title: '修改描述', },
dataIndex: 'name', {
key: 'name', title: '修改描述',
render: () =>{ dataIndex: 'name',
return ( key: 'name',
<button>修改描述</button> render: () => {
) return <button>修改描述</button>;
} },
}, },
{ {
title: '删除', title: '删除',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: () =>{ render: () => {
return ( return <button>删除</button>;
<button>删除</button> },
) },
} ];
}, return (
] <>
return ( <PageContainer>
<> <Card>
<PageContainer> <div>数据库初始化</div>
<Card> <div />
<div>数据库初始化</div> <Form
<div></div> layout="horizontal"
<Form labelAlign="left"
layout="horizontal" labelCol={{ span: 3 }}
labelAlign='left' form={form}
labelCol={{span:3}} onFinish={onFinish}
form={form} onValuesChange={onValuesChange}
onFinish={onFinish} >
onValuesChange= {onValuesChange} <Form.Item label={`${formLables.ip}:`} name="ip">
> <Input placeholder="请输入" />
<Form.Item label={`${formLables.ip}:`} name='ip'> </Form.Item>
<Input placeholder="请输入" /> <Form.Item label={`${formLables.userName}:`} name="userName">
</Form.Item> <Input placeholder="请输入" />
<Form.Item label={`${formLables.userName}:`} name='userName'> </Form.Item>
<Input placeholder="请输入" /> <Form.Item label={`${formLables.password}:`} name="password">
</Form.Item> <Input placeholder="请输入" />
<Form.Item label={`${formLables.password}:`} name = 'password'> </Form.Item>
<Input placeholder="请输入" /> <Form.Item label={`${formLables.dbName}:`} name="dbName">
</Form.Item> <Select
<Form.Item label={`${formLables.dbName}:`} name = 'dbName'> showSearch
<Select placeholder="请选择"
showSearch optionFilterProp="children"
placeholder="请选择" onFocus={() => {
optionFilterProp="children" selectFocus();
onFocus = {()=>{selectFocus()}} }}
onChange={(e) =>{onChange(e)}} onChange={e => {
filterOption={(input, option) => onChange(e);
option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0 }}
} filterOption={(input, option) =>
> option.children.toLowerCase().indexOf(input.toLowerCase()) >=
{option && option.length>0 &&option.map( (item, index) =>{ 0
return (<Option value={item.value} key={index}>{item.value}</Option>) }
})} >
</Select> {option &&
</Form.Item> option.length > 0 &&
<Form.Item > option.map((item, index) => {
<Space size='large'> return (
<Button onClick={onCheck}>测试连接</Button> <Option value={item.value} key={index}>
<Button htmlType='submit'>保存连接</Button> {item.value}
<Button htmlType='reset' onClick = { testChlick}>数据库初始化</Button> </Option>
</Space> );
<span>{dbForm.inUse}</span> })}
</Form.Item> </Select>
{/* <div className={`btnBox`}> </Form.Item>
<Form.Item>
<Space size="large">
<Button onClick={onCheck}>测试连接</Button>
<Button htmlType="submit">保存连接</Button>
<Button htmlType="reset" onClick={testChlick}>
数据库初始化
</Button>
</Space>
<span>{dbForm.inUse}</span>
</Form.Item>
{/* <div className={`btnBox`}>
<Button onClick={onCheck}>测试连接</Button> <Button onClick={onCheck}>测试连接</Button>
<Button>保存连接</Button> <Button>保存连接</Button>
<Button>数据库初始化</Button> <Button>数据库初始化</Button>
<span>(产品方案(物联GCK))</span> <span>(产品方案(物联GCK))</span>
</div> */} </div> */}
</Form> </Form>
</Card> </Card>
<Card> <Card>
<div>近期保存的数据库连接</div> <div>近期保存的数据库连接</div>
<Table columns={columns} dataSource={data} bordered loading={tableLoading} <Table
onRow={record => { columns={columns}
return { dataSource={data}
onClick: () => { tableClick(record)}, // 点击行 bordered
}; loading={tableLoading}
}} onRow={record => {
/> return {
</Card> onClick: () => {
</PageContainer> tableClick(record);
</> }, // 点击行
) };
} }}
/>
</Card>
</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) .then(res => {
console.log(res) setCheckLoading(false);
if(res.sucess){ console.log(res);
const { list, messageList } = res if (res.sucess) {
//自动检测列表 const { list, messageList } = res;
let arr = list.map((item,index) => { // 自动检测列表
item.key=index let arr = list.map((item, index) => {
return item item.key = index;
}) return item;
//手动检查列表 });
let arr2 = messageList.map((item,index) => { // 手动检查列表
item.key=index let arr2 = messageList.map((item, index) => {
return item item.key = index;
}) return item;
console.log(arr) });
setAutoCheckList(arr) console.log(arr);
setCheckList(arr2) setAutoCheckList(arr);
} setCheckList(arr2);
}).catch(err =>{ }
setCheckLoading(false) })
console.error(err) .catch(err => {
}) setCheckLoading(false);
},[]) console.error(err);
//获取数据库升级记录 });
useEffect( () => { }, []);
setLogLoading(true) //获取数据库升级记录
get(`/Cityinterface/rest/services/OMS.svc/DatabaseStandard_GetLog`,{ useEffect(() => {
_version:9999, setLogLoading(true);
_dc:new Date().getTime() get(`/Cityinterface/rest/services/OMS.svc/DatabaseStandard_GetLog`, {
}).then(res =>{ _version: 9999,
setLogLoading(false) _dc: new Date().getTime(),
console.log(res) })
if(res){ .then(res => {
let arr = [] setLogLoading(false);
res.map((item,index)=>{ console.log(res);
item.key = index if (res) {
arr.push(item) let arr = [];
}) res.map((item, index) => {
setLogList(res) item.key = index;
} arr.push(item);
}).catch(err =>{ });
setLogLoading(false) setLogList(res);
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 autoCheckColumns = [ const handleLog = text => {
{ setModalVisible(true);
title:'表名称', setContent(text);
dataIndex: 'tableName', };
key: 'tableName', const autoCheckColumns = [
}, {
{ title: '表名称',
title:'类型', dataIndex: 'tableName',
dataIndex: 'type', key: 'tableName',
key: 'type', },
}, {
{ title: '类型',
title:'差异比较', dataIndex: 'type',
dataIndex: 'message', key: 'type',
key: 'message', },
}, {
title: '差异比较',
]; dataIndex: 'message',
const checkColumns = [ key: 'message',
{ },
title:'表名称', ];
dataIndex: 'tableName', const checkColumns = [
key: 'tableName', {
width:200 title: '表名称',
}, dataIndex: 'tableName',
// { key: 'tableName',
// title:'类型', width: 200,
// dataIndex: 'type', },
// key: 'type', // {
// }, // title:'类型',
{ // dataIndex: 'type',
title:'差异比较', // key: 'type',
dataIndex: 'message', // },
key: 'message', {
ellipsis:true, title: '差异比较',
// width:80 dataIndex: 'message',
}, key: 'message',
]; ellipsis: true,
const logColumns = [ // width:80
{ },
title:'登录名', ];
dataIndex: 'updateBy', const logColumns = [
key: 'updateBy', {
}, title: '登录名',
{ dataIndex: 'updateBy',
title:'数据库名称', key: 'updateBy',
dataIndex: 'name', },
key: 'name', {
}, title: '数据库名称',
{ dataIndex: 'name',
title:'数据库版本', key: 'name',
dataIndex: 'version', },
key: 'version', {
}, title: '数据库版本',
{ dataIndex: 'version',
title:'升级时间', key: 'version',
dataIndex: 'updateTime', },
key: 'updateTime', {
}, title: '升级时间',
{ dataIndex: 'updateTime',
title:'版本日志', key: 'updateTime',
dataIndex: 'despersion', },
key: 'despersion', {
render: (text) =>{ title: '版本日志',
return ( dataIndex: 'despersion',
<button onClick ={()=>{handleLog(text)}}>日志</button> key: 'despersion',
) render: text => {
} return (
}, <button
{ onClick={() => {
title:'升级内容', handleLog(text);
dataIndex: 'content', }}
key: 'content', >
ellipsis:true, 日志
render: (text) =>{ </button>
return ( );
<button onClick ={()=>{handleLog(text)}}>升级内容</button> },
) },
} {
}, title: '升级内容',
] dataIndex: 'content',
key: 'content',
ellipsis: true,
render: text => {
return (
<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
<Space> columns={autoCheckColumns}
<Button onClick= {handleCheck}>检查</Button> dataSource={autoCheckList}
<Button onClick= {handleUpdate}>升级</Button> bordered
</Space> loading={checkLoading}
</Card> />
<Card> <Space>
<div>表字段手动修复 (字段长度不统一,请手动修改差异,数据可能会截断,请谨慎操作)</div> <Button onClick={handleCheck}>检查</Button>
<Table columns={ checkColumns } dataSource={checkList} bordered loading={checkLoading}></Table> <Button onClick={handleUpdate}>升级</Button>
</Card> </Space>
<Card> </Card>
<div>数据库升级记录</div> <Card>
<Table columns={ logColumns } dataSource={logList} bordered loading={logLoading}></Table> <div>
</Card> 表字段手动修复
</PageContainer> (字段长度不统一,请手动修改差异,数据可能会截断,请谨慎操作)
</div>
<Table
columns={checkColumns}
dataSource={checkList}
bordered
loading={checkLoading}
/>
</Card>
<Card>
<div>数据库升级记录</div>
<Table
columns={logColumns}
dataSource={logList}
bordered
loading={logLoading}
/>
</Card>
</PageContainer>
<Modal <Modal
title='详细信息' title="详细信息"
visible={modalVisible} visible={modalVisible}
keyboard={false} maskClosable keyboard={false}
onOk={() => setModalVisible(false)} maskClosable
onCancel={() => setModalVisible(false)} onOk={() => setModalVisible(false)}
footer={[ onCancel={() => setModalVisible(false)}
<Button onClick={ () => setModalVisible(false)}>关闭窗口</Button> footer={[
]}> <Button onClick={() => setModalVisible(false)}>关闭窗口</Button>,
{content} ]}
</Modal> >
</> {content}
) </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