Commit 3717c68a authored by 赵吉's avatar 赵吉

perf: youhua

parent e08c4d7b
...@@ -67,7 +67,7 @@ module.exports = { ...@@ -67,7 +67,7 @@ module.exports = {
'newline-per-chained-call': 0, 'newline-per-chained-call': 0,
'no-confusing-arrow': 0, 'no-confusing-arrow': 0,
'no-console': 1, 'no-console': 1,
'no-unused-vars': 2, 'no-unused-vars': 1,
'no-use-before-define': 0, 'no-use-before-define': 0,
'prefer-template': 2, 'prefer-template': 2,
'react/jsx-wrap-multilines': 0, 'react/jsx-wrap-multilines': 0,
......
import React, { useEffect, useState } from 'react'; import React,{ useEffect, useState } from 'react';
import { Card, Form, Input, Button, Select, Table, Tag, Space } 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 InitDataBase = () => { const { Option } = Select
const [form] = Form.useForm(); const formLables = {
ip:'服务器名或IP地址',
const { Option } = Select; userName:'数据库用户名称',
const onFinish = e => { password:'数据库用户密码',
console.log(e); dbName:'数据库名称',
}; }
const [dbForm, setDbForm] = useState({ const InitDataBase = (props) =>{
ip: '', const [form] = Form.useForm()
dbName: '', const onFinish = (e) =>{
password: '',
userName: '',
inUse: '',
});
const [data, setData] = useState([]);
const url = window.location.host;
console.log(window.location.host);
useEffect(() => {
get(`/Cityinterface/rest/services/OMS.svc/S_GetConnRecord`, {
_version: 9999,
dc: 1603334559186,
})
.then(res => {
if (res.length > 0) {
let arr = res.map((item, index) => {
item.key = index;
return item;
});
setData(arr);
} }
const [tableLoading, setTableLoading] = useState(false)
const [dbForm,setDbForm] = useState({
ip:'',
dbName:'',
password:'',
userName:'',
inUse:'',
}) })
.catch(err => { const [data, setData ] = useState([]) //数据库链接记录
console.error(err); const [option, setOption] =useState([]) //下拉列表数据
}); console.log(window.location.host)
}, []); //获取数据库链接记录
useEffect(() => { useEffect( () =>{
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseConfig`, { setTableLoading(true)
_version: 9999, get(`/Cityinterface/rest/services/OMS.svc/S_GetConnRecord`,{
dc: 1603334559186, _version:9999,
dc:1603334559186
}).then(res =>{
setTableLoading(false)
if(res.length>0){
let arr = res.map( (item,index) =>{
item.key = index
return item
}) })
.then(res => { setData(arr)
// console.log(res);
if (res.success) {
const obj = {};
for (const k in dbForm) {
obj[k] = res[k];
} }
form.setFieldsValue(obj); }).catch(err =>{
setDbForm(obj); setTableLoading(false)
console.error(err)
})
},[])
//获取数据库配置信息
useEffect( () =>{
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseConfig`,{
_version:9999,
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}
}) })
.catch(err => { }
console.error(err); }).catch(err =>{
}); console.error(err)
}, []); })
const testChlick = () => {}; },[])
const onValuesChange = e => { const testChlick = () =>{
form.setFieldsValue(e); }
}; const onValuesChange =(value,b)=>{
const onChange = e => { form.setFieldsValue(value)
console.log(e); }
const onChange = (value) => {
form.setFieldsValue({ form.setFieldsValue({
dbName: e, dbName:value
}); })
}; }
const onCheck = e => { const onCheck = (e) =>{
console.log(dbForm); console.log(dbForm)
console.log(form.getFieldValue()); console.log(form.getFieldValue())
}; console.log(form.getFieldsValue())
const option = [
{ }
value: 'jack', const selectFocus = (e) =>{
}, setOption([])
{ let params =form.getFieldsValue()
value: 'jack1', get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`,{
}, _version:9999,
{ _dc:1603334559186,
value: 'jack2', userName:params['userName']||'',
}, password:params['password']||'',
]; ip:params['ip']||'',
}).then(res =>{
if(res.success){
setOption(res.root)
}else{
notification.error({
message:'通知',
duration:3,
description:res.message
})
setOption([])
}
console.log(res)
}).catch(err =>{
console.error(err)
})
}
//点击表格回显到表单
const tableClick = (item) => {
let obj = {...dbForm}
for(let k in obj){
obj[k] = item[k]
}
form.setFieldsValue(obj)
}
const columns = [ const columns = [
{ {
title: '服务器名或IP地址', title: '服务器名或IP地址',
...@@ -114,63 +147,67 @@ const InitDataBase = () => { ...@@ -114,63 +147,67 @@ const InitDataBase = () => {
title: '修改描述', title: '修改描述',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: () => { render: () =>{
return <button>修改描述</button>; return (
}, <button>修改描述</button>
)
}
}, },
{ {
title: '删除', title: '删除',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: () => { render: () =>{
return <button>删除</button>; return (
}, <button>删除</button>
)
}
}, },
]; ]
return ( return (
<> <>
<PageContainer> <PageContainer>
<Card> <Card>
<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="服务器名或IP地址:" name="ip"> <Form.Item label={`${formLables.ip}:`} name='ip'>
<Input placeholder="请输入" /> <Input placeholder="请输入" />
</Form.Item> </Form.Item>
<Form.Item label="数据库用户名称:" name="userName"> <Form.Item label={`${formLables.userName}:`} name='userName'>
<Input placeholder="请输入" /> <Input placeholder="请输入" />
</Form.Item> </Form.Item>
<Form.Item label="数据库用户密码:" name="password"> <Form.Item label={`${formLables.password}:`} name = 'password'>
<Input placeholder="请输入" /> <Input placeholder="请输入" />
</Form.Item> </Form.Item>
<Form.Item label="数据库名称:" name="dbName"> <Form.Item label={`${formLables.dbName}:`} name = 'dbName'>
<Select <Select
showSearch showSearch
placeholder="请选择" placeholder="请选择"
optionFilterProp="children" optionFilterProp="children"
onChange={onChange} onFocus = {()=>{selectFocus()}}
onChange={(e) =>{onChange(e)}}
filterOption={(input, option) => filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= option.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
0
} }
> >
{option.map(item => { {option && option.length>0 &&option.map( (item, index) =>{
return <Option value={item.value}>{item.value}</Option>; 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 htmlType='reset' onClick = { testChlick}>数据库初始化</Button>
数据库初始化
</Button>
</Space> </Space>
<span>{dbForm.inUse}</span> <span>{dbForm.inUse}</span>
</Form.Item> </Form.Item>
...@@ -182,12 +219,20 @@ const InitDataBase = () => { ...@@ -182,12 +219,20 @@ const InitDataBase = () => {
</div> */} </div> */}
</Form> </Form>
</Card> </Card>
<Card> <Card>
<Table columns={columns} dataSource={data} bordered /> <div>近期保存的数据库连接</div>
<Table columns={columns} dataSource={data} bordered loading={tableLoading}
onRow={record => {
return {
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 } from 'antd'; import { Card, Form, Input, Button, Select, Table, Tag, Space, Modal} 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 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)
useEffect(() => { const [logLoading, setLogLoading] = useState(false)
get(`/Cityinterface/rest/services/OMS.svc/TableCheck`, { const [modalVisible, setModalVisible] = useState(false) //弹窗
_version: 9999, const [content, setContent] = useState(null)
_dc: new Date().getTime(), //检查数据库表
}) useEffect( () => {
.then(res => { setCheckLoading(true)
console.log(res); get(`/Cityinterface/rest/services/OMS.svc/TableCheck`,{
if (res.sucess) { _version:9999,
const { list, messageList } = res; _dc:new Date().getTime()
}).then(res =>{
setCheckLoading(false)
console.log(res)
if(res.sucess){
const { list, messageList } = res
//自动检测列表 //自动检测列表
let arr = list.map((item, index) => { let arr = list.map((item,index) => {
item.key = index; item.key=index
return item; return item
}); })
//手动检查列表 //手动检查列表
let arr2 = messageList.map((item, index) => { let arr2 = messageList.map((item,index) => {
// eslint-disable-next-line no-param-reassign item.key=index
item.key = index; return item
return item; })
}); console.log(arr)
console.log(arr); setAutoCheckList(arr)
setAutoCheckList(arr); setCheckList(arr2)
setCheckList(arr2);
} }
}).catch(err =>{
setCheckLoading(false)
console.error(err)
}) })
.catch(err => { },[])
console.error(err);
});
}, []);
//获取数据库升级记录 //获取数据库升级记录
useEffect(() => { useEffect( () => {
get(`/Cityinterface/rest/services/OMS.svc/DatabaseStandard_GetLog`, { setLogLoading(true)
_version: 9999, get(`/Cityinterface/rest/services/OMS.svc/DatabaseStandard_GetLog`,{
_dc: new Date().getTime(), _version:9999,
_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)
}) })
.then(res => { setLogList(res)
console.log(res);
if (res) {
setLogList(res);
} }
}).catch(err =>{
setLogLoading(false)
console.error(err)
}) })
.catch(err => { },[])
console.error(err); const handleCheck = () =>{
}); console.log('check DB')
}, []); }
const handleCheck = () => { const handleUpdate = () =>{
console.log('check DB'); console.log('updatedb')
}; }
const handleUpdate = () => { const handleLog = (text) =>{
console.log('updatedb'); 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: '类型',
dataIndex: 'type',
key: 'type',
}, },
// {
// title:'类型',
// dataIndex: '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',
key: 'version',
},
{
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) =>{
return (
<button onClick ={()=>{handleLog(text)}}>日志</button>
)
}
}, },
{ {
title: '升级内容', title:'升级内容',
dataIndex: 'content', dataIndex: 'content',
key: 'content', key: 'content',
ellipsis: true, ellipsis:true,
render: (text) =>{
return (
<button onClick ={()=>{handleLog(text)}}>升级内容</button>
)
}
}, },
]; ]
return ( return (
<> <>
<PageContainer> <PageContainer>
<Card> <Card>
<Table <div>表结构自动化修复</div>
columns={autoCheckColumns} <Table columns={ autoCheckColumns } dataSource={autoCheckList} bordered loading={checkLoading}></Table>
dataSource={autoCheckList}
bordered
/>
<Space> <Space>
<Button onClick={handleCheck}>检查</Button> <Button onClick= {handleCheck}>检查</Button>
<Button onClick={handleUpdate}>升级</Button> <Button onClick= {handleUpdate}>升级</Button>
</Space> </Space>
</Card> </Card>
<Card> <Card>
<Table columns={checkColumns} dataSource={checkList} bordered /> <div>表字段手动修复 (字段长度不统一,请手动修改差异,数据可能会截断,请谨慎操作)</div>
<Table columns={ checkColumns } dataSource={checkList} bordered loading={checkLoading}></Table>
</Card> </Card>
<Card> <Card>
<Table columns={logColumns} dataSource={logList} bordered /> <div>数据库升级记录</div>
<Table columns={ logColumns } dataSource={logList} bordered loading={logLoading}></Table>
</Card> </Card>
</PageContainer> </PageContainer>
<Modal
title='详细信息'
visible={modalVisible}
keyboard={false} maskClosable
onOk={() => setModalVisible(false)}
onCancel={() => setModalVisible(false)}
footer={[
<Button onClick={ () => setModalVisible(false)}>关闭窗口</Button>
]}>
{content}
</Modal>
</> </>
); )
};
}
export default ManagementDataBase; export default ManagementDataBase
\ No newline at end of file
...@@ -2,10 +2,9 @@ import UserLayout from '../layouts/UserLayout'; ...@@ -2,10 +2,9 @@ import UserLayout from '../layouts/UserLayout';
import Login from '../pages/user/login'; import Login from '../pages/user/login';
import BasicLayout from '../layouts/BasicLayout'; import BasicLayout from '../layouts/BasicLayout';
import Welcome from '../pages/Welcome'; import Welcome from '../pages/Welcome';
import RequestTest from '../pages/testPages/request';
import InitDataBase from '../pages/database/InitDataBase'; import InitDataBase from '../pages/database/InitDataBase';
import ManagementDataBase from '../pages/database/ManagementDataBase'; import ManagementDataBase from '../pages/database/ManagementDataBase';
// import OrgAndUser from '../pages/organization/OrgAndUser';
export default { export default {
routes: [ routes: [
{ {
......
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