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