Commit 20da8a93 authored by 张烨's avatar 张烨

style: fix lint

parent 40f1b6a5
...@@ -10,12 +10,12 @@ import { ...@@ -10,12 +10,12 @@ import {
notification, notification,
Modal, Modal,
Row, Row,
Col Col,
} from 'antd'; } 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';
import styles from './InitDataBase.less' import styles from './InitDataBase.less';
const { Option } = Select; const { Option } = Select;
const formLables = { const formLables = {
...@@ -26,7 +26,7 @@ const formLables = { ...@@ -26,7 +26,7 @@ const formLables = {
}; };
const InitDataBase = props => { const InitDataBase = props => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const [tableLoading, setTableLoading] = useState(false);//连接记录 const [tableLoading, setTableLoading] = useState(false); // 连接记录
const [dbForm, setDbForm] = useState({ const [dbForm, setDbForm] = useState({
ip: '', ip: '',
dbName: '', dbName: '',
...@@ -34,13 +34,13 @@ const InitDataBase = props => { ...@@ -34,13 +34,13 @@ const InitDataBase = props => {
userName: '', userName: '',
inUse: '', inUse: '',
}); });
const [data, setData] = useState([]); //数据库链接记录 const [data, setData] = useState([]); // 数据库链接记录
const [upData,setUpData] = useState(1);//列表刷新标记 const [upData, setUpData] = useState(1); // 列表刷新标记
const [option, setOption] = useState([]); //下拉列表数据 const [option, setOption] = useState([]); // 下拉列表数据
const [desc, setDesc] = useState('');//修改描述 const [desc, setDesc] = useState(''); // 修改描述
const [modalVisible, setModalVisible] = useState(false) const [modalVisible, setModalVisible] = useState(false);
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`, {
...@@ -62,30 +62,28 @@ const InitDataBase = props => { ...@@ -62,30 +62,28 @@ const InitDataBase = props => {
console.error(err); console.error(err);
}); });
}, [upData]); }, [upData]);
//获取数据库配置信息 // 获取数据库配置信息
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 => { .then(res => {
console.log(res,'69res'); console.log(res, '69res');
if (res.success) { if (res.success) {
let obj = {}; let obj = {};
for (let k in dbForm) { Object.keys(dbForm).forEach(k => {
obj[k] = res[k]; obj[k] = res[k];
}
form.setFieldsValue(obj);
setDbForm(val => {
return { ...val, ...obj };
}); });
form.setFieldsValue(obj);
setDbForm(val => ({ ...val, ...obj }));
} }
}) })
.catch(err => { .catch(err => {
console.error(err); console.error(err);
}); });
}, []); }, []);
//数据库初始化 // 数据库初始化
const initClick = () => {}; const initClick = () => {};
const onValuesChange = (value, b) => { const onValuesChange = (value, b) => {
form.setFieldsValue(value); form.setFieldsValue(value);
...@@ -95,75 +93,79 @@ const InitDataBase = props => { ...@@ -95,75 +93,79 @@ const InitDataBase = props => {
dbName: value, dbName: value,
}); });
}; };
//保存连接 // 保存连接
const onFinish = values => { const onFinish = values => {
const obj = values const obj = values;
get('/Cityinterface/rest/services/OMS.svc/S_SaveConnection',{ get('/Cityinterface/rest/services/OMS.svc/S_SaveConnection', {
_version:9999, _version: 9999,
_dc:new Date().getTime(), _dc: new Date().getTime(),
ip:obj.ip, ip: obj.ip,
dbName:obj.dbName, dbName: obj.dbName,
userName:obj.userName, userName: obj.userName,
password:obj.password password: obj.password,
}).then(res =>{ })
if(res.GetMe===true){ .then(res => {
setUpData(upData+1) if (res.GetMe === true) {
notification.success({ setUpData(upData + 1);
message: '通知', notification.success({
duration: 3, message: '通知',
description: '保存成功', duration: 3,
}); description: '保存成功',
}else{ });
} else {
notification.error({
message: '提示',
duration: 3,
description: res.Say.Message || '保存失败',
});
}
})
.catch(err => {
console.log(err);
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: res.Say.Message||'保存失败', description: err || '保存失败',
}); });
}
}).catch(err =>{
console.log(err)
notification.error({
message: '提示',
duration: 3,
description: err||'保存失败',
}); });
})
}; };
const onCheck = e => { const onCheck = e => {
//测试连接 // 测试连接
console.log(dbForm); console.log(dbForm);
console.log(form.getFieldValue()); console.log(form.getFieldValue());
console.log(form.getFieldsValue()); console.log(form.getFieldsValue());
const obj = form.getFieldsValue() const obj = form.getFieldsValue();
get('/Cityinterface/rest/services/OMS.svc/S_GetConnectionTest',{ get('/Cityinterface/rest/services/OMS.svc/S_GetConnectionTest', {
_version:9999, _version: 9999,
_dc:new Date().getTime(), _dc: new Date().getTime(),
ip:obj.ip, ip: obj.ip,
dbName:obj.dbName, dbName: obj.dbName,
userName:obj.userName, userName: obj.userName,
password:obj.password password: obj.password,
}).then(res =>{ })
if(res.GetMe===true){ .then(res => {
notification.success({ if (res.GetMe === true) {
message: '通知', notification.success({
duration: 3, message: '通知',
description: '连接成功', duration: 3,
}); description: '连接成功',
}else{ });
} else {
notification.error({
message: '提示',
duration: 3,
description: res.Say.Message || '连接失败',
});
}
})
.catch(err => {
console.log(err);
notification.error({ notification.error({
message: '提示', message: '提示',
duration: 3, duration: 3,
description: res.Say.Message||'连接失败', description: err || '连接失败',
}); });
}
}).catch(err =>{
console.log(err)
notification.error({
message: '提示',
duration: 3,
description: err||'连接失败',
}); });
})
}; };
const selectFocus = e => { const selectFocus = e => {
setOption([]); setOption([]);
...@@ -171,9 +173,9 @@ const InitDataBase = props => { ...@@ -171,9 +173,9 @@ const InitDataBase = props => {
get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`, { get(`/Cityinterface/rest/services/OMS.svc/S_GetDataBaseList`, {
_version: 9999, _version: 9999,
_dc: 1603334559186, _dc: 1603334559186,
userName: params['userName'] || '', userName: params.userName || '',
password: params['password'] || '', password: params.password || '',
ip: params['ip'] || '', ip: params.ip || '',
}) })
.then(res => { .then(res => {
if (res.success) { if (res.success) {
...@@ -192,45 +194,47 @@ const InitDataBase = props => { ...@@ -192,45 +194,47 @@ const InitDataBase = props => {
console.error(err); console.error(err);
}); });
}; };
//点击表格回显到表单 // 点击表格回显到表单
const tableClick = item => { const tableClick = item => {
let obj = { ...dbForm }; let obj = { ...dbForm };
for (let k in obj) { Object.keys(obj).forEach(k => {
obj[k] = item[k]; obj[k] = item[k];
} });
form.setFieldsValue(obj); form.setFieldsValue(obj);
}; };
//展示修改描述 // 展示修改描述
const changeDesc = () => { const changeDesc = () => {
setModalVisible(true) setModalVisible(true);
setDesc('') setDesc('');
} };
const descChange = (e) =>{ const descChange = e => {
const { value } = e.target const { value } = e.target;
setDesc(value) setDesc(value);
} };
//弹窗确认回调 // 弹窗确认回调
const modalOkCallback = () =>{ const modalOkCallback = () => {
console.log(form.getFieldsValue()); console.log(form.getFieldsValue());
const obj = form.getFieldsValue() const obj = form.getFieldsValue();
//更新描述 // 更新描述
get('/Cityinterface/rest/services/OMS.svc/S_UpdateConnDesc',{ get('/Cityinterface/rest/services/OMS.svc/S_UpdateConnDesc', {
_version:9999, _version: 9999,
_dc:new Date().getTime(), _dc: new Date().getTime(),
ip:obj.ip, ip: obj.ip,
dbName:obj.dbName, dbName: obj.dbName,
userName:obj.userName, userName: obj.userName,
password:obj.password, password: obj.password,
desc desc,
}).then(res =>{
console.log(res)
setModalVisible(false)
setUpData(upData+1)
}).catch(err =>{
console.error(err)
setModalVisible(false)
}) })
} .then(res => {
console.log(res);
setModalVisible(false);
setUpData(upData + 1);
})
.catch(err => {
console.error(err);
setModalVisible(false);
});
};
const columns = [ const columns = [
{ {
title: '服务器名或IP地址', title: '服务器名或IP地址',
...@@ -261,18 +265,28 @@ const InitDataBase = props => { ...@@ -261,18 +265,28 @@ const InitDataBase = props => {
title: '修改描述', title: '修改描述',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: () => { render: () => (
return <Button type='primary' size='small' onClick={ ()=>{changeDesc()}}>修改描述</Button>; <Button
}, type="primary"
size="small"
onClick={() => {
changeDesc();
}}
>
修改描述
</Button>
),
}, },
{ {
title: '删除', title: '删除',
dataIndex: 'name', dataIndex: 'name',
key: 'name', key: 'name',
render: () => { render: () => (
return <Button size='small' danger>删除</Button>; <Button size="small" danger>
}, 删除
</Button>
),
}, },
]; ];
return ( return (
...@@ -309,6 +323,7 @@ const InitDataBase = props => { ...@@ -309,6 +323,7 @@ const InitDataBase = props => {
onChange={e => { onChange={e => {
onChange(e); onChange(e);
}} }}
// eslint-disable-next-line no-shadow
filterOption={(input, option) => filterOption={(input, option) =>
option.children.toLowerCase().indexOf(input.toLowerCase()) >= option.children.toLowerCase().indexOf(input.toLowerCase()) >=
0 0
...@@ -316,26 +331,37 @@ const InitDataBase = props => { ...@@ -316,26 +331,37 @@ const InitDataBase = props => {
> >
{option && {option &&
option.length > 0 && option.length > 0 &&
option.map((item, index) => { option.map((item, index) => (
return ( <Option value={item.value} key={index}>
<Option value={item.value} key={index}> {item.value}
{item.value} </Option>
</Option> ))}
);
})}
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item> <Form.Item>
<div className={styles.tCenter}> <div className={styles.tCenter}>
<Space size="large"> <Space size="large">
<Button onClick={onCheck}>测试连接</Button> <Button onClick={onCheck}>测试连接</Button>
<Button type='primary' htmlType="submit" loading={tableLoading}>保存连接</Button> <Button
<Button type='primary' danger htmlType="reset" onClick={()=>{initClick()}}> type="primary"
htmlType="submit"
loading={tableLoading}
>
保存连接
</Button>
<Button
type="primary"
danger
htmlType="reset"
onClick={() => {
initClick();
}}
>
数据库初始化 数据库初始化
</Button> </Button>
<span>{dbForm.inUse}</span> <span>{dbForm.inUse}</span>
</Space> </Space>
</div> </div>
</Form.Item> </Form.Item>
</Form> </Form>
</Card> </Card>
...@@ -343,41 +369,45 @@ const InitDataBase = props => { ...@@ -343,41 +369,45 @@ const InitDataBase = props => {
<Card className={styles.mgTop20}> <Card className={styles.mgTop20}>
<div className={styles.tableTitle}>近期保存的数据库连接</div> <div className={styles.tableTitle}>近期保存的数据库连接</div>
<Table <Table
style={{marginTop:'20px'}} style={{ marginTop: '20px' }}
columns={columns} columns={columns}
dataSource={data} dataSource={data}
bordered bordered
loading={tableLoading} loading={tableLoading}
size='small' size="small"
onRow={record => { onRow={record => ({
return { onClick: () => {
onClick: () => { tableClick(record);
tableClick(record); }, // 点击行
}, // 点击行 })}
};
}}
/> />
</Card> </Card>
<Modal <Modal
title='修改链接描述' title="修改链接描述"
visible={modalVisible} visible={modalVisible}
maskClosable maskClosable
onOk={() => modalOkCallback() } onOk={() => modalOkCallback()}
onCancel={() => setModalVisible(false)} onCancel={() => setModalVisible(false)}
width="1000px" width="1000px"
bodyStyle={{ bodyStyle={{
minHeight:'100px' minHeight: '100px',
}} }}
cancelText='取消' cancelText="取消"
okText='确认修改' okText="确认修改"
destroyOnClose={true} destroyOnClose
> >
<Row > <Row>
<Col span={1} className={styles.decsBox}>描述:</Col> <Col span={1} className={styles.decsBox}>
<Col span={11} > 描述:
<Input placeholder='请输入描述' onChange={(value)=>{ </Col>
descChange(value) <Col span={11}>
}}></Input></Col> <Input
placeholder="请输入描述"
onChange={value => {
descChange(value);
}}
/>
</Col>
</Row> </Row>
</Modal> </Modal>
</PageContainer> </PageContainer>
......
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