update approvals page
Deploy Frontend / build-and-deploy (push) Successful in 28s
Details
Deploy Frontend / build-and-deploy (push) Successful in 28s
Details
This commit is contained in:
parent
64bd6bd147
commit
74bf66554b
|
|
@ -6,8 +6,12 @@ export interface ApprovalsListParams {
|
||||||
limit?: number
|
limit?: number
|
||||||
status?: string
|
status?: string
|
||||||
initiator_id?: number
|
initiator_id?: number
|
||||||
topic_id?: number
|
topic_id?: number // одиночный (для обратной совместимости)
|
||||||
|
topic_ids?: number[] // 🆕 множественный выбор тем
|
||||||
|
category_ids?: number[] // 🆕 множественный выбор категорий
|
||||||
department_id?: number
|
department_id?: number
|
||||||
|
date_from?: string // 🆕 YYYY-MM-DD
|
||||||
|
date_to?: string // 🆕 YYYY-MM-DD
|
||||||
content?: string
|
content?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,8 +29,30 @@ export interface UpdateApprovalRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const approvalsApi = {
|
export const approvalsApi = {
|
||||||
getList: (params: ApprovalsListParams = {}) =>
|
getList: (params: ApprovalsListParams = {}) => {
|
||||||
apiClient.get<ApiResponse<Approval[]>>('/approvals', { params }),
|
// Формируем query-параметры, корректно сериализуя массивы
|
||||||
|
const query: Record<string, any> = {}
|
||||||
|
|
||||||
|
if (params.offset !== undefined) query.offset = params.offset
|
||||||
|
if (params.limit !== undefined) query.limit = params.limit
|
||||||
|
if (params.status) query.status = params.status
|
||||||
|
if (params.initiator_id) query.initiator_id = params.initiator_id
|
||||||
|
if (params.topic_id) query.topic_id = params.topic_id
|
||||||
|
if (params.department_id) query.department_id = params.department_id
|
||||||
|
if (params.content) query.content = params.content
|
||||||
|
if (params.date_from) query.date_from = params.date_from
|
||||||
|
if (params.date_to) query.date_to = params.date_to
|
||||||
|
|
||||||
|
// 🆕 Массивы передаём через запятую: "1,2,3"
|
||||||
|
if (params.topic_ids && params.topic_ids.length > 0) {
|
||||||
|
query.topic_ids = params.topic_ids.join(',')
|
||||||
|
}
|
||||||
|
if (params.category_ids && params.category_ids.length > 0) {
|
||||||
|
query.category_ids = params.category_ids.join(',')
|
||||||
|
}
|
||||||
|
|
||||||
|
return apiClient.get<ApiResponse<Approval[]>>('/approvals', { params: query })
|
||||||
|
},
|
||||||
|
|
||||||
getById: (id: number) =>
|
getById: (id: number) =>
|
||||||
apiClient.get<Approval>(`/approvals/${id}`),
|
apiClient.get<Approval>(`/approvals/${id}`),
|
||||||
|
|
@ -37,7 +63,6 @@ export const approvalsApi = {
|
||||||
delete: (id: number) =>
|
delete: (id: number) =>
|
||||||
apiClient.delete<boolean>('/approvals', { data: { id } }),
|
apiClient.delete<boolean>('/approvals', { data: { id } }),
|
||||||
|
|
||||||
// 🆕 Получение заявок для отчёта (с фильтрами по датам)
|
|
||||||
getForReport: (params: ApprovalsReportParams = {}) =>
|
getForReport: (params: ApprovalsReportParams = {}) =>
|
||||||
apiClient.get<ApiResponse<Approval[]>>('/approvals/report', { params }),
|
apiClient.get<ApiResponse<Approval[]>>('/approvals/report', { params }),
|
||||||
|
|
||||||
|
|
@ -46,30 +71,28 @@ export const approvalsApi = {
|
||||||
params,
|
params,
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
getFile: (approvalId: number, fileId: number) =>
|
getFile: (approvalId: number, fileId: number) =>
|
||||||
apiClient.get(`/approvals/${approvalId}/files/${fileId}`, {
|
apiClient.get(`/approvals/${approvalId}/files/${fileId}`, {
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
}),
|
}),
|
||||||
|
|
||||||
downloadFile: (approvalId: number, fileId: number, fileName: string) => {
|
downloadFile: (approvalId: number, fileId: number, fileName: string) => {
|
||||||
const token = localStorage.getItem('token')
|
const token = localStorage.getItem('token')
|
||||||
const apiKey = import.meta.env.VITE_API_KEY
|
|
||||||
const timestamp = Math.floor(Date.now() / 1000).toString()
|
const timestamp = Math.floor(Date.now() / 1000).toString()
|
||||||
const deviceId = localStorage.getItem('device_id') || 'admin-panel'
|
const deviceId = localStorage.getItem('device_id') || 'admin-panel'
|
||||||
|
|
||||||
// Генерируем HMAC подпись (как в client.ts)
|
|
||||||
const publicKey = import.meta.env.VITE_API_PUBLIC_KEY
|
const publicKey = import.meta.env.VITE_API_PUBLIC_KEY
|
||||||
const privateKey = import.meta.env.VITE_API_PRIVATE_KEY
|
const privateKey = import.meta.env.VITE_API_PRIVATE_KEY
|
||||||
const message = publicKey + ":" + timestamp
|
const message = publicKey + ":" + timestamp
|
||||||
const signature = CryptoJS.HmacSHA256(message, privateKey).toString(CryptoJS.enc.Hex)
|
const signature = CryptoJS.HmacSHA256(message, privateKey).toString(CryptoJS.enc.Hex)
|
||||||
|
|
||||||
// Создаём URL с query параметрами
|
|
||||||
const url = `${apiClient.defaults.baseURL}/approvals/${approvalId}/files/${fileId}/download`
|
const url = `${apiClient.defaults.baseURL}/approvals/${approvalId}/files/${fileId}/download`
|
||||||
|
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = `${url}?_t=${timestamp}`
|
link.href = `${url}?_t=${timestamp}`
|
||||||
link.setAttribute('download', fileName)
|
link.setAttribute('download', fileName)
|
||||||
|
|
||||||
// Добавляем заголовки через fetch
|
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import {useEffect, useState} from 'react'
|
import { useEffect, useState, useMemo } from 'react'
|
||||||
import {
|
import {
|
||||||
Paper,
|
Paper,
|
||||||
Table,
|
Table,
|
||||||
|
|
@ -9,6 +9,7 @@ import {
|
||||||
Text,
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
Select,
|
Select,
|
||||||
|
MultiSelect,
|
||||||
Pagination,
|
Pagination,
|
||||||
Loader,
|
Loader,
|
||||||
Center,
|
Center,
|
||||||
|
|
@ -19,17 +20,26 @@ import {
|
||||||
Alert,
|
Alert,
|
||||||
} from '@mantine/core'
|
} from '@mantine/core'
|
||||||
import { DatePickerInput } from '@mantine/dates'
|
import { DatePickerInput } from '@mantine/dates'
|
||||||
import {IconEye, IconSearch, IconFileText, IconFileExcel, IconInfoCircle, IconX} from '@tabler/icons-react'
|
import {
|
||||||
|
IconEye,
|
||||||
|
IconSearch,
|
||||||
|
IconFileText,
|
||||||
|
IconFileExcel,
|
||||||
|
IconInfoCircle,
|
||||||
|
IconX,
|
||||||
|
IconFilter,
|
||||||
|
} from '@tabler/icons-react'
|
||||||
import { notifications } from '@mantine/notifications'
|
import { notifications } from '@mantine/notifications'
|
||||||
import { useApprovals } from '@/features/approvals/hooks/useApprovals'
|
import { useApprovals } from '@/features/approvals/hooks/useApprovals'
|
||||||
import { useTopics } from '@/features/topics/hooks/useTopics'
|
import { useTopics } from '@/features/topics/hooks/useTopics'
|
||||||
import { useDepartments } from '@/features/departments/hooks/useDepartments'
|
import { useDepartments } from '@/features/departments/hooks/useDepartments'
|
||||||
import { useCategories } from '@/features/categories/hooks/useCategories'
|
import { useCategories } from '@/features/categories/hooks/useCategories'
|
||||||
|
import { useUsers } from '@/features/users/hooks/useUsers'
|
||||||
import { approvalsApi } from '@/api/approvals'
|
import { approvalsApi } from '@/api/approvals'
|
||||||
import ApprovalDetailsModal from './components/ApprovalDetailsModal'
|
import ApprovalDetailsModal from './components/ApprovalDetailsModal'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import 'dayjs/locale/ru'
|
import 'dayjs/locale/ru'
|
||||||
import {useDebouncedValue} from "@mantine/hooks";
|
import { useDebouncedValue } from '@mantine/hooks'
|
||||||
|
|
||||||
dayjs.locale('ru')
|
dayjs.locale('ru')
|
||||||
|
|
||||||
|
|
@ -52,24 +62,29 @@ const STATUS_LABELS: Record<string, string> = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ApprovalsPage() {
|
export default function ApprovalsPage() {
|
||||||
// Фильтры списка
|
// === Состояния фильтров ===
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
|
const [searchInput, setSearchInput] = useState('')
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
const [statusFilter, setStatusFilter] = useState<string | null>(null)
|
const [searchError, setSearchError] = useState<string | null>(null)
|
||||||
const [categoryFilter, setCategoryFilter] = useState<string | null>(null)
|
const [debouncedSearch] = useDebouncedValue(searchInput, 400)
|
||||||
const [topicFilter, setTopicFilter] = useState<string | null>(null)
|
|
||||||
const [departmentFilter, setDepartmentFilter] = useState<string | null>(null)
|
|
||||||
|
|
||||||
|
const [statusFilter, setStatusFilter] = useState<string | null>(null)
|
||||||
|
const [categoryFilter, setCategoryFilter] = useState<string[]>([])
|
||||||
|
const [topicFilter, setTopicFilter] = useState<string[]>([])
|
||||||
|
const [departmentFilter, setDepartmentFilter] = useState<string | null>(null) // 🆕 БЫЛО ПРОПУЩЕНО
|
||||||
|
const [initiatorFilter, setInitiatorFilter] = useState<string | null>(null)
|
||||||
|
const [dateFrom, setDateFrom] = useState<Date | null>(null)
|
||||||
|
const [dateTo, setDateTo] = useState<Date | null>(null)
|
||||||
|
|
||||||
|
// === Отчёт ===
|
||||||
const [reportDateFrom, setReportDateFrom] = useState<Date | null>(null)
|
const [reportDateFrom, setReportDateFrom] = useState<Date | null>(null)
|
||||||
const [reportDateTo, setReportDateTo] = useState<Date | null>(null)
|
const [reportDateTo, setReportDateTo] = useState<Date | null>(null)
|
||||||
const [reportLoading, setReportLoading] = useState(false)
|
const [reportLoading, setReportLoading] = useState(false)
|
||||||
|
|
||||||
const [selectedApprovalId, setSelectedApprovalId] = useState<number | null>(null)
|
const [selectedApprovalId, setSelectedApprovalId] = useState<number | null>(null)
|
||||||
|
|
||||||
const [searchInput, setSearchInput] = useState('')
|
// === Обработка поиска ===
|
||||||
const [searchError, setSearchError] = useState<string | null>(null)
|
|
||||||
const [debouncedSearch] = useDebouncedValue(searchInput, 400)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debouncedSearch === '') {
|
if (debouncedSearch === '') {
|
||||||
setSearch('')
|
setSearch('')
|
||||||
|
|
@ -77,89 +92,153 @@ export default function ApprovalsPage() {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debouncedSearch.length < 2) {
|
if (debouncedSearch.length < 2) {
|
||||||
setSearchError('Введите минимум 2 символа')
|
setSearchError('Введите минимум 2 символа')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
setSearchError(null)
|
setSearchError(null)
|
||||||
setSearch(debouncedSearch)
|
setSearch(debouncedSearch)
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}, [debouncedSearch])
|
}, [debouncedSearch])
|
||||||
|
|
||||||
const { data: categoryTopics } = useTopics({
|
// === Загрузка справочников ===
|
||||||
limit: 1000,
|
|
||||||
...(categoryFilter && { category_id: Number(categoryFilter) }),
|
|
||||||
})
|
|
||||||
|
|
||||||
const effectiveTopicFilter = categoryFilter && categoryTopics?.data?.length === 1
|
|
||||||
? String(categoryTopics.data[0].id)
|
|
||||||
: topicFilter
|
|
||||||
|
|
||||||
const { data, isLoading, isFetching } = useApprovals({
|
|
||||||
offset: (page - 1) * LIMIT,
|
|
||||||
limit: LIMIT,
|
|
||||||
...(search && { content: search }),
|
|
||||||
...(statusFilter && { status: statusFilter }),
|
|
||||||
...(effectiveTopicFilter && { topic_id: Number(effectiveTopicFilter) }),
|
|
||||||
...(departmentFilter && { department_id: Number(departmentFilter) }),
|
|
||||||
})
|
|
||||||
|
|
||||||
const { data: categories } = useCategories({ limit: 1000 })
|
const { data: categories } = useCategories({ limit: 1000 })
|
||||||
const { data: topics } = useTopics({ limit: 1000 })
|
const { data: allTopics } = useTopics({ limit: 1000 })
|
||||||
const { data: departments } = useDepartments()
|
const { data: departments } = useDepartments()
|
||||||
|
const { data: users } = useUsers({ limit: 1000 })
|
||||||
|
|
||||||
|
// === Темы, отфильтрованные по выбранным категориям ===
|
||||||
|
const filteredTopics = useMemo(() => {
|
||||||
|
if (!allTopics?.data) return []
|
||||||
|
if (categoryFilter.length === 0) return allTopics.data
|
||||||
|
const categoryIds = categoryFilter.map(Number)
|
||||||
|
return allTopics.data.filter((t) =>
|
||||||
|
t.category_id && categoryIds.includes(t.category_id)
|
||||||
|
)
|
||||||
|
}, [allTopics, categoryFilter])
|
||||||
|
|
||||||
|
// === Сброс невалидных тем при изменении категорий ===
|
||||||
|
useEffect(() => {
|
||||||
|
if (categoryFilter.length > 0 && topicFilter.length > 0) {
|
||||||
|
const validTopicIds = new Set(filteredTopics.map((t) => String(t.id)))
|
||||||
|
const validSelected = topicFilter.filter((id) => validTopicIds.has(id))
|
||||||
|
if (validSelected.length !== topicFilter.length) {
|
||||||
|
setTopicFilter(validSelected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Если категории сброшены — темы остаются как есть
|
||||||
|
}, [categoryFilter, filteredTopics, topicFilter])
|
||||||
|
|
||||||
|
// === Опции для Select/MultiSelect ===
|
||||||
|
const categoryOptions = useMemo(
|
||||||
|
() =>
|
||||||
|
categories?.data?.map((c) => ({
|
||||||
|
value: String(c.id),
|
||||||
|
label: c.name || '',
|
||||||
|
})) || [],
|
||||||
|
[categories]
|
||||||
|
)
|
||||||
|
|
||||||
|
const topicOptions = useMemo(
|
||||||
|
() =>
|
||||||
|
filteredTopics.map((t) => ({
|
||||||
|
value: String(t.id),
|
||||||
|
label: `${t.category?.name || '—'} / ${t.name || ''}`,
|
||||||
|
})),
|
||||||
|
[filteredTopics]
|
||||||
|
)
|
||||||
|
|
||||||
|
const departmentOptions = useMemo(
|
||||||
|
() =>
|
||||||
|
departments?.data?.map((d) => ({
|
||||||
|
value: String(d.id),
|
||||||
|
label: d.name || '',
|
||||||
|
})) || [],
|
||||||
|
[departments]
|
||||||
|
)
|
||||||
|
|
||||||
|
const userOptions = useMemo(
|
||||||
|
() =>
|
||||||
|
users?.data?.map((u) => ({
|
||||||
|
value: String(u.id),
|
||||||
|
label: u.full_name || u.username || `ID: ${u.id}`,
|
||||||
|
})) || [],
|
||||||
|
[users]
|
||||||
|
)
|
||||||
|
|
||||||
|
// === Формирование параметров запроса ===
|
||||||
|
const requestParams = useMemo(() => {
|
||||||
|
const params: any = {
|
||||||
|
offset: (page - 1) * LIMIT,
|
||||||
|
limit: LIMIT,
|
||||||
|
}
|
||||||
|
if (search) params.content = search
|
||||||
|
if (statusFilter) params.status = statusFilter
|
||||||
|
if (departmentFilter) params.department_id = Number(departmentFilter)
|
||||||
|
if (initiatorFilter) params.initiator_id = Number(initiatorFilter)
|
||||||
|
if (categoryFilter.length > 0) {
|
||||||
|
params.category_ids = categoryFilter.map(Number)
|
||||||
|
}
|
||||||
|
if (topicFilter.length > 0) {
|
||||||
|
params.topic_ids = topicFilter.map(Number)
|
||||||
|
}
|
||||||
|
if (dateFrom) params.date_from = dayjs(dateFrom).format('YYYY-MM-DD')
|
||||||
|
if (dateTo) params.date_to = dayjs(dateTo).format('YYYY-MM-DD')
|
||||||
|
return params
|
||||||
|
}, [
|
||||||
|
page, search, statusFilter, departmentFilter,
|
||||||
|
initiatorFilter, categoryFilter, topicFilter, dateFrom, dateTo,
|
||||||
|
])
|
||||||
|
|
||||||
|
// === Запрос списка заявок ===
|
||||||
|
const { data, isLoading, isFetching } = useApprovals(requestParams)
|
||||||
|
|
||||||
const totalPages = data?.total_count ? Math.ceil(data.total_count / LIMIT) : 1
|
const totalPages = data?.total_count ? Math.ceil(data.total_count / LIMIT) : 1
|
||||||
|
|
||||||
const categoryOptions = categories?.data?.map((c) => ({
|
// === Сброс фильтров ===
|
||||||
value: String(c.id),
|
const handleResetFilters = () => {
|
||||||
label: c.name || '',
|
setSearchInput('')
|
||||||
})) || []
|
setSearch('')
|
||||||
|
setStatusFilter(null)
|
||||||
const topicOptions = topics?.data?.map((t) => ({
|
setCategoryFilter([])
|
||||||
value: String(t.id),
|
setTopicFilter([])
|
||||||
label: t.name || '',
|
setDepartmentFilter(null)
|
||||||
})) || []
|
setInitiatorFilter(null)
|
||||||
|
setDateFrom(null)
|
||||||
const departmentOptions = departments?.data?.map((d) => ({
|
setDateTo(null)
|
||||||
value: String(d.id),
|
|
||||||
label: d.name || '',
|
|
||||||
})) || []
|
|
||||||
|
|
||||||
const handleCategoryChange = (value: string | null) => {
|
|
||||||
setCategoryFilter(value)
|
|
||||||
setTopicFilter(null)
|
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 🆕 Генерация отчёта
|
const hasActiveFilters =
|
||||||
|
search ||
|
||||||
|
statusFilter ||
|
||||||
|
categoryFilter.length > 0 ||
|
||||||
|
topicFilter.length > 0 ||
|
||||||
|
departmentFilter ||
|
||||||
|
initiatorFilter ||
|
||||||
|
dateFrom ||
|
||||||
|
dateTo
|
||||||
|
|
||||||
|
// === Генерация отчёта ===
|
||||||
const handleGenerateReport = async () => {
|
const handleGenerateReport = async () => {
|
||||||
setReportLoading(true)
|
setReportLoading(true)
|
||||||
try {
|
try {
|
||||||
const params: any = { all_access: true }
|
const params: any = { all_access: true }
|
||||||
|
if (reportDateFrom) params.date_from = dayjs(reportDateFrom).format('YYYY-MM-DD')
|
||||||
if (reportDateFrom) {
|
if (reportDateTo) params.date_to = dayjs(reportDateTo).format('YYYY-MM-DD')
|
||||||
params.date_from = dayjs(reportDateFrom).format('YYYY-MM-DD')
|
|
||||||
}
|
|
||||||
if (reportDateTo) {
|
|
||||||
params.date_to = dayjs(reportDateTo).format('YYYY-MM-DD')
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await approvalsApi.downloadReport(params)
|
const response = await approvalsApi.downloadReport(params)
|
||||||
|
|
||||||
const blob = new Blob([response.data], {
|
const blob = new Blob([response.data], {
|
||||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
})
|
})
|
||||||
|
|
||||||
const url = window.URL.createObjectURL(blob)
|
const url = window.URL.createObjectURL(blob)
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a')
|
||||||
link.href = url
|
link.href = url
|
||||||
|
|
||||||
const now = dayjs()
|
const now = dayjs()
|
||||||
let fileName = `Согласования_${now.format('DD.MM.YYYY')}_${now.format('HH-mm')}.xlsx`
|
link.setAttribute(
|
||||||
|
'download',
|
||||||
link.setAttribute('download', fileName)
|
`Согласования_${now.format('DD.MM.YYYY')}_${now.format('HH-mm')}.xlsx`
|
||||||
|
)
|
||||||
document.body.appendChild(link)
|
document.body.appendChild(link)
|
||||||
link.click()
|
link.click()
|
||||||
link.remove()
|
link.remove()
|
||||||
|
|
@ -171,20 +250,11 @@ export default function ApprovalsPage() {
|
||||||
color: 'green',
|
color: 'green',
|
||||||
})
|
})
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
if (error.response?.data instanceof Blob) {
|
notifications.show({
|
||||||
const text = await error.response.data.text()
|
title: 'Ошибка',
|
||||||
notifications.show({
|
message: error.response?.data?.error_description || 'Не удалось сформировать отчёт',
|
||||||
title: 'Ошибка',
|
color: 'red',
|
||||||
message: text || 'Не удалось сформировать отчёт',
|
})
|
||||||
color: 'red',
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
notifications.show({
|
|
||||||
title: 'Ошибка',
|
|
||||||
message: error.response?.data?.error_description || 'Не удалось сформировать отчёт',
|
|
||||||
color: 'red',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
setReportLoading(false)
|
setReportLoading(false)
|
||||||
}
|
}
|
||||||
|
|
@ -192,7 +262,7 @@ export default function ApprovalsPage() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
{/* Заголовок и кнопка отчёта */}
|
{/* Заголовок */}
|
||||||
<Group justify="space-between">
|
<Group justify="space-between">
|
||||||
<Text size="xl" fw={700}>Заявки</Text>
|
<Text size="xl" fw={700}>Заявки</Text>
|
||||||
<Text c="dimmed" size="sm">
|
<Text c="dimmed" size="sm">
|
||||||
|
|
@ -200,7 +270,7 @@ export default function ApprovalsPage() {
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
{/* 🆕 Секция формирования отчёта */}
|
{/* Секция отчёта */}
|
||||||
<Paper withBorder p="md" bg="blue.0">
|
<Paper withBorder p="md" bg="blue.0">
|
||||||
<Stack gap="sm">
|
<Stack gap="sm">
|
||||||
<Group justify="space-between">
|
<Group justify="space-between">
|
||||||
|
|
@ -251,11 +321,29 @@ export default function ApprovalsPage() {
|
||||||
|
|
||||||
{/* Фильтры списка */}
|
{/* Фильтры списка */}
|
||||||
<Paper withBorder p="md">
|
<Paper withBorder p="md">
|
||||||
<Text fw={600} size="lg" mb="sm">Фильтры списка</Text>
|
<Group justify="space-between" mb="sm">
|
||||||
|
<Group gap="xs">
|
||||||
|
<IconFilter size={20} />
|
||||||
|
<Text fw={600} size="lg">Фильтры</Text>
|
||||||
|
</Group>
|
||||||
|
{hasActiveFilters && (
|
||||||
|
<Button
|
||||||
|
variant="subtle"
|
||||||
|
color="gray"
|
||||||
|
size="xs"
|
||||||
|
leftSection={<IconX size={14} />}
|
||||||
|
onClick={handleResetFilters}
|
||||||
|
>
|
||||||
|
Сбросить фильтры
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Group>
|
||||||
|
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
<Group gap="md" align="flex-end">
|
{/* Строка 1: Поиск + Статус + Инициатор */}
|
||||||
|
<Group gap="md" align="flex-end" grow>
|
||||||
<TextInput
|
<TextInput
|
||||||
label="Поиск по тексту заявки"
|
label="Поиск по тексту"
|
||||||
placeholder="Введите 2+ символа..."
|
placeholder="Введите 2+ символа..."
|
||||||
leftSection={<IconSearch size={16} />}
|
leftSection={<IconSearch size={16} />}
|
||||||
value={searchInput}
|
value={searchInput}
|
||||||
|
|
@ -271,7 +359,6 @@ export default function ApprovalsPage() {
|
||||||
</ActionIcon>
|
</ActionIcon>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
style={{ flex: 1 }}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
|
|
@ -290,14 +377,45 @@ export default function ApprovalsPage() {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}}
|
}}
|
||||||
clearable
|
clearable
|
||||||
style={{ minWidth: 180 }}
|
/>
|
||||||
|
|
||||||
|
<Select
|
||||||
|
label="Инициатор"
|
||||||
|
placeholder="Все инициаторы"
|
||||||
|
data={userOptions}
|
||||||
|
value={initiatorFilter}
|
||||||
|
onChange={(v) => {
|
||||||
|
setInitiatorFilter(v)
|
||||||
|
setPage(1)
|
||||||
|
}}
|
||||||
|
clearable
|
||||||
|
searchable
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group gap="md" align="flex-end">
|
{/* Строка 2: Категории + Темы + Отдел */}
|
||||||
<Select
|
<Group gap="md" align="flex-end" grow>
|
||||||
label="Тема"
|
<MultiSelect
|
||||||
placeholder="Все темы"
|
label="Категории"
|
||||||
|
placeholder="Все категории"
|
||||||
|
data={categoryOptions}
|
||||||
|
value={categoryFilter}
|
||||||
|
onChange={(v) => {
|
||||||
|
setCategoryFilter(v)
|
||||||
|
setPage(1)
|
||||||
|
}}
|
||||||
|
clearable
|
||||||
|
searchable
|
||||||
|
nothingFoundMessage="Категории не найдены"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<MultiSelect
|
||||||
|
label="Темы"
|
||||||
|
placeholder={
|
||||||
|
categoryFilter.length > 0
|
||||||
|
? 'Выберите темы'
|
||||||
|
: 'Все темы'
|
||||||
|
}
|
||||||
data={topicOptions}
|
data={topicOptions}
|
||||||
value={topicFilter}
|
value={topicFilter}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
|
@ -306,8 +424,13 @@ export default function ApprovalsPage() {
|
||||||
}}
|
}}
|
||||||
clearable
|
clearable
|
||||||
searchable
|
searchable
|
||||||
style={{ minWidth: 200 }}
|
disabled={filteredTopics.length === 0}
|
||||||
disabled={!!categoryFilter}
|
nothingFoundMessage="Темы не найдены"
|
||||||
|
description={
|
||||||
|
categoryFilter.length > 0
|
||||||
|
? `Показаны темы выбранных категорий (${filteredTopics.length})`
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
|
|
@ -320,9 +443,35 @@ export default function ApprovalsPage() {
|
||||||
setPage(1)
|
setPage(1)
|
||||||
}}
|
}}
|
||||||
clearable
|
clearable
|
||||||
style={{ minWidth: 180 }}
|
|
||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
|
{/* Строка 3: Период дат */}
|
||||||
|
<Group gap="md" align="flex-end" grow>
|
||||||
|
<DatePickerInput
|
||||||
|
label="Дата создания от"
|
||||||
|
placeholder="Выберите дату"
|
||||||
|
value={dateFrom}
|
||||||
|
onChange={(val) => {
|
||||||
|
setDateFrom(val as Date | null)
|
||||||
|
setPage(1)
|
||||||
|
}}
|
||||||
|
clearable
|
||||||
|
maxDate={dateTo || undefined}
|
||||||
|
/>
|
||||||
|
<DatePickerInput
|
||||||
|
label="Дата создания до"
|
||||||
|
placeholder="Выберите дату"
|
||||||
|
value={dateTo}
|
||||||
|
onChange={(val) => {
|
||||||
|
setDateTo(val as Date | null)
|
||||||
|
setPage(1)
|
||||||
|
}}
|
||||||
|
clearable
|
||||||
|
minDate={dateFrom || undefined}
|
||||||
|
/>
|
||||||
|
<Box style={{ flex: 1 }} />
|
||||||
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
|
|
@ -436,14 +585,7 @@ export default function ApprovalsPage() {
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
{isFetching && !isLoading && (
|
{isFetching && !isLoading && (
|
||||||
<Box
|
<Box style={{ position: 'fixed', top: 70, right: 20, zIndex: 1000 }}>
|
||||||
style={{
|
|
||||||
position: 'fixed',
|
|
||||||
top: 70,
|
|
||||||
right: 20,
|
|
||||||
zIndex: 1000
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Loader size="xs" />
|
<Loader size="xs" />
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue