Commit d0fecb90 authored by 皮倩雯's avatar 皮倩雯

fix: '人员选择器,选择器交互优化'

parent a05f547a
Pipeline #55153 passed with stages
......@@ -48,6 +48,7 @@ import {
InfoCircleOutlined,
} from '@ant-design/icons';
import Tree from '@/components/ExpendableTree';
import { convertLegacyProps } from 'antd/lib/button/button';
const AddModal = props => {
const {
callBackSubmit = () => {},
......@@ -169,6 +170,9 @@ const AddModal = props => {
const [timeData, setTimeData] = useState('');
const { Option } = Select;
const [synchronization, setSynchronization] = useState('');
const [popeleShape, setPopeleShape] = useState('');
const [gl, setGl] = useState('');
const [cse, setCse] = useState('');
// 提交
const onSubmit = () => {
// 不切换树
......@@ -281,8 +285,16 @@ const AddModal = props => {
data[0].Config = `${data[0].Config}?${obj.filterName}`;
}
break;
case '选择器':
if (cse) {
let str = `${obj.farter}.${obj.farterData}`;
data[0].Config = str;
} else {
data[0].Config = obj.Config ? obj.Config : '';
}
break;
case '人员选择器':
if (checkboxAll1 == true) {
if (popeleShape == '分组模态') {
if (checkboxAllID1 == true) {
if (obj.ConfigName) {
let str = cho ? `全部ID.${obj.ConfigName}` : `全部ID.${obj.ConfigName}.n`;
......@@ -300,10 +312,18 @@ const AddModal = props => {
data[0].Config = str;
}
}
} else {
} else if (popeleShape == '下拉框') {
let str = cho ? `${obj.Config}` : `${obj.Config}.n`;
console.log(str);
data[0].Config = str;
} else if (popeleShape == '树形模态') {
if (gl) {
let str = cho ? `tree.单选|非站点` : `tree.多选|非站点`;
data[0].Config = str;
} else {
let str = cho ? `tree.单选|站点` : `tree.多选|站点`;
data[0].Config = str;
}
}
break;
default:
......@@ -555,6 +575,26 @@ const AddModal = props => {
setRadio(0);
}
break;
case '选择器':
let sele = res[0].data.root.Config.split('.');
console.log(sele[0]);
console.log(sele[1]);
if (sele[1]) {
form.setFieldsValue({
Association: true,
farter: sele[0],
farterData: sele[1],
});
setCse(true);
} else {
console.log(sele[0]);
form.setFieldsValue({
Association: false,
Config: sele[0],
});
setCse(false);
}
break;
case '人员选择器':
let pepole = res[0].data.root.Config.split('.');
console.log(pepole);
......@@ -565,17 +605,27 @@ const AddModal = props => {
setCheckboxAll1(true);
if (pepole[1] != 'n') {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: false,
ConfigName: pepole[1],
});
} else {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: false,
ConfigName: '',
});
}
if (res[0].data.root.Config.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
} else {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('分组模态');
} else if (pepole[0] == '全部ID') {
setHide(false);
setFlag(true);
......@@ -583,17 +633,79 @@ const AddModal = props => {
setCheckboxAllID1(true);
if (pepole[1] != 'n') {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: true,
ConfigName: pepole[1],
});
} else {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: true,
ConfigName: '',
});
}
if (res[0].data.root.Config.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
} else {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('分组模态');
} else if (pepole[0] == 'tree') {
setCheckboxAll1(false);
setCheckboxAllID1(false);
setHide(true);
setFlag(1);
let tree = pepole[1].split('|');
if (tree[0] == '多选') {
if (tree[1] == '站点') {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: false,
choose: false,
});
setGl(false);
setCho(false);
} else {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: true,
choose: false,
});
setGl(true);
setCho(false);
}
} else {
if (tree[1] == '站点') {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: false,
choose: true,
});
setGl(false);
setCho(true);
} else {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: true,
choose: true,
});
setGl(true);
setCho(true);
}
}
setPopeleShape('树形模态');
} else {
setCheckboxAll1(false);
setCheckboxAllID1(false);
......@@ -601,10 +713,10 @@ const AddModal = props => {
setFlag(false);
form.setFieldsValue({
All1: false,
PeShape: '下拉框',
AllID1: false,
Config: pepole[0],
});
}
if (res[0].data.root.Config.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
......@@ -612,6 +724,9 @@ const AddModal = props => {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('下拉框');
}
break;
}
setPramData({ ...res[0].data.root, coordinates, must, picture });
......@@ -642,6 +757,9 @@ const AddModal = props => {
});
}
} else {
setPopeleShape('');
setGl('');
setCse('');
setPramData([]);
form.resetFields();
setChee('');
......@@ -653,6 +771,7 @@ const AddModal = props => {
setCheckboxAll1('');
setCheckboxAllID1('');
setFlag(false);
setPopeleShape('下拉框');
setHide(true);
setSynchronization(false);
}
......@@ -783,6 +902,7 @@ const AddModal = props => {
} else {
form.setFieldsValue({
Config: '',
guolv: '',
ConfigName: '',
tableName: '',
fieldName: '',
......@@ -797,17 +917,24 @@ const AddModal = props => {
ShowConfig: '',
pepole: '',
choose: '',
PeShape: '',
Association: '',
farter: '',
farterData: '',
});
}
setCse('');
setPopeleShape('');
setRadio(0);
setRadio3('0');
setRadio1('0');
setGl('');
setPep('');
setCho('');
setCheckboxAll1('');
setCheckboxAllID1('');
setFlag(false);
setPopeleShape('下拉框');
setHide(true);
console.log(value);
if (value == '文本') {
......@@ -1166,6 +1293,25 @@ const AddModal = props => {
setRadio(0);
}
break;
case '选择器':
console.log(aa.Config);
let sele = aa.Config.split('.');
if (sele[1]) {
form.setFieldsValue({
Association: true,
farter: sele[0],
farterData: sele[1],
});
setCse(true);
} else {
console.log(sele[0]);
form.setFieldsValue({
Association: false,
Config: sele[0],
});
setCse(false);
}
break;
case '人员选择器':
let pepole = aa.Config.split('.');
console.log(pepole);
......@@ -1176,17 +1322,27 @@ const AddModal = props => {
setCheckboxAll1(true);
if (pepole[1] != 'n') {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: false,
ConfigName: pepole[1],
});
} else {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: false,
ConfigName: '',
});
}
if (aa.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
} else {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('分组模态');
} else if (pepole[0] == '全部ID') {
setHide(false);
setFlag(true);
......@@ -1194,17 +1350,79 @@ const AddModal = props => {
setCheckboxAllID1(true);
if (pepole[1] != 'n') {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: true,
ConfigName: pepole[1],
});
} else {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: true,
ConfigName: '',
});
}
if (aa.Config.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
} else {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('分组模态');
} else if (pepole[0] == 'tree') {
setCheckboxAll1(false);
setCheckboxAllID1(false);
setHide(true);
setFlag(1);
let tree = pepole[1].split('|');
if (tree[0] == '多选') {
if (tree[1] == '站点') {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: false,
choose: false,
});
setGl(false);
setCho(false);
} else {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: true,
choose: false,
});
setGl(true);
setCho(false);
}
} else {
if (tree[1] == '站点') {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: false,
choose: true,
});
setGl(false);
setCho(true);
} else {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: true,
choose: true,
});
setGl(true);
setCho(true);
}
}
setPopeleShape('树形模态');
} else {
setCheckboxAll1(false);
setCheckboxAllID1(false);
......@@ -1212,10 +1430,10 @@ const AddModal = props => {
setFlag(false);
form.setFieldsValue({
All1: false,
PeShape: '下拉框',
AllID1: false,
Config: pepole[0],
});
}
if (aa.Config.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
......@@ -1223,6 +1441,9 @@ const AddModal = props => {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('下拉框');
}
break;
}
setValue1();
......@@ -1415,6 +1636,24 @@ const AddModal = props => {
setRadio(0);
}
break;
case '选择器':
let sele = res[0].data.root.Config.split('.');
if (sele[1]) {
form.setFieldsValue({
Association: true,
farter: sele[0],
farterData: sele[1],
});
setCse(true);
} else {
console.log(sele[0]);
form.setFieldsValue({
Association: false,
Config: sele[0],
});
setCse(false);
}
break;
case '人员选择器':
let pepole = res[0].data.root.Config.split('.');
console.log(pepole);
......@@ -1425,17 +1664,27 @@ const AddModal = props => {
setCheckboxAll1(true);
if (pepole[1] != 'n') {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: false,
ConfigName: pepole[1],
});
} else {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: false,
ConfigName: '',
});
}
if (res[0].data.root.Config.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
} else {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('分组模态');
} else if (pepole[0] == '全部ID') {
setHide(false);
setFlag(true);
......@@ -1443,17 +1692,79 @@ const AddModal = props => {
setCheckboxAllID1(true);
if (pepole[1] != 'n') {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: true,
ConfigName: pepole[1],
});
} else {
form.setFieldsValue({
PeShape: '分组模态',
All1: true,
AllID1: true,
ConfigName: '',
});
}
if (res[0].data.root.Config.endsWith('.n')) {
form.setFieldsValue({ choose: false });
setCho(false);
} else {
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('分组模态');
} else if (pepole[0] == 'tree') {
setCheckboxAll1(false);
setCheckboxAllID1(false);
setHide(true);
setFlag(1);
let tree = pepole[1].split('|');
if (tree[0] == '多选') {
if (tree[1] == '站点') {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: false,
choose: false,
});
setGl(false);
setCho(false);
} else {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: true,
choose: false,
});
setGl(true);
setCho(false);
}
} else {
if (tree[1] == '站点') {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: false,
choose: true,
});
setGl(false);
setCho(true);
} else {
form.setFieldsValue({
PeShape: '树形模态',
All1: true,
AllID1: true,
guolv: true,
choose: true,
});
setGl(true);
setCho(true);
}
}
setPopeleShape('树形模态');
} else {
setCheckboxAll1(false);
setCheckboxAllID1(false);
......@@ -1461,19 +1772,19 @@ const AddModal = props => {
setFlag(false);
form.setFieldsValue({
All1: false,
PeShape: '下拉框',
AllID1: false,
Config: pepole[0],
});
}
if (res[0].data.root.Config.endsWith('.n')) {
console.log(111);
form.setFieldsValue({ choose: false });
setCho(false);
} else {
console.log(222);
form.setFieldsValue({ choose: true });
setCho(true);
}
setPopeleShape('下拉框');
}
break;
}
setValue1();
......@@ -1590,8 +1901,16 @@ const AddModal = props => {
data[0].Config = `${data[0].Config}?${obj.filterName}`;
}
break;
case '选择器':
if (cse) {
let str = `${obj.farter}.${obj.farterData}`;
data[0].Config = str;
} else {
data[0].Config = obj.Config ? obj.Config : '';
}
break;
case '人员选择器':
if (checkboxAll1 == true) {
if (popeleShape == '分组模态') {
if (checkboxAllID1 == true) {
if (obj.ConfigName) {
let str = cho ? `全部ID.${obj.ConfigName}` : `全部ID.${obj.ConfigName}.n`;
......@@ -1609,10 +1928,18 @@ const AddModal = props => {
data[0].Config = str;
}
}
} else {
} else if (popeleShape == '下拉框') {
let str = cho ? `${obj.Config}` : `${obj.Config}.n`;
console.log(str);
data[0].Config = str;
} else if (popeleShape == '树形模态') {
if (gl) {
let str = cho ? `tree.单选|非站点` : `tree.多选|非站点`;
data[0].Config = str;
} else {
let str = cho ? `tree.单选|站点` : `tree.多选|站点`;
data[0].Config = str;
}
}
break;
default:
......@@ -1639,7 +1966,9 @@ const AddModal = props => {
}
}
form.setFieldsValue({
Association: '',
Config: '',
guolv: '',
ConfigName: '',
tableName: '',
fieldName: '',
......@@ -1655,16 +1984,23 @@ const AddModal = props => {
pepole: '',
choose: '',
SyncEvent: '',
PeShape: '',
farter: '',
farterData: '',
});
setCse('');
setPopeleShape('');
setRadio(0);
setRadio3('0');
setRadio1('0');
setGl('');
setPep('');
setCho('');
setCheckboxAll1('');
setCheckboxAllID1('');
setSynchronization(false);
setFlag(false);
setPopeleShape('下拉框');
setHide(true);
if (i == 1.14) {
console.log(valueData);
......@@ -1854,6 +2190,11 @@ const AddModal = props => {
setCho(e.target.checked);
};
const changeGl = e => {
console.log(e);
setGl(e.target.checked);
};
const changeAll1 = e => {
let aa = form.getFieldsValue().ConfigName;
let bb = form.getFieldsValue().Config;
......@@ -1882,6 +2223,35 @@ const AddModal = props => {
setSynchronization(e.target.checked);
};
const popeleShapeOnChange = e => {
console.log(e);
setPopeleShape(e.target.value);
let aa = form.getFieldsValue().ConfigName;
let bb = form.getFieldsValue().Config;
if (e.target.value == '分组模态') {
if (bb || bb == '' || bb == undefined) {
form.setFieldsValue({ ConfigName: bb });
}
setHide(false);
setFlag(true);
} else if (e.target.value == '下拉框') {
if (aa || aa == '' || bb == undefined) {
form.setFieldsValue({ Config: aa });
}
setHide(true);
setFlag(false);
setCheckboxAllID1(false);
} else if (e.target.value == '树形模态') {
setHide(true);
setFlag(1);
setCheckboxAllID1(false);
}
};
const changeCse = e => {
setCse(e.target.checked);
};
return (
<>
<Drawer
......@@ -2195,19 +2565,53 @@ const AddModal = props => {
<>
<Item
label="配置"
name="Config"
name="Association"
labelCol={{ span: 4 }}
// rules={[{ required: true, message: '请输入数据字典名称' }]}
>
<Checkbox
checked={cse}
onChange={changeCse}
style={{ marginBottom: '0' }}
>
关联选择器
</Checkbox>
</Item>
{cse ? (
<Row>
<Col span={12}>
<Item
label="父字段名"
name="farter"
labelCol={{ span: 8 }}
rules={[{ required: true, message: '请输入父字段名' }]}
>
<Input placeholder="请输入父字段名称" />
</Item>
</Col>
<Col span={12}>
<Item
label="数据字典"
name="farterData"
labelCol={{ span: 7 }}
rules={[{ required: true, message: '请输入数据字典名称' }]}
>
<Input placeholder="请输入数据字典名称" />
</Item>
</Col>
</Row>
) : (
<Item label="数据字典" name="Config" labelCol={{ span: 4 }}>
<TextArea allowClear placeholder="请输入数据字典名称" />
</Item>
)}
</>
);
case '搜索选择器':
return (
<>
<Item
label="数据字典名称"
label="数据字典"
name="Config"
labelCol={{ span: 4 }}
// rules={[{ required: true, message: '请输入数据字典名称' }]}
......@@ -2324,28 +2728,66 @@ const AddModal = props => {
<>
<Item
labelCol={{ span: 4 }}
label={
<div>
<Tooltip
title={
<>
<span>弹窗显示人员所属机构</span>
<Image width={200} src={AllImage} />
</>
}
label="展示形态"
name="PeShape"
// label={
// <div>
// <Tooltip
// title={
// <>
// <span>弹窗显示人员所属机构</span>
// <Image width={200} src={AllImage} />
// </>
// }
// >
// <InfoCircleOutlined
// style={{
// color: 'rgb(24 144 255)',
// marginRight: '5px',
// }}
// />
// </Tooltip>
// <span>人员选择器形态</span>
// </div>
// }
>
<InfoCircleOutlined
style={{
color: 'rgb(24 144 255)',
marginRight: '5px',
}}
/>
</Tooltip>
<span>配置</span>
<div style={{ display: 'inline-block', marginRight: '10px' }}>
<Radio.Group
style={{ marginTop: '0.3rem' }}
value={popeleShape}
onChange={popeleShapeOnChange}
>
<Radio value="下拉框">下拉框</Radio>
<Radio value="分组模态">分组模态</Radio>
<Radio value="树形模态">树形模态</Radio>
</Radio.Group>
</div>
}
</Item>
<Item
labelCol={{ span: 4 }}
// label={
// <div>
// <Tooltip
// title={
// <>
// <span>弹窗显示人员所属机构</span>
// <Image width={200} src={AllImage} />
// </>
// }
// >
// <InfoCircleOutlined
// style={{
// color: 'rgb(24 144 255)',
// marginRight: '5px',
// }}
// />
// </Tooltip>
// <span>配置</span>
// </div>
// }
label="配置"
>
<div style={{ display: 'inline-block', marginRight: '10px' }}>
{/* <div style={{ display: 'inline-block', marginRight: '10px' }}>
<Item name="All1" style={{ marginBottom: '0' }}>
<Checkbox
checked={checkboxAll1}
......@@ -2355,7 +2797,7 @@ const AddModal = props => {
弹窗
</Checkbox>
</Item>
</div>
</div> */}
<div style={{ display: 'inline-block', marginRight: '10px' }}>
<Item name="choose" style={{ marginBottom: '0' }}>
<Checkbox
......@@ -2409,6 +2851,22 @@ const AddModal = props => {
</Item>
</>
);
case 1:
return (
<>
<Item label="过滤" name="Config" labelCol={{ span: 4 }}>
<Item name="guolv" style={{ marginBottom: '0' }}>
<Checkbox
checked={gl}
onChange={changeGl}
style={{ marginBottom: '0' }}
>
非站点
</Checkbox>
</Item>
</Item>
</>
);
case false:
return (
<>
......
......@@ -2,8 +2,11 @@ import React, { useState, useEffect } from 'react';
import { DatePicker, Table, Row, Col, Button, notification, message, Spin } from 'antd';
import { SwapRightOutlined, SyncOutlined } from '@ant-design/icons';
import moment from 'moment';
import 'moment/dist/locale/zh-cn';
import locale from 'antd/es/date-picker/locale/zh_CN';
import { post, PUBLISH_SERVICE } from '@/services/index';
import styles from './index.less';
const { RangePicker } = DatePicker;
const LoginLog = () => {
const [loading, setLoading] = useState(false); // 源数据
......@@ -16,6 +19,10 @@ const LoginLog = () => {
const [endTime, setEndTime] = useState(
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'), // 默认值当前时间
);
const [allTime, setAllTime] = useState([
moment().startOf('month'),
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
]);
const [filteredValue, setFilteredValue] = useState([]);
const columns = [
......@@ -64,15 +71,15 @@ const LoginLog = () => {
];
// 在起止时间任意一个变化后获取数据
useEffect(() => {
if (startTime && endTime) {
if (allTime) {
setLoading(true);
getData();
}
}, [startTime, endTime]);
}, [allTime]);
const getData = () => {
post(`${PUBLISH_SERVICE}/LogCenter/GetLoginLog`, {
DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
DateFrom: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
DateTo: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
IP: '',
Module: '',
Description: '',
......@@ -114,15 +121,24 @@ const LoginLog = () => {
const changeEndTime = time => {
setEndTime(time);
};
const changeTime = time => {
setAllTime(time);
};
// 近1/6/12/24小时
const setTime = time => {
setEndTime(moment(new Date(), 'YYYY-MM-DD HH:mm:ss'));
setStartTime(
moment(new Date(new Date().getTime() - time * 60 * 60 * 1000), 'YYYY-MM-DD HH:mm:ss'),
);
setAllTime([
moment(new Date(new Date().getTime() - time * 60 * 60 * 1000), 'YYYY-MM-DD HH:mm:ss'),
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
]);
};
const handleReset = () => {
setStartTime(moment().startOf('week'));
setAllTime([moment().startOf('week'), moment(new Date(), 'YYYY-MM-DD HH:mm:ss')]);
setFilteredValue([]);
};
const onChangeInput = filters => {
......@@ -135,7 +151,15 @@ const LoginLog = () => {
<Row className={styles.head}>
<Col span={24}>
<span style={{ lineHeight: 2 }}>时间:</span>
<DatePicker
<RangePicker
locale={locale}
showTime
format="YYYY-MM-DD HH:mm:ss"
onChange={changeTime}
value={allTime}
allowClear={false}
/>
{/* <DatePicker
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="起始时间"
......@@ -152,8 +176,10 @@ const LoginLog = () => {
onChange={changeEndTime}
style={{ marginRight: '10px' }}
allowClear={false}
/>
<Button onClick={() => setTime(1)}>近1小时</Button>
/> */}
<Button onClick={() => setTime(1)} style={{ marginLeft: '20px' }}>
近1小时
</Button>
<Button onClick={() => setTime(6)}>近6小时</Button>
<Button onClick={() => setTime(24)}>近1天</Button>
<Button onClick={() => setTime(24 * 7)}>近1周</Button>
......
......@@ -14,9 +14,13 @@ import {
} from 'antd';
import { SwapRightOutlined, SyncOutlined } from '@ant-design/icons';
import moment from 'moment';
import 'moment/dist/locale/zh-cn';
import locale from 'antd/es/date-picker/locale/zh_CN';
import { get, PUBLISH_SERVICE } from '@/services/index';
import styles from './index.less';
const { RangePicker } = DatePicker;
const OmsLog = () => {
const [loading, setLoading] = useState(false); // 源数据
const [data, setData] = useState([]); // 源数据
......@@ -28,6 +32,10 @@ const OmsLog = () => {
const [endTime, setEndTime] = useState(
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'), // 默认值当前时间
);
const [allTime, setAllTime] = useState([
moment().startOf('month'),
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
]);
const [showSearchStyle, setShowSearchStyle] = useState(false); // 是否显示模糊查询样式
const [total, setTotal] = useState();
const [pageSize, setPageSize] = useState(20);
......@@ -57,9 +65,21 @@ const OmsLog = () => {
title: '标签',
dataIndex: 'Label',
key: 'Label',
ellipsis: 'true',
width: 300,
render: item => searchStyle1(item),
// width: 300,
onCell: () => ({
style: {
maxWidth: 300,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
cursor: 'pointer',
},
}),
render: record => (
<Tooltip placement="topLeft" title={record}>
{searchStyle1(record)}
</Tooltip>
),
},
{
title: '操作信息',
......@@ -129,16 +149,16 @@ const OmsLog = () => {
// 在起止时间任意一个变化后获取数据
useEffect(() => {
if (startTime && endTime) {
if (allTime) {
setLoading(true);
getData();
}
}, [startTime, endTime]);
}, [allTime]);
const getData = () => {
get(`${PUBLISH_SERVICE}/LogCenter/GetOmsCustomerLog`, {
logType: 'operationLog',
StartDateTime: startTime.format('YYYY-MM-DD HH:mm:ss'),
EndDate: endTime.format('YYYY-MM-DD HH:mm:ss'),
StartDateTime: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
EndDate: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
function: functionName,
label,
PageIndex: 1,
......@@ -183,8 +203,8 @@ const OmsLog = () => {
const getData1 = (page, size) => {
get(`${PUBLISH_SERVICE}/LogCenter/GetOmsCustomerLog`, {
logType: 'operationLog',
StartDateTime: startTime.format('YYYY-MM-DD HH:mm:ss'),
EndDate: endTime.format('YYYY-MM-DD HH:mm:ss'),
StartDateTime: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
EndDate: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
function: functionName,
label,
PageIndex: page,
......@@ -230,16 +250,24 @@ const OmsLog = () => {
const changeEndTime = time => {
setEndTime(time);
};
const changeTime = time => {
setAllTime(time);
};
// 近1/6/12/24小时
const setTime = time => {
setEndTime(moment(new Date(), 'YYYY-MM-DD HH:mm:ss'));
setStartTime(
moment(new Date(new Date().getTime() - time * 60 * 60 * 1000), 'YYYY-MM-DD HH:mm:ss'),
);
setAllTime([
moment(new Date(new Date().getTime() - time * 60 * 60 * 1000), 'YYYY-MM-DD HH:mm:ss'),
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
]);
};
const handleReset = () => {
setStartTime(moment().startOf('month'));
setEndTime(moment(new Date(), 'YYYY-MM-DD HH:mm:ss'));
setAllTime([moment().startOf('month'), moment(new Date(), 'YYYY-MM-DD HH:mm:ss')]);
setFunctionName('');
setFilteredValue([]);
setLabel('');
......@@ -261,7 +289,15 @@ const OmsLog = () => {
<Row className={styles.head}>
<Col span={24}>
<span style={{ lineHeight: 2 }}>时间:</span>
<DatePicker
<RangePicker
locale={locale}
showTime
format="YYYY-MM-DD HH:mm:ss"
onChange={changeTime}
value={allTime}
allowClear={false}
/>
{/* <DatePicker
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="起始时间"
......@@ -278,8 +314,10 @@ const OmsLog = () => {
onChange={changeEndTime}
style={{ marginRight: '10px' }}
allowClear={false}
/>
<Button onClick={() => setTime(1)}>近1小时</Button>
/> */}
<Button onClick={() => setTime(1)} style={{ marginLeft: '20px' }}>
近1小时
</Button>
{/* <Button onClick={() => setTime(6)}>近6小时</Button> */}
<Button onClick={() => setTime(24)}>近1天</Button>
<Button onClick={() => setTime(24 * 7)}>近1周</Button>
......
.omsLog{
.head{
.omsLog {
.head {
padding: 10px;
background: white;
margin-bottom: 2px;
min-width: 1030px;
}
.chart{
.chart {
padding: 16px;
background: white;
}
.table{
.table {
border-top: 1px solid #f0eded;
// overflow: auto;//不要这个,pagination否则无法固定底部
.ant-table-thead tr th{
.ant-table-thead tr th {
font-weight: 600;
color:rgba(0,0,0,0.85);
background-color:#F6F9FE;
color: rgba(0, 0, 0, 0.85);
background-color: #f6f9fe;
}
.ant-table-body{
height:calc(100vh - 208px);
.ant-table-body {
height: calc(100vh - 208px);
border-right: white;
overflow: auto !important;
// .ant-table-tbody{
// overflow: scroll !important;
// }
}
.ant-pagination{
.ant-table-cell {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ant-pagination {
z-index: 999;
border-top: 1px solid #f0eded;
}
......@@ -33,18 +38,18 @@
width: 99%;
margin: 10px auto;
}
.ant-table-pagination{
.ant-table-pagination {
padding-right: 12px;
background: white;
margin: 1px 0;
padding:8px;
padding: 8px;
padding-right: 20px;
}
}
.ant-spin-container {
background-color: white;
}
.icon{
.icon {
margin-top: -5px !important;
vertical-align: text-bottom;
}
......
......@@ -15,11 +15,15 @@ import {
} from 'antd';
import { SwapRightOutlined, SyncOutlined, CaretUpFilled, CaretDownFilled } from '@ant-design/icons';
import { Chart, Interval, Line, Axis } from 'bizcharts';
import moment from 'moment';
import { post, PUBLISH_SERVICE } from '@/services/index';
import moment from 'moment';
import 'moment/dist/locale/zh-cn';
import locale from 'antd/es/date-picker/locale/zh_CN';
import styles from './index.less';
const { Option } = Select;
const { Search } = Input;
const { RangePicker } = DatePicker;
const ServiceLog = () => {
const [loading, setLoading] = useState(false); // 源数据
......@@ -32,6 +36,10 @@ const ServiceLog = () => {
const [endTime, setEndTime] = useState(
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'), // 默认值,当前时间
);
const [allTime, setAllTime] = useState([
moment().startOf('month'),
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
]);
const [logType, setLogType] = useState('9999'); // 请求参数,日志类型,默认是正常,0:成功 -1:异常 9999:全部
const [searchWord, setSearchWord] = useState(''); // 关键字
const [showSearchStyle, setShowSearchStyle] = useState(false); // 是否显示模糊查询样式
......@@ -45,8 +53,8 @@ const ServiceLog = () => {
const [keepOrder, setKeepOrder] = useState('');
// 计算时间间隔(分钟)
const start = new Date(startTime).getTime();
const end = new Date(endTime).getTime();
const start = new Date(allTime[0]).getTime();
const end = new Date(allTime[1]).getTime();
const minuteInterval = (end - start) / (60 * 1000); // 相隔多少分钟
const countInterval = () => {
if (minuteInterval > 0 && minuteInterval <= 30) {
......@@ -60,11 +68,16 @@ const ServiceLog = () => {
}
};
// 计算时间间隔(月份),禁止跨月份查询
const startMonth = new Date(startTime).getMonth();
const endMonth = new Date(endTime).getMonth();
const startYear = new Date(startTime).getYear();
const endYear = new Date(endTime).getYear();
const startMonth = new Date(allTime[0]).getMonth();
const endMonth = new Date(allTime[1]).getMonth();
const startYear = new Date(allTime[0]).getYear();
const endYear = new Date(allTime[1]).getYear();
if (minuteInterval <= 0) {
console.log(start);
console.log(end);
console.log(allTime[0]);
console.log(allTime[1]);
console.log(minuteInterval);
notification.error({
message: '时间设置有误',
description: '起始时间应该早于结束时间',
......@@ -82,7 +95,7 @@ const ServiceLog = () => {
dataIndex: 'Path',
key: 'Path',
fixed: 'left',
width: 400,
width: 300,
render: item => searchStyle(item),
},
{
......@@ -207,8 +220,8 @@ const ServiceLog = () => {
// 获取日志表数据时PageSize设置为200,其他接口默认值20
PageIndex: 1,
PageSize: 20,
DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
DateFrom: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
DateTo: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
IP: '',
Module: searchWord,
LogType: +logType,
......@@ -258,8 +271,8 @@ const ServiceLog = () => {
// 获取日志表数据时PageSize设置为200,其他接口默认值20
PageIndex: 1,
PageSize: 20,
DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
DateFrom: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
DateTo: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
IP: '',
Module: searchWord,
LogType: +logType,
......@@ -310,42 +323,24 @@ const ServiceLog = () => {
};
// 在起止时间任意一个变化后获取数据,且起止时间应该早于结束时间,且不允许跨月查询
useEffect(() => {
if (
startTime &&
endTime &&
end - start > 0 &&
startMonth === endMonth &&
startYear === endYear
) {
if (allTime && end - start > 0 && startMonth === endMonth && startYear === endYear) {
countInterval(); // 根据起止时间计算时间间隔
}
}, [startTime, endTime]);
}, [allTime]);
useEffect(() => {
if (
startTime &&
endTime &&
end - start > 0 &&
startMonth === endMonth &&
startYear === endYear
) {
if (allTime && end - start > 0 && startMonth === endMonth && startYear === endYear) {
setLoading(true);
getData('/TrafficStatistics', setVisitedCount); // 访问量统计
}
}, [startTime, endTime, logType, timeInterval]);
}, [allTime, logType, timeInterval]);
useEffect(() => {
if (
startTime &&
endTime &&
end - start > 0 &&
startMonth === endMonth &&
startYear === endYear
) {
if (allTime && end - start > 0 && startMonth === endMonth && startYear === endYear) {
setLoading(true);
getData('/TopCountList', setPathCount); // 接口调用频次统计
getData('/TopConsumeList', setReponseTime); // 接口平均耗时统计
getData('/GetOMSLog', setDataTable); // 接口调用记录
}
}, [startTime, endTime, logType]);
}, [allTime, logType]);
// 封装接口请求,参数url/设置方法set
const getData = (url, set) => {
......@@ -353,8 +348,8 @@ const ServiceLog = () => {
// 获取日志表数据时PageSize设置为200,其他接口默认值20
PageIndex: 1,
PageSize: 20,
DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
DateFrom: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
DateTo: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
IP: '',
Module: url === '/GetOMSLog' ? searchWord : '',
LogType: +logType,
......@@ -408,8 +403,8 @@ const ServiceLog = () => {
data = {
PageIndex: page,
PageSize: size,
DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
DateFrom: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
DateTo: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
IP: '',
Module: searchWord,
LogType: +logType,
......@@ -424,8 +419,8 @@ const ServiceLog = () => {
data = {
PageIndex: page,
PageSize: size,
DateFrom: startTime.format('YYYY-MM-DD HH:mm:ss'),
DateTo: endTime.format('YYYY-MM-DD HH:mm:ss'),
DateFrom: allTime[0].format('YYYY-MM-DD HH:mm:ss'),
DateTo: allTime[1].format('YYYY-MM-DD HH:mm:ss'),
IP: '',
Module: searchWord,
LogType: +logType,
......@@ -466,16 +461,26 @@ const ServiceLog = () => {
// DatePicker改变点击确定时
const changeStartTime = time => {
console.log(time);
setStartTime(time);
};
const changeEndTime = time => {
console.log(time);
setEndTime(time);
};
const changeTime = time => {
console.log(time);
setAllTime(time);
};
// 近1/6/12/24小时,同时设置对应的时间间隔
const setTime = (time, value) => {
setTimeInterval(value);
setEndTime(moment(new Date(), 'YYYY-MM-DD HH:mm:ss'));
setStartTime(moment(new Date(new Date().getTime() - time * 60 * 1000), 'YYYY-MM-DD HH:mm:ss'));
setEndTime(moment(new Date(), 'YYYY-MM-DD HH:mm:ss'));
setAllTime([
moment(new Date(new Date().getTime() - time * 60 * 1000), 'YYYY-MM-DD HH:mm:ss'),
moment(new Date(), 'YYYY-MM-DD HH:mm:ss'),
]);
};
// 设置返回状态
const changeStatus = value => {
......@@ -494,6 +499,7 @@ const ServiceLog = () => {
setTimeInterval('4');
setStartTime(moment().startOf('month'));
setEndTime(moment(new Date(), 'YYYY-MM-DD HH:mm:ss'));
setAllTime([moment().startOf('month'), moment(new Date(), 'YYYY-MM-DD HH:mm:ss')]);
setSearchWord('');
setShowSearchStyle(false);
};
......@@ -515,7 +521,16 @@ const ServiceLog = () => {
<Row className={styles.head}>
<Col span={24}>
<span>时间:</span>
<DatePicker
<RangePicker
locale={locale}
showTime
format="YYYY-MM-DD HH:mm:ss"
onChange={changeTime}
value={allTime}
allowClear={false}
/>
{/* <DatePicker
locale={locale}
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="起始时间"
......@@ -525,6 +540,7 @@ const ServiceLog = () => {
/>
<SwapRightOutlined style={{ verticalAlign: '0.125em' }} />
<DatePicker
locale={locale}
showTime
format="YYYY-MM-DD HH:mm:ss"
placeholder="结束时间"
......@@ -532,8 +548,10 @@ const ServiceLog = () => {
onChange={changeEndTime}
style={{ marginRight: '10px' }}
allowClear={false}
/>
<Button onClick={() => setTime(15, '1')}>近15分钟</Button>
/> */}
<Button onClick={() => setTime(15, '1')} style={{ marginLeft: '10px' }}>
近15分钟
</Button>
<Button onClick={() => setTime(60, '2')}>近1小时</Button>
<Button onClick={() => setTime(12 * 60, '3')}>近12小时</Button>
<Button onClick={() => setTime(24 * 60, '3')}>近1天</Button>
......
......@@ -65,3 +65,7 @@
.ant-select-arrow .anticon > svg {
vertical-align: middle;
}
.ant-picker-separator {
display: flex;
align-items: center;
}
/* eslint-disable no-else-return */
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable prefer-template */
/* eslint-disable react/jsx-boolean-value */
import React, { useState, useEffect } from 'react';
......@@ -294,8 +296,12 @@ const AddModal = props => {
{
validator: (rule, value) => {
let aa = form.getFieldValue().systemName;
let regEn = /[`~!@#$%^&*()_+<>?:"{},.\/;'[\]]/im;
let regCn = /[·!#¥(——):;“”‘、,|《。》?、【】[\]]/im;
if (keepSystemName.indexOf(aa) != -1) {
return Promise.reject('名称已存在');
} else if (regEn.test(aa) || regCn.test(aa)) {
return Promise.reject('名称不能包含特殊字符');
}
return Promise.resolve();
},
......
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