forked from ddrilling/asb_cloud_front
Формат даты исправлен
This commit is contained in:
parent
de72f13bac
commit
e82868bd2e
@ -1,15 +1,15 @@
|
||||
import {Table, Select, DatePicker, Input} from 'antd';
|
||||
import { Table, Select, DatePicker, Input } from 'antd'
|
||||
import { useState, useEffect } from 'react'
|
||||
import moment from 'moment'
|
||||
|
||||
import { MessageService } from '../services/api'
|
||||
import LoaderPortal from '../components/LoaderPortal'
|
||||
import { notify } from "../components/factory"
|
||||
import { notify } from '../components/factory'
|
||||
import '../styles/message.css'
|
||||
|
||||
const { Option } = Select
|
||||
const pageSize = 26
|
||||
const {RangePicker} = DatePicker;
|
||||
const { RangePicker } = DatePicker
|
||||
const { Search } = Input
|
||||
|
||||
// Словарь категорий для строк таблицы
|
||||
@ -24,33 +24,29 @@ const columns = [
|
||||
title: 'Дата',
|
||||
key: 'date',
|
||||
dataIndex: 'date',
|
||||
render: (item) => moment(item).format('DD MMM YYYY, HH:MM:ss'),
|
||||
},
|
||||
{
|
||||
render: item => moment(item).format('DD MMM YYYY, HH:mm:ss'),
|
||||
}, {
|
||||
title: 'Глубина',
|
||||
key: 'wellDepth',
|
||||
dataIndex: 'wellDepth',
|
||||
render: (_, item) => <span>{_} м.</span>,
|
||||
},
|
||||
{
|
||||
render: depth => <span>{depth.toFixed(2)} м.</span>,
|
||||
}, {
|
||||
title: 'Категория',
|
||||
key: 'categoryId',
|
||||
dataIndex: 'categoryId',
|
||||
render: (_, item) => categoryDictionary[item.categoryId].title,
|
||||
style: (_, item) => categoryDictionary[item.categoryId].style,
|
||||
ellipsis: true,
|
||||
},
|
||||
{
|
||||
}, {
|
||||
title: 'Сообщение',
|
||||
key: 'message',
|
||||
dataIndex: 'message',
|
||||
},
|
||||
{
|
||||
}, {
|
||||
title: 'Пользователь',
|
||||
key: 'user',
|
||||
dataIndex: 'user',
|
||||
},
|
||||
];
|
||||
]
|
||||
|
||||
const filterOptions = [
|
||||
{label: 'Важное', value: 1},
|
||||
@ -70,29 +66,15 @@ export default function Messages({idWell}) {
|
||||
|
||||
const children = filterOptions.map((line) => <Option key={line.value}>{line.label}</Option>)
|
||||
|
||||
const onChangeRange = (range) => {
|
||||
setRange(range)
|
||||
}
|
||||
|
||||
const onChangeSearchString = (message) => {
|
||||
if (message.length < 3) {
|
||||
setSearchString('')
|
||||
return
|
||||
}
|
||||
setSearchString(message)
|
||||
}
|
||||
const onChangeRange = (range) => setRange(range)
|
||||
const onChangeSearchString = (message) => setSearchString(message.length > 2 ? message : '')
|
||||
|
||||
useEffect(() => {
|
||||
const GetMessages = async () => {
|
||||
setShowLoader(true)
|
||||
|
||||
try {
|
||||
let begin = null
|
||||
let end = null
|
||||
if (range?.length > 1) {
|
||||
begin = range[0].toISOString()
|
||||
end = range[1].toISOString()
|
||||
}
|
||||
const [begin, end] = range?.length > 1 ? [range[0].toISOString(), range[1].toISOString()] : [null, null]
|
||||
let paginatedMessages = await MessageService.getMessages(idWell,
|
||||
(page - 1) * pageSize,
|
||||
pageSize,
|
||||
@ -106,14 +88,12 @@ export default function Messages({idWell}) {
|
||||
return
|
||||
}
|
||||
|
||||
setMessages(paginatedMessages.items.map(m => {
|
||||
return {
|
||||
setMessages(paginatedMessages.items.map(m => ({
|
||||
key: m.id,
|
||||
categoryids: categoryDictionary[m.categoryId],
|
||||
begin: m.date,
|
||||
...m
|
||||
}
|
||||
}))
|
||||
})))
|
||||
setPagination({
|
||||
total: paginatedMessages.count,
|
||||
current: Math.floor(paginatedMessages.skip / pageSize),
|
||||
@ -133,10 +113,10 @@ export default function Messages({idWell}) {
|
||||
<div className='filter-group'>
|
||||
<h3 className='filter-group-heading'>Фильтр сообщений</h3>
|
||||
<Select
|
||||
mode="multiple"
|
||||
mode={'multiple'}
|
||||
allowClear
|
||||
placeholder="Фильтр сообщений"
|
||||
className="filter-selector"
|
||||
placeholder={'Фильтр сообщений'}
|
||||
className={'filter-selector'}
|
||||
value={categories}
|
||||
onChange={setCategories}>
|
||||
{children}
|
||||
@ -146,8 +126,8 @@ export default function Messages({idWell}) {
|
||||
onChange={onChangeRange}
|
||||
/>
|
||||
<Search
|
||||
className="filter-selector"
|
||||
placeholder="Фильтр сообщений по тексту"
|
||||
className={'filter-selector'}
|
||||
placeholder={'Фильтр сообщений по тексту'}
|
||||
onSearch={onChangeSearchString}
|
||||
/>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user