From a7d46c04f5714ce6f7882f3090aed10e54e41837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=9D=D0=B0=D0=B4=D0=B5?= =?UTF-8?q?=D0=B8=D0=BD?= Date: Mon, 29 Dec 2025 15:32:27 +0300 Subject: [PATCH] =?UTF-8?q?feat(requests):=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82?= =?UTF-8?q?=D1=80=D1=8B=20=D0=BF=D0=BE=20=D1=81=D0=BE=D1=82=D1=80=D1=83?= =?UTF-8?q?=D0=B4=D0=BD=D0=B8=D0=BA=D1=83=20=D0=B8=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B8=D0=BE=D0=B4=D1=83=20=D0=B4=D0=B0=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/requests_app/views.py | 33 +++++++++++++++++++ .../js/components/requestListHandler.js | 20 ++++++++++- backend/templates/requests_app/_filters.html | 27 ++++++++++++--- 3 files changed, 75 insertions(+), 5 deletions(-) diff --git a/backend/requests_app/views.py b/backend/requests_app/views.py index a56d4001..3d2da97d 100644 --- a/backend/requests_app/views.py +++ b/backend/requests_app/views.py @@ -239,10 +239,20 @@ class RequestsView(LoginRequiredMixin, TemplateView): type_ = (request.GET.get("type") or "").strip() status_ = (request.GET.get("status") or "").strip() + employee_id = (request.GET.get("employee_id") or "").strip() + date_from = (request.GET.get("date_from") or "").strip() + date_to = (request.GET.get("date_to") or "").strip() + if type_: params["type"] = type_ if status_: params["status"] = status_ + if employee_id: + params["employee_id"] = employee_id + if date_from: + params["date_from"] = date_from + if date_to: + params["date_to"] = date_to # NB: в API сортировки нет — параметр `ordering` не прокидываем. @@ -254,6 +264,14 @@ class RequestsView(LoginRequiredMixin, TemplateView): data.get("detail") or f"Не удалось загрузить список заявлений (HTTP {status}).", ) + + # Загружаем список сотрудников для фильтра + employees = [] + ok_emp, data_emp, _ = _api_unpack(api.get("v1/employees/", params={"page_size": 1000})) + if ok_emp: + employees_results, _, _, _ = _parse_page_payload(data_emp) + employees = employees_results + ctx.update( { "requests": [], @@ -262,10 +280,14 @@ class RequestsView(LoginRequiredMixin, TemplateView): "count": None, "scope": scope, "can_process": _user_can_process_requests(request.user), + "employees": employees, "filters": { "type": type_, "status": status_, "view": scope, + "employee_id": employee_id, + "date_from": date_from, + "date_to": date_to, }, } ) @@ -273,6 +295,13 @@ class RequestsView(LoginRequiredMixin, TemplateView): results, next_url, prev_url, count = _parse_page_payload(data) + # Загружаем список сотрудников для фильтра + employees = [] + ok_emp, data_emp, _ = _api_unpack(api.get("v1/employees/", params={"page_size": 1000})) + if ok_emp: + employees_results, _, _, _ = _parse_page_payload(data_emp) + employees = employees_results + ctx.update( { "requests": results, @@ -281,10 +310,14 @@ class RequestsView(LoginRequiredMixin, TemplateView): "count": count, "scope": scope, "can_process": _user_can_process_requests(request.user), + "employees": employees, "filters": { "type": type_, "status": status_, "view": scope, + "employee_id": employee_id, + "date_from": date_from, + "date_to": date_to, }, } ) diff --git a/backend/static/js/components/requestListHandler.js b/backend/static/js/components/requestListHandler.js index 84661177..2372ae95 100644 --- a/backend/static/js/components/requestListHandler.js +++ b/backend/static/js/components/requestListHandler.js @@ -35,6 +35,9 @@ export function initRequestListHandler(options) { let currentView = urlParams.get("view") || ""; // 'mine' | 'addressed' | '' let currentType = urlParams.get("type") || ""; let currentStatus = urlParams.get("status") || ""; + let currentEmployeeId = urlParams.get("employee_id") || ""; + let currentDateFrom = urlParams.get("date_from") || ""; + let currentDateTo = urlParams.get("date_to") || ""; let searchQuery = ""; // Поисковый запрос let allRequests = []; // Все загруженные заявления let loading = false; @@ -48,7 +51,13 @@ export function initRequestListHandler(options) { "type =", currentType, "status =", - currentStatus + currentStatus, + "employee_id =", + currentEmployeeId, + "date_from =", + currentDateFrom, + "date_to =", + currentDateTo ); // Intersection Observer для бесконечной прокрутки @@ -114,6 +123,15 @@ export function initRequestListHandler(options) { if (currentStatus) { params.append("status", currentStatus); } + if (currentEmployeeId) { + params.append("employee_id", currentEmployeeId); + } + if (currentDateFrom) { + params.append("date_from", currentDateFrom); + } + if (currentDateTo) { + params.append("date_to", currentDateTo); + } url = `${apiListUrl}?${params}`; console.log("loadRequests: initial load", url); diff --git a/backend/templates/requests_app/_filters.html b/backend/templates/requests_app/_filters.html index d4d5ec99..d97c5fe1 100644 --- a/backend/templates/requests_app/_filters.html +++ b/backend/templates/requests_app/_filters.html @@ -5,7 +5,7 @@ {% endif %} -
+
-
+
-
-