Commit 9685d053 authored by 陈前坚's avatar 陈前坚

perf: log

parent 83d59719
......@@ -14,6 +14,7 @@ import { Chart, Interval, Tooltip, Axis } from 'bizcharts';
import { DataSet } from '@antv/data-set';
import moment from 'moment';
import { post, PUBLISH_SERVICE } from '@/services/index';
import styles from './index.less';
const ServiceLog = () => {
const [loading, setLoading] = useState(false); // 源数据
......@@ -138,72 +139,76 @@ const ServiceLog = () => {
return (
<>
<Row style={{ padding: '10px', background: 'white' }}>
<Col span={24}>
<span style={{ lineHeight: 2 }}>时间:</span>
<DatePicker
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="起始时间"
value={startTime}
onChange={changeStartTime}
allowClear={false}
/>
<SwapRightOutlined style={{ lineHeight: 2 }} />
<DatePicker
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="结束时间"
value={endTime}
onChange={changeEndTime}
style={{ marginRight: '10px' }}
allowClear={false}
/>
<Button onClick={() => setTime(1)}>1小时</Button>
<Button onClick={() => setTime(6)}>6小时</Button>
<Button onClick={() => setTime(12)}>12小时</Button>
<Button onClick={() => setTime(24)}>1</Button>
<Button onClick={() => setTime(24 * 7)}>1</Button>
</Col>
</Row>
<Spin spinning={loading} tip="loading">
<Row style={{ padding: '10px', background: 'white' }}>
<Col span={12}>
<Chart
height={316}
width={400}
autoFit
data={IPCount}
interactions={['active-region']}
padding="auto"
>
<Axis
name="IP"
label="null"
title={{ offset: 20, position: 'end' }}
/>
<Axis name="计数" title />
<Interval position="IP*计数" />
<Tooltip shared />
</Chart>
<div className={styles.serviceLog}>
<Row className={styles.head}>
<Col span={24}>
<span style={{ lineHeight: 2 }}>时间:</span>
<DatePicker
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="起始时间"
value={startTime}
onChange={changeStartTime}
allowClear={false}
/>
<SwapRightOutlined style={{ lineHeight: 2 }} />
<DatePicker
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="结束时间"
value={endTime}
onChange={changeEndTime}
style={{ marginRight: '10px' }}
allowClear={false}
/>
<Button onClick={() => setTime(1)}>1小时</Button>
<Button onClick={() => setTime(6)}>6小时</Button>
<Button onClick={() => setTime(12)}>12小时</Button>
<Button onClick={() => setTime(24)}>1</Button>
<Button onClick={() => setTime(24 * 7)}>1</Button>
</Col>
</Row>
<Table
size="small"
bordered
columns={columns}
dataSource={data0}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 10,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</Spin>
<Spin spinning={loading} tip="loading">
<Row className={styles.chart}>
<Col span={12}>
<Chart
height={316}
width={400}
autoFit
data={IPCount}
interactions={['active-region']}
padding="auto"
>
<Axis
name="IP"
label="null"
title={{ offset: 20, position: 'end' }}
/>
<Axis name="计数" title />
<Interval position="IP*计数" />
<Tooltip shared />
</Chart>
</Col>
</Row>
<div className={styles.table}>
<Table
size="small"
bordered
columns={columns}
dataSource={data0}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 10,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</div>
</Spin>
</div>
</>
);
};
......
.serviceLog{
.head{
padding: 10px;
background: white;
margin-bottom: 2px;
min-width: 1030px;
}
.chart{
padding: 16px;
background: white;
}
.table{
border-top: 1px solid #f0eded;
// overflow: auto;//不要这个,pagination否则无法固定底部
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.ant-table-content{
height:calc(100vh - 518px);
border-right: white;
overflow: auto !important;
}
.ant-pagination{
z-index: 999;
border-top: 1px solid #f0eded;
}
.ant-table-pagination{
padding-right: 12px;
background: white;
margin: 1px 0;
padding:8px;
padding-right: 20px;
}
}
}
\ No newline at end of file
......@@ -10,17 +10,27 @@
background: white;
}
.table{
height:calc(100vh - 452px);
overflow: auto;
border-top: 1px solid #f0eded;
// overflow: auto;//不要这个,pagination否则无法固定底部
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.ant-table-content{
height:calc(100vh - 500px);
border-right: white;
overflow: auto !important;
}
.ant-pagination{
z-index: 999;
border-top: 1px solid #f0eded;
}
.ant-table-pagination{
padding-right: 12px;
background: white;
margin: 2px 0px;
padding:6px 10px;
}
}
margin: 1px 0;
padding:8px;
padding-right: 20px;
}
}
}
\ No newline at end of file
......@@ -10,17 +10,27 @@
background: white;
}
.table{
height:calc(100vh - 452px);
overflow: auto;
border-top: 1px solid #f0eded;
// overflow: auto;//不要这个,pagination否则无法固定底部
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.ant-table-content{
height:calc(100vh - 500px);
border-right: white;
overflow: auto !important;
}
.ant-pagination{
z-index: 999;
border-top: 1px solid #f0eded;
}
.ant-table-pagination{
padding-right: 12px;
background: white;
margin: 2px 0px;
padding:6px 10px;
}
}
margin: 1px 0;
padding:8px;
padding-right: 20px;
}
}
}
\ No newline at end of file
import React from 'react';
import { Table, Row, Col } from 'antd';
import React, { useState, useEffect } from 'react';
import {
Table,
Spin,
Modal,
Form,
Input,
Space,
Button,
Popconfirm,
notification,
message,
} from 'antd';
import { get } from '@/services/index';
import styles from './AppDic.less';
const AppDic = () => {
const [loading, setLoading] = useState(false);
const [addVisible, setAddVisible] = useState(false);
const [editVisible, setEditVisible] = useState(false);
const [data, setData] = useState([]); // 表数据
const [select, setSelect] = useState({}); // 当前选中条目,修改/删除时设置
const [addForm] = Form.useForm();
const [editForm] = Form.useForm();
const columns = [
{
title: '名称',
dataIndex: 'Label',
key: 'Label',
},
{
title: '键名',
dataIndex: 'Key',
key: 'Key',
},
{
title: '值',
dataIndex: 'Value',
key: 'Value',
},
{
title: '描述',
dataIndex: 'Description',
key: 'Description',
render: record => {
if (!record) {
return '-';
}
return record;
},
},
{
title: '操作',
key: 'action',
width: 200,
render: record => (
<Space>
<Button
type="primary"
size="small"
onClick={() => {
setSelect(record);
setEditVisible(true);
editForm.setFieldsValue({
label: record.Label,
key: record.Key,
value: record.Value,
description: record.Description,
});
}}
>
修改
</Button>
<Popconfirm
title="是否删除该数据?"
okText="确认"
cancelText="取消"
onConfirm={submitDelete}
>
<Button
size="small"
danger
onClick={() => {
setSelect(record);
}}
>
删除
</Button>
</Popconfirm>
</Space>
),
},
];
useEffect(() => {
getData('-1');
}, []);
const getData = () => {
setLoading(true);
get(`/Cityinterface/rest/services/OMS.svc/M_GetKeyValue`, {
_version: 9999,
_dc: new Date().getTime(),
})
.then(res => {
if (res) {
if (res.length > 0) {
res.map(item => {
item.key = item.id;
return item;
});
}
setData(res);
} else {
notification.error({
message: '获取失败',
description: res.message,
});
}
setLoading(false);
})
.catch(err => {
setLoading(false);
message.error(err);
});
};
// 提交-添加
const submitAdd = () => {
const label = addForm.getFieldValue('label');
const key = addForm.getFieldValue('key');
const value = addForm.getFieldValue('value');
const description = addForm.getFieldValue('description');
if (label && key && value) {
get(`/Cityinterface/rest/services/OMS.svc/M_AddKeyValue`, {
_version: 9999,
_dc: new Date().getTime(),
label,
key,
value,
desc: description,
})
.then(res => {
if (res.success) {
setAddVisible(false);
getData();
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
} else {
notification.error({
message: '提交失败',
description: '名称/键名/值不能为空',
});
}
};
// 提交-重置
const submitReset = () => {
get(`/Cityinterface/rest/services/OMS.svc/M_ResetKeyValue`, {
_version: 9999,
_dc: new Date().getTime(),
})
.then(res => {
if (res.success) {
getData();
notification.success({
message: '重置成功',
});
} else {
notification.error({
message: '重置失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
};
// 提交-编辑
const submitEdit = () => {
const label = editForm.getFieldValue('label');
const key = editForm.getFieldValue('key');
const value = editForm.getFieldValue('value');
const description = editForm.getFieldValue('description');
if (label && key && value) {
get(`/Cityinterface/rest/services/OMS.svc/M_EditKeyValue`, {
_version: 9999,
_dc: new Date().getTime(),
id: select.id,
label,
key,
value,
desc: description,
})
.then(res => {
if (res.success) {
setEditVisible(false);
getData();
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
} else {
notification.error({
message: '提交失败',
description: '名称/键名/值不能为空',
});
}
};
const submitDelete = () => {
get(`/Cityinterface/rest/services/OMS.svc/M_DeleteKeyValue`, {
_version: 9999,
_dc: new Date().getTime(),
key: select.Key,
})
.then(res => {
if (res.success) {
getData(select.parentID);
notification.success({
message: '删除成功',
});
} else {
notification.error({
message: '删除失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
};
const appDic = () => {
console.log('123');
return (
<Row>
<Col span={12}>
<Table
size="small"
bordered
// columns={columns}
// dataSource={data0}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 10,
showQuickJumper: true,
showSizeChanger: true,
<div className={styles.AppDic}>
<Spin spinning={loading} tip="loading...">
<div
style={{
marginBottom: '10px',
fontSize: '16px',
height: 'calc(100vh-200px)',
}}
/>
</Col>
<Col span={12}>
>
<span style={{ padding: '0 10px' }}>数据字典</span>
<Button
style={{ marginLeft: '10px' }}
type="primary"
size="small"
onClick={() => {
setAddVisible(true);
addForm.resetFields();
}}
>
添加
</Button>
<Popconfirm
title="是否重置默认配置?"
okText="确认"
cancelText="取消"
onConfirm={submitReset}
>
<Button size="small" danger style={{ marginLeft: '10px' }}>
重置
</Button>
</Popconfirm>
</div>
<Table
size="small"
bordered
// columns={columns}
// dataSource={data0}
columns={columns}
dataSource={data}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
defaultPageSize: 10,
defaultPageSize: 20,
showQuickJumper: true,
showSizeChanger: true,
}}
/>
</Col>
</Row>
</Spin>
{/* 添加 */}
<Modal
title="添加数据字典"
visible={addVisible}
onOk={submitAdd}
onCancel={() => {
setAddVisible(false);
}}
okText="确认"
cancelText="取消"
>
<Form form={addForm} labelCol={{ span: 3 }}>
<Form.Item
name="label"
label="名称"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入名称" />
</Form.Item>
<Form.Item
name="key"
label="键名"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入键名" />
</Form.Item>
<Form.Item
name="value"
label="值"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入值" />
</Form.Item>
<Form.Item name="description" label="描述">
<Input placeholder="请输入相关描述" />
</Form.Item>
</Form>
</Modal>
{/* 修改 */}
<Modal
title="修改数据字典"
visible={editVisible}
onOk={submitEdit}
onCancel={() => {
setEditVisible(false);
}}
okText="确认"
cancelText="取消"
>
<Form form={editForm} labelCol={{ span: 3 }}>
<Form.Item
name="label"
label="名称"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入名称" />
</Form.Item>
<Form.Item name="key" label="键名">
<Input placeholder="请输入键名" />
</Form.Item>
<Form.Item
name="value"
label="值"
rules={[{ required: true, message: '不能为空' }]}
>
<Input placeholder="请输入值" />
</Form.Item>
<Form.Item name="description" label="描述">
<Input placeholder="请输入相关描述" />
</Form.Item>
</Form>
</Modal>
</div>
);
};
export default appDic;
export default AppDic;
.AppDic{
overflow: auto;
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.ant-pagination{
z-index: 999;
background: white;
margin: 2px 0px;
padding:6px 10px;
}
.ant-table-tbody{
.clickRowStyle{
background: #cfe7fd;
}
.clickRowStyle:hover>td{
background: #aed8fa;
}
}
.ant-card-body{
padding: 10px !important;
}
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.ant-table-content{
height:calc(100vh - 258px);
border-right: white;
overflow: auto !important;
}
.ant-pagination{
z-index: 999;
border-top: 1px solid #f0eded;
}
.ant-table-pagination{
padding-right: 12px;
background: white;
margin: 1px 0;
padding:8px;
padding-right: 20px;
}
}
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import {
Table,
Spin,
Modal,
Form,
Input,
......@@ -12,7 +13,6 @@ import {
} from 'antd';
import { get } from '@/services/index';
import styles from './WebDic.less';
import AddForm from '@/pages/webConfig/menuconfig/AddForm';
const WebDic = () => {
const [loading, setLoading] = useState(false);
......@@ -21,7 +21,8 @@ const WebDic = () => {
const [editVisible, setEditVisible] = useState(false);
const [data, setData] = useState([]); // 一级条目
const [subData, setSubData] = useState([]); // 二级条目
const [select, setSelect] = useState({}); // 当前选中条目
const [select, setSelect] = useState({}); // 当前选中条目,可以是一级/二级条目,修改/删除时设置
const [selectID, setSelectID] = useState('-1'); // 当前选中一级条目的ID,添加条目时使用
const [addForm] = Form.useForm();
const [editForm] = Form.useForm();
......@@ -56,7 +57,6 @@ const WebDic = () => {
e.stopPropagation();
setSelect(record);
setEditVisible(true);
console.log(record);
editForm.setFieldsValue({
nodeName: record.nodeName,
nodeValue: record.nodeValue,
......@@ -90,6 +90,7 @@ const WebDic = () => {
useEffect(() => {
getData('-1');
}, []);
// 根据父节点nodeID(即parentID)获取数据,一级条目parentID = -1
const getData = value => {
setLoading(true);
get(`/Cityinterface/rest/services/OMS.svc/D_GetDataDictionaryList`, {
......@@ -99,18 +100,22 @@ const WebDic = () => {
key: '',
})
.then(res => {
if (res && res.length > 0) {
res.map(item => {
item.key = item.nodeID;
return item;
});
if (res) {
if (res.length > 0) {
res.map(item => {
item.key = item.nodeID;
return item;
});
}
// value为 -1 时获取一级条目数据,否则获取二级条目数据
if (value === '-1') {
setData(res); // 设置一级条目
setSelect(res[0]); // 默认当前选中一级条目第一条
setSelectID(res[0].nodeID); // 设置选中的一级条目ID,用于添加二级条目
} else if (value) {
setSubData(res); // 设置二级条目
setSubData(res); // 设置二级条目,res为空[]时也要设置
}
// 获取二级条目
// 获取二级条目数据,默认一级条目第一条,递归一次(条件parentID === '-1')
if (res && res[0] && res[0].parentID === '-1') {
getData(res[0].nodeID);
}
......@@ -134,59 +139,77 @@ const WebDic = () => {
const submitAdd = value => {
const nodeName = addForm.getFieldValue('nodeName');
const nodeValue = addForm.getFieldValue('nodeValue');
get(`/Cityinterface/rest/services/OMS.svc/D_AddDataDictionary`, {
_version: 9999,
_dc: new Date().getTime(),
nodeID: value,
nodeName,
nodeValue,
})
.then(res => {
if (res.success) {
setAddVisible(false);
getData('-1');
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
if (nodeName) {
get(`/Cityinterface/rest/services/OMS.svc/D_AddDataDictionary`, {
_version: 9999,
_dc: new Date().getTime(),
nodeID: value,
nodeName,
nodeValue,
})
.catch(err => {
message.error(err);
.then(res => {
if (res.success) {
setAddVisible(false);
if (level === 1) {
getData('-1');
} else {
getData(selectID);
}
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
} else {
notification.error({
message: '提交失败',
description: '名称不能为空',
});
}
};
// 提交-编辑
const submitEdit = () => {
const nodeName = editForm.getFieldValue('nodeName');
const nodeValue = editForm.getFieldValue('nodeValue');
get(`/Cityinterface/rest/services/OMS.svc/D_EditDataDictionary`, {
_version: 9999,
_dc: new Date().getTime(),
nodeID: select.nodeID,
nodeName,
nodeValue,
})
.then(res => {
if (res.success) {
setEditVisible(false);
getData(select.parentID);
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
if (nodeName) {
get(`/Cityinterface/rest/services/OMS.svc/D_EditDataDictionary`, {
_version: 9999,
_dc: new Date().getTime(),
nodeID: select.nodeID,
nodeName,
nodeValue,
})
.catch(err => {
message.error(err);
.then(res => {
if (res.success) {
setEditVisible(false);
getData(select.parentID);
notification.success({
message: '提交成功',
});
} else {
notification.error({
message: '提交失败',
description: res.message,
});
}
})
.catch(err => {
message.error(err);
});
} else {
notification.error({
message: '提交失败',
description: '名称不能为空',
});
}
};
const submitDelete = () => {
......@@ -215,68 +238,76 @@ const WebDic = () => {
return (
<div className={styles.WebDic}>
<div style={{ marginBottom: '10px', fontSize: '16px' }}>
<span style={{ padding: '0 10px' }}>一级条目</span>
<Button
type="primary"
<Spin spinning={loading} tip="loading...">
<div style={{ marginBottom: '10px', fontSize: '16px' }}>
<span style={{ padding: '0 10px' }}>一级条目</span>
<Button
type="primary"
size="small"
onClick={() => {
setLevel(1);
setAddVisible(true);
addForm.resetFields();
}}
>
添加
</Button>
</div>
{/* 一级条目 表格 */}
<Table
size="small"
onClick={() => {
setLevel(1);
setAddVisible(true);
bordered
columns={columns}
dataSource={data}
scroll={{ x: 'max-content' }}
rowClassName={setRowClassName}
onRow={record => ({
onClick: () => {
getData(record.nodeID);
setSelect(record);
setSelectID(record.nodeID);
},
})}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
showQuickJumper: true,
showSizeChanger: true,
}}
>
添加
</Button>
</div>
<Table
size="small"
bordered
columns={columns}
dataSource={data}
scroll={{ x: 'max-content' }}
rowClassName={setRowClassName}
onRow={record => ({
onClick: () => {
getData(record.nodeID);
setSelect(record);
},
})}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
showQuickJumper: true,
showSizeChanger: true,
}}
/>
<hr color="#cfe7fd" />
<div style={{ marginBottom: '10px', fontSize: '16px' }}>
<span style={{ padding: '0 10px' }}>二级条目</span>
<Button
type="primary"
/>
<hr color="#cfe7fd" />
<div style={{ marginBottom: '10px', fontSize: '16px' }}>
<span style={{ padding: '0 10px' }}>二级条目</span>
<Button
type="primary"
size="small"
onClick={() => {
setLevel(2);
setAddVisible(true);
addForm.resetFields();
}}
>
添加
</Button>
</div>
{/* 二级条目 表格 */}
<Table
size="small"
onClick={() => {
setLevel(2);
setAddVisible(true);
bordered
columns={columns}
dataSource={subData}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
showQuickJumper: true,
showSizeChanger: true,
}}
>
添加
</Button>
</div>
<Table
size="small"
bordered
columns={columns}
dataSource={subData}
scroll={{ x: 'max-content' }}
pagination={{
showTotal: (total, range) =>
`第${range[0]}-${range[1]} 条/共 ${total} 条`,
pageSizeOptions: [10, 20, 50, 100],
showQuickJumper: true,
showSizeChanger: true,
}}
/>
/>
</Spin>
{/* 添加 */}
<Modal
title={level === 1 ? '添加一级条目' : '添加二级条目'}
......@@ -285,7 +316,7 @@ const WebDic = () => {
if (level === 1) {
submitAdd('-1');
} else {
// submitAdd(select.nodeID);
submitAdd(selectID);
}
}}
onCancel={() => {
......
.WebDic{
overflow: auto;
height:calc(100vh-200px);
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
......@@ -22,4 +21,24 @@
.ant-card-body{
padding: 10px !important;
}
.ant-table-thead tr th{
font-weight: 600;
color:rgba(0,0,0,0.85);
}
.ant-table-content{
height:calc(100vh - 488px);
border-right: white;
overflow: auto !important;
}
.ant-pagination{
z-index: 999;
border-top: 1px solid #f0eded;
}
.ant-table-pagination{
padding-right: 12px;
background: white;
margin: 1px 0;
padding:8px;
padding-right: 20px;
}
}
\ 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