Commit 22bf8bd9 authored by 李纪文's avatar 李纪文

feat: 组态控制日志样式优化

parent 94ebb8bc
...@@ -7,24 +7,55 @@ ...@@ -7,24 +7,55 @@
import { getRemoteOperationLog } from '../../apis'; import { getRemoteOperationLog } from '../../apis';
import BasicTable from '@wisdom-components/basictable'; import BasicTable from '@wisdom-components/basictable';
import LoadBox from '@wisdom-components/loadbox'; import LoadBox from '@wisdom-components/loadbox';
import { Button, DatePicker, Input, Tag, Tooltip, ConfigProvider } from 'antd'; import { Button, DatePicker, Input, Tag, Tooltip, ConfigProvider, Radio } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import moment from 'moment'; import moment from 'moment';
import React, { useEffect, useState, useContext } from 'react'; import React, { useEffect, useState, useContext } from 'react';
import './index.less'; import './index.less';
import { render } from 'less';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const dateList = [
{
key: 'roundClock',
name: '近24小时',
},
{
key: 'thisWeek',
name: '本周',
},
{
key: 'thisMonth',
name: '本月',
},
{
key: 'thisQuarter',
name: '本季度',
},
{
key: 'thisYear',
name: '今年',
},
{
key: 'customer',
name: '自定义',
},
];
const startFormat = 'YYYY-MM-DD 00:00:00';
const endFormat = 'YYYY-MM-DD HH:mm:ss';
const ControlRecords = ({ nodeData, bindList }) => { const ControlRecords = ({ nodeData, bindList }) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext); const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('ec-configuration-control-records'); const prefixCls = getPrefixCls('ec-configuration-control-records');
const dateFormat = 'YYYY-MM-DD HH:mm:ss'; const dateFormat = 'YYYY-MM-DD HH:mm:ss';
const [time, setTime] = useState([ const [time, setTime] = useState([
moment().subtract(7, 'day').format('YYYY-MM-DD 00:00:00'), moment().subtract(24, 'hour').format('YYYY-MM-DD HH:mm:ss'),
moment().format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss'),
]); ]);
const [dateValue, setDateValue] = useState('roundClock');
const [userName, setUserName] = useState(''); const [userName, setUserName] = useState('');
const [deviceCode, setDeviceCode] = useState(bindList?.code);
const [tableData, setTableData] = useState([]); const [tableData, setTableData] = useState([]);
const [tableLoading, setTableLoading] = useState(true); const [tableLoading, setTableLoading] = useState(true);
const [totalNum, setTotalNum] = useState(0); const [totalNum, setTotalNum] = useState(0);
...@@ -60,26 +91,7 @@ const ControlRecords = ({ nodeData, bindList }) => { ...@@ -60,26 +91,7 @@ const ControlRecords = ({ nodeData, bindList }) => {
align: 'center', align: 'center',
width: 100, width: 100,
ellipsis: true, ellipsis: true,
}, render: (record) => (record ? moment(record).format('YYYY-MM-DD HH:mm:ss') : '-'),
{
title: '控制点位',
dataIndex: 'controlPoint',
align: 'center',
width: 140,
ellipsis: true,
onCell: () => ({
style: {
maxWidth: 140,
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
},
}),
render: (record) => (
<Tooltip placement="topLeft" title={record}>
{record}
</Tooltip>
),
}, },
{ {
title: '初始状态', title: '初始状态',
...@@ -123,7 +135,7 @@ const ControlRecords = ({ nodeData, bindList }) => { ...@@ -123,7 +135,7 @@ const ControlRecords = ({ nodeData, bindList }) => {
), ),
}, },
{ {
title: '等待时间', title: '等待时间(ms)',
dataIndex: 'controlWatiTime', dataIndex: 'controlWatiTime',
width: 80, width: 80,
align: 'center', align: 'center',
...@@ -161,25 +173,81 @@ const ControlRecords = ({ nodeData, bindList }) => { ...@@ -161,25 +173,81 @@ const ControlRecords = ({ nodeData, bindList }) => {
}); });
}; };
const timeChange = (dates, dateStrings) => {
setTime(dateStrings);
};
const userChange = (e) => { const userChange = (e) => {
setUserName(e.target.value); setUserName(e.target.value);
}; };
const userEnter = (e) => {
setParams({
...params,
pageIndex: 1,
dateFrom: time[0],
dateTo: time[1],
userName: e.target.value,
});
};
const timeChange = (dates) => {
onDateChange('customer', dates);
};
const onRadioChange = (e) => {
onDateChange(e.target.value);
};
const onDateChange = (key, data = []) => {
let start = '',
end = '';
switch (key) {
case 'roundClock':
start = moment().subtract(24, 'hour').format('YYYY-MM-DD HH:mm:ss');
end = moment().format('YYYY-MM-DD HH:mm:ss');
break;
case 'thisWeek':
start = moment().startOf('week').format(startFormat);
end = moment().endOf('week').format(endFormat);
break;
case 'thisMonth':
start = moment().startOf('month').format(startFormat);
end = moment().endOf('month').format(endFormat);
break;
case 'thisQuarter':
start = moment().startOf('quarter').format(startFormat);
end = moment().endOf('quarter').format(endFormat);
break;
case 'thisYear':
start = moment().startOf('year').format(startFormat);
end = moment().endOf('year').format(endFormat);
break;
case 'customer':
if (data && data.length > 0) {
start = moment(data[0]).format(startFormat);
end = moment(data[1]).format(endFormat);
} else {
return setDateValue(key);
}
break;
}
setDateValue(key);
setTime([start, end]);
if (data && data.length > 0) return false;
setParams({
...params,
pageIndex: 1,
dateFrom: time[0],
dateTo: time[1],
userName: userName,
});
};
const pageChange = (pageIndex, pageSize) => { const pageChange = (pageIndex, pageSize) => {
// 分页改变 // 分页改变
params.pageIndex = pageIndex; setParams({ ...params, pageIndex: pageIndex, pageSize: pageSize });
params.pageSize = pageSize;
setParams({ ...params });
}; };
const operateBtn = () => { const operateBtn = () => {
const _params = { const _params = {
pageIndex: 1, pageIndex: 1,
deviceCode: deviceCode,
dateFrom: time[0], dateFrom: time[0],
dateTo: time[1], dateTo: time[1],
userName: userName, userName: userName,
...@@ -198,38 +266,36 @@ const ControlRecords = ({ nodeData, bindList }) => { ...@@ -198,38 +266,36 @@ const ControlRecords = ({ nodeData, bindList }) => {
<div className={classNames(prefixCls)}> <div className={classNames(prefixCls)}>
<div className={classNames('recordsHeaderWrap')}> <div className={classNames('recordsHeaderWrap')}>
<div className={classNames('recordsHeader')}> <div className={classNames('recordsHeader')}>
<span className={classNames('operateName', 'operateTime')}>设备类型:</span> <Radio.Group value={dateValue} onChange={onRadioChange}>
<Input {dateList.map((item) => (
placeholder="请输入设备类型" <Radio.Button key={item.key} value={item.key}>
readOnly {item.name}
value={bindList?.type || ''} </Radio.Button>
style={{ width: 150 }} ))}
/> </Radio.Group>
<span className={classNames('operateName')}>设备编码:</span> {
<Input
placeholder="请输入设备编码"
readOnly
value={bindList?.code || ''}
style={{ width: 150 }}
/>
<span className={classNames('operateName')}>操作时间:</span>
<RangePicker <RangePicker
showTime showTime
allowClear={false} allowClear={false}
value={[moment(time[0], dateFormat), moment(time[1], dateFormat)]} value={[moment(time[0], dateFormat), moment(time[1], dateFormat)]}
onChange={timeChange} onChange={timeChange}
disabled={dateValue !== 'customer'}
style={{ marginLeft: '10px' }}
/> />
}
<span className={classNames('operateName')}>操作人:</span> <span className={classNames('operateName')}>操作人:</span>
<Input <Input
placeholder="请输入操作人" placeholder="请输入操作人"
allowClear allowClear
onChange={userChange} onChange={userChange}
onPressEnter={userEnter}
style={{ width: 150 }} style={{ width: 150 }}
/> />
<Button type="primary" className={classNames('operateName')} onClick={operateBtn}> <Button type="primary" className={classNames('operateName')} onClick={operateBtn}>
确定 确定
</Button> </Button>
</div> </div>
<div className={classNames('recordsHeaderInfo')}>{`设备编码:${bindList?.code || ''}`}</div>
</div> </div>
<div className={classNames('recordscontent')}> <div className={classNames('recordscontent')}>
<BasicTable <BasicTable
......
...@@ -12,17 +12,19 @@ ...@@ -12,17 +12,19 @@
.recordsHeaderWrap { .recordsHeaderWrap {
display: flex; display: flex;
align-items: center; align-items: flex-end;
justify-content: space-between; justify-content: space-between;
margin-bottom: 5px; margin-bottom: 5px;
background: #ffffff; background: #ffffff;
padding-bottom: 10px; flex-direction: column;
flex: none;
} }
.recordsHeader { .recordsHeader {
display: flex; display: flex;
align-items: center; align-items: center;
flex: none; flex: none;
width: 100%;
.operateName { .operateName {
flex: none; flex: none;
......
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