initial commit
This commit is contained in:
212
static/scripts/applications-table.js
Normal file
212
static/scripts/applications-table.js
Normal file
@ -0,0 +1,212 @@
|
||||
const createTable = () => {
|
||||
const table = document.getElementById("applicationsTable");
|
||||
const tbody = table.querySelector("tbody");
|
||||
|
||||
// Очищаем таблицу
|
||||
tbody.innerHTML = "";
|
||||
|
||||
applications.forEach((application) => {
|
||||
const row = document.createElement("tr");
|
||||
row.setAttribute("onclick", `openApplication(${application.id});`);
|
||||
|
||||
// Добавляем ячейки с данными
|
||||
const id = document.createElement("td");
|
||||
id.textContent = application.id;
|
||||
row.appendChild(id);
|
||||
const status = document.createElement("td");
|
||||
status.textContent = application.status;
|
||||
row.appendChild(status);
|
||||
const type = document.createElement("td");
|
||||
type.textContent = application.type;
|
||||
row.appendChild(type);
|
||||
const worker = document.createElement("td");
|
||||
worker.textContent = application.worker;
|
||||
row.appendChild(worker);
|
||||
const legal = document.createElement("td");
|
||||
legal.innerHTML = application.legal;
|
||||
row.appendChild(legal);
|
||||
const date = document.createElement("td");
|
||||
const rawDate = new Date(application.date);
|
||||
const formattedDate = `${rawDate.getDate().toString().padStart(2, "0")}/${(
|
||||
rawDate.getMonth() + 1
|
||||
)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawDate.getFullYear()}`;
|
||||
date.textContent = formattedDate;
|
||||
row.appendChild(date);
|
||||
|
||||
const finaldate = document.createElement("td");
|
||||
if (application.finaldate) {
|
||||
const rawFinalDate = new Date(application.finaldate);
|
||||
const formattedfinalDate = `${rawFinalDate
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, "0")}/${(rawFinalDate.getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawFinalDate.getFullYear()}`;
|
||||
finaldate.textContent = formattedfinalDate;
|
||||
} else {
|
||||
finaldate.textContent = "";
|
||||
}
|
||||
row.appendChild(finaldate);
|
||||
const car = document.createElement("td");
|
||||
if (application.car) {
|
||||
let carText = application.car.replace(/"/g, '"');
|
||||
carText = JSON.parse(carText).join(", ");
|
||||
car.textContent = carText;
|
||||
}
|
||||
row.appendChild(car);
|
||||
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
createTable();
|
||||
});
|
||||
|
||||
function getCookie(name) {
|
||||
var cookies = document.cookie.split(";");
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i].trim();
|
||||
if (cookie.startsWith(name + "=")) {
|
||||
return cookie.substring(name.length + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function requestUpdate() {
|
||||
document.getElementById("applicationsTable").style.filter =
|
||||
"brightness(0.85)";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("searchText", document.getElementById("table-search").value);
|
||||
formData.append(
|
||||
"page",
|
||||
parseInt(document.getElementById("page-number").textContent)
|
||||
);
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
body: formData,
|
||||
};
|
||||
|
||||
fetch(API_SERVER + "/forms/getapplications", requestOptions)
|
||||
.then((response) => {
|
||||
document.getElementById("applicationsTable").style.filter =
|
||||
"brightness(1)";
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error("Ошибка при отправке POST запроса.");
|
||||
return "Ошибка при отправке запроса.";
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
applications.splice(0, applications.length);
|
||||
|
||||
applications.push(
|
||||
...data.applications.map((item) => ({
|
||||
id: item.id,
|
||||
status: item.Статус,
|
||||
type: item.Вид_заявки,
|
||||
worker: item.Работник,
|
||||
date: item.Дата_заявки,
|
||||
finaldate: item.Дата_решения,
|
||||
legal: item.Организация,
|
||||
car: item.Авто_гос_номер,
|
||||
}))
|
||||
);
|
||||
|
||||
createTable();
|
||||
|
||||
totalMax = Math.ceil(data.totalCount / 15);
|
||||
|
||||
if (totalMax === 0) {
|
||||
totalMax = 1;
|
||||
}
|
||||
|
||||
var currentPage = parseInt(pageNumberInput.textContent, 10);
|
||||
if (currentPage > totalMax) {
|
||||
pageNumberInput.textContent = totalMax;
|
||||
requestUpdate();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Ошибка при отправке запроса:", error);
|
||||
});
|
||||
}
|
||||
|
||||
// function closeForm() {
|
||||
// var formContainer = $("#form-bg");
|
||||
// var fform = $("#form");
|
||||
// formContainer.removeClass("active");
|
||||
// fform.removeClass("form-animation");
|
||||
// $("body").css("overflow", "auto");
|
||||
// }
|
||||
|
||||
// document.addEventListener("DOMContentLoaded", function () {
|
||||
// const form = document.getElementById("add-form");
|
||||
|
||||
// form.addEventListener("submit", function (event) {
|
||||
// event.preventDefault();
|
||||
|
||||
// const deleteConfirmation = document.getElementById("addInformation");
|
||||
// const closeButton = document.getElementById("closeButton");
|
||||
// const mark = document.getElementById("success-mark");
|
||||
|
||||
// closeForm();
|
||||
|
||||
// closeButton.style.display = "none";
|
||||
// deleteConfirmation.style.display = "flex";
|
||||
// mark.style.display = "none";
|
||||
|
||||
// const formData = new FormData(form);
|
||||
|
||||
// form.reset();
|
||||
|
||||
// fetch(API_SERVER + "/user", {
|
||||
// method: "POST",
|
||||
// headers: {
|
||||
// Authorization: getCookie("token"),
|
||||
// },
|
||||
// body: formData,
|
||||
// })
|
||||
// .then((response) => response.json())
|
||||
// .then((data) => {
|
||||
// showMessage("Пользователь успешно добавлен", true);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// showMessage("Не удалось добавить пользователя", false);
|
||||
// console.error("Ошибка:", error);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// function addUser() {
|
||||
// var formContainer = $("#form-bg");
|
||||
// var form = $("#form");
|
||||
// formContainer.addClass("active");
|
||||
// form.addClass("form-animation");
|
||||
// $("body").css("overflow", "hidden");
|
||||
// }
|
||||
|
||||
// $(document).ready(function () {
|
||||
// // Закрывает popup форму
|
||||
// $("#close-form-btn").click(function () {
|
||||
// closeForm();
|
||||
// });
|
||||
|
||||
// // Функция для закрытия формы
|
||||
// function closeForm() {
|
||||
// var formContainer = $("#form-bg");
|
||||
// var form = $("#form");
|
||||
// formContainer.removeClass("active");
|
||||
// form.removeClass("form-animation");
|
||||
// $("body").css("overflow", "auto");
|
||||
// }
|
||||
// });
|
36
static/scripts/helpPopup.js
Normal file
36
static/scripts/helpPopup.js
Normal file
@ -0,0 +1,36 @@
|
||||
function toggleDropdown(dropdownId) {
|
||||
$(".dropdown-help")
|
||||
.not("#" + dropdownId)
|
||||
.removeClass("is-visible");
|
||||
setTimeout(function () {
|
||||
$(".dropdown-help")
|
||||
.not("#" + dropdownId)
|
||||
.css("display", "none");
|
||||
}, 200);
|
||||
|
||||
const dropdownHelp = $("#" + dropdownId);
|
||||
if (dropdownHelp.hasClass("is-visible")) {
|
||||
event.preventDefault();
|
||||
dropdownHelp.removeClass("is-visible");
|
||||
setTimeout(function () {
|
||||
dropdownHelp.css("display", "none");
|
||||
}, 200);
|
||||
} else {
|
||||
event.preventDefault();
|
||||
dropdownHelp.css("display", "inline-flex");
|
||||
dropdownHelp.addClass("is-visible");
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on("click", function (event) {
|
||||
if ($(event.target).closest(".help-button").length) {
|
||||
return;
|
||||
} else {
|
||||
if (!$(event.target).closest(".dropdown-help").length) {
|
||||
$(".dropdown-help").removeClass("is-visible");
|
||||
setTimeout(function () {
|
||||
$(".dropdown-help").css("display", "none");
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
});
|
10965
static/scripts/jquery.min.js
vendored
Normal file
10965
static/scripts/jquery.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
144
static/scripts/passes-table.js
Normal file
144
static/scripts/passes-table.js
Normal file
@ -0,0 +1,144 @@
|
||||
const createTable = () => {
|
||||
const table = document.getElementById("passesTable");
|
||||
const tbody = table.querySelector("tbody");
|
||||
|
||||
// Очищаем таблицу
|
||||
tbody.innerHTML = "";
|
||||
|
||||
passes.forEach((pass) => {
|
||||
const row = document.createElement("tr");
|
||||
row.setAttribute("onclick", `openPass(${pass.id});`);
|
||||
|
||||
// Добавляем ячейки с данными
|
||||
const id = document.createElement("td");
|
||||
id.textContent = pass.id;
|
||||
row.appendChild(id);
|
||||
const status = document.createElement("td");
|
||||
status.textContent = pass.status;
|
||||
row.appendChild(status);
|
||||
const date = document.createElement("td");
|
||||
const rawDate = new Date(pass.date);
|
||||
const formattedDate = `${rawDate.getDate().toString().padStart(2, "0")}/${(
|
||||
rawDate.getMonth() + 1
|
||||
)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawDate.getFullYear()}`;
|
||||
date.textContent = formattedDate;
|
||||
row.appendChild(date);
|
||||
const type = document.createElement("td");
|
||||
type.textContent = pass.type;
|
||||
row.appendChild(type);
|
||||
const worker = document.createElement("td");
|
||||
worker.textContent = pass.name;
|
||||
row.appendChild(worker);
|
||||
const legal = document.createElement("td");
|
||||
legal.innerHTML = pass.legal;
|
||||
row.appendChild(legal);
|
||||
const finaldate = document.createElement("td");
|
||||
if (pass.finaldate) {
|
||||
const rawFinalDate = new Date(pass.finaldate);
|
||||
const formattedfinalDate = `${rawFinalDate
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, "0")}/${(rawFinalDate.getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawFinalDate.getFullYear()}`;
|
||||
finaldate.textContent = formattedfinalDate;
|
||||
} else {
|
||||
finaldate.textContent = "";
|
||||
}
|
||||
row.appendChild(finaldate);
|
||||
const address = document.createElement("td");
|
||||
address.textContent = pass.address;
|
||||
row.appendChild(address);
|
||||
const car = document.createElement("td");
|
||||
if (pass.car) {
|
||||
let carText = pass.car.replace(/"/g, '"');
|
||||
carText = JSON.parse(carText).join(", ");
|
||||
car.textContent = carText;
|
||||
}
|
||||
row.appendChild(car);
|
||||
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
createTable();
|
||||
});
|
||||
|
||||
function getCookie(name) {
|
||||
var cookies = document.cookie.split(";");
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i].trim();
|
||||
if (cookie.startsWith(name + "=")) {
|
||||
return cookie.substring(name.length + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function requestUpdate() {
|
||||
document.getElementById("passesTable").style.filter = "brightness(0.85)";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("searchText", document.getElementById("table-search").value);
|
||||
formData.append(
|
||||
"page",
|
||||
parseInt(document.getElementById("page-number").textContent)
|
||||
);
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
body: formData,
|
||||
};
|
||||
|
||||
fetch(API_SERVER + "/passes/getpasses", requestOptions)
|
||||
.then((response) => {
|
||||
document.getElementById("passesTable").style.filter = "brightness(1)";
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error("Ошибка при отправке POST запроса.");
|
||||
return "Ошибка при отправке запроса.";
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
passes.splice(0, passes.length);
|
||||
|
||||
passes.push(
|
||||
...data.passes.map((item) => ({
|
||||
id: item.id,
|
||||
status: item.Состояние,
|
||||
date: item.Дата_выдачи,
|
||||
finaldate: item.Действие_до,
|
||||
type: item.Вид_пропуска,
|
||||
name: item.Работник,
|
||||
legal: item.Организация,
|
||||
address: item.Зона_доступа,
|
||||
car: item.Авто_гос_номер,
|
||||
tmcname: item.Наименование,
|
||||
}))
|
||||
);
|
||||
|
||||
createTable();
|
||||
|
||||
totalMax = Math.ceil(data.totalCount / 15);
|
||||
|
||||
if (totalMax === 0) {
|
||||
totalMax = 1;
|
||||
}
|
||||
|
||||
var currentPage = parseInt(pageNumberInput.textContent, 10);
|
||||
if (currentPage > totalMax) {
|
||||
pageNumberInput.textContent = totalMax;
|
||||
requestUpdate();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Ошибка при отправке запроса:", error);
|
||||
});
|
||||
}
|
134
static/scripts/tso-table.js
Normal file
134
static/scripts/tso-table.js
Normal file
@ -0,0 +1,134 @@
|
||||
const createTable = () => {
|
||||
const table = document.getElementById("passesTable");
|
||||
const tbody = table.querySelector("tbody");
|
||||
|
||||
// Очищаем таблицу
|
||||
tbody.innerHTML = "";
|
||||
|
||||
passes.forEach((pass) => {
|
||||
const row = document.createElement("tr");
|
||||
row.setAttribute("onclick", `openPass(${pass.id});`);
|
||||
|
||||
// Добавляем ячейки с данными
|
||||
const id = document.createElement("td");
|
||||
id.textContent = pass.id;
|
||||
row.appendChild(id);
|
||||
const status = document.createElement("td");
|
||||
status.textContent = pass.status;
|
||||
row.appendChild(status);
|
||||
const date = document.createElement("td");
|
||||
const rawDate = new Date(pass.date);
|
||||
const formattedDate = `${rawDate.getDate().toString().padStart(2, "0")}/${(
|
||||
rawDate.getMonth() + 1
|
||||
)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawDate.getFullYear()}`;
|
||||
date.textContent = formattedDate;
|
||||
row.appendChild(date);
|
||||
const type = document.createElement("td");
|
||||
type.textContent = pass.type;
|
||||
row.appendChild(type);
|
||||
const object = document.createElement("td");
|
||||
object.textContent = pass.object;
|
||||
row.appendChild(object);
|
||||
const editdate = document.createElement("td");
|
||||
if (pass.editdate) {
|
||||
const rawFinalDate = new Date(pass.editdate);
|
||||
const formattedfinalDate = `${rawFinalDate
|
||||
.getDate()
|
||||
.toString()
|
||||
.padStart(2, "0")}/${(rawFinalDate.getMonth() + 1)
|
||||
.toString()
|
||||
.padStart(2, "0")}/${rawFinalDate.getFullYear()}`;
|
||||
editdate.textContent = formattedfinalDate;
|
||||
} else {
|
||||
editdate.textContent = "";
|
||||
}
|
||||
row.appendChild(editdate);
|
||||
const executor = document.createElement("td");
|
||||
executor.textContent = pass.executor;
|
||||
row.appendChild(executor);
|
||||
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
createTable();
|
||||
});
|
||||
|
||||
function getCookie(name) {
|
||||
var cookies = document.cookie.split(";");
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i].trim();
|
||||
if (cookie.startsWith(name + "=")) {
|
||||
return cookie.substring(name.length + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function requestUpdate() {
|
||||
document.getElementById("passesTable").style.filter = "brightness(0.85)";
|
||||
|
||||
const formData = new FormData();
|
||||
// formData.append("searchText", document.getElementById("table-search").value);
|
||||
formData.append(
|
||||
"page",
|
||||
parseInt(document.getElementById("page-number").textContent)
|
||||
);
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
body: formData,
|
||||
};
|
||||
|
||||
fetch(API_SERVER + "/passes/gettso", requestOptions)
|
||||
.then((response) => {
|
||||
document.getElementById("passesTable").style.filter = "brightness(1)";
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error("Ошибка при отправке POST запроса.");
|
||||
return "Ошибка при отправке запроса.";
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
passes.splice(0, passes.length);
|
||||
|
||||
passes.push(
|
||||
...data.passes.map((item) => ({
|
||||
id: item.id,
|
||||
status: item.Состояние,
|
||||
object: item.Объект,
|
||||
fabula: item.Фабула,
|
||||
type: item.Вид_неисправности,
|
||||
date: item.Дата_подачи,
|
||||
editdate: item.Дата_изменения,
|
||||
who: item.Кто_подал,
|
||||
executor: item.Исполнитель,
|
||||
events: item.Мероприятия,
|
||||
}))
|
||||
);
|
||||
|
||||
createTable();
|
||||
|
||||
totalMax = Math.ceil(data.totalCount / 15);
|
||||
|
||||
if (totalMax === 0) {
|
||||
totalMax = 1;
|
||||
}
|
||||
|
||||
var currentPage = parseInt(pageNumberInput.textContent, 10);
|
||||
if (currentPage > totalMax) {
|
||||
pageNumberInput.textContent = totalMax;
|
||||
requestUpdate();
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Ошибка при отправке запроса:", error);
|
||||
});
|
||||
}
|
259
static/scripts/users-table.js
Normal file
259
static/scripts/users-table.js
Normal file
@ -0,0 +1,259 @@
|
||||
const createTable = () => {
|
||||
const table = document.getElementById("usersTable");
|
||||
const legalsTable = document.getElementById("legalsTable");
|
||||
const tbody = table.querySelector("tbody");
|
||||
const legalsTbody = legalsTable.querySelector("tbody");
|
||||
|
||||
// Очищаем таблицу
|
||||
tbody.innerHTML = "";
|
||||
legalsTbody.innerHTML = "";
|
||||
|
||||
users.forEach((user) => {
|
||||
const row = document.createElement("tr");
|
||||
if (user.isblocked === "true" || user.isblocked === true) {
|
||||
row.setAttribute("style", `background: rgba(255, 69, 58, 0.3)`);
|
||||
}
|
||||
row.setAttribute("onclick", `openUser(${user.id});`);
|
||||
|
||||
// Добавляем ячейки с данными
|
||||
const id = document.createElement("td");
|
||||
id.textContent = user.id;
|
||||
row.appendChild(id);
|
||||
const surname = document.createElement("td");
|
||||
surname.textContent = user.surname;
|
||||
row.appendChild(surname);
|
||||
const name = document.createElement("td");
|
||||
name.textContent = user.name;
|
||||
row.appendChild(name);
|
||||
const secondname = document.createElement("td");
|
||||
secondname.textContent = user.secondname;
|
||||
row.appendChild(secondname);
|
||||
const role = document.createElement("td");
|
||||
if (user.role) {
|
||||
role.textContent = user.role;
|
||||
} else {
|
||||
role.textContent = "Гость";
|
||||
}
|
||||
row.appendChild(role);
|
||||
const phone = document.createElement("td");
|
||||
phone.textContent = user.phone;
|
||||
row.appendChild(phone);
|
||||
const email = document.createElement("td");
|
||||
email.textContent = user.email;
|
||||
row.appendChild(email);
|
||||
const sub = document.createElement("td");
|
||||
sub.textContent = user.sub;
|
||||
row.appendChild(sub);
|
||||
const department = document.createElement("td");
|
||||
department.textContent = user.department;
|
||||
row.appendChild(department);
|
||||
|
||||
tbody.appendChild(row);
|
||||
});
|
||||
|
||||
legals.forEach((legal) => {
|
||||
const legalsRow = document.createElement("tr");
|
||||
legalsRow.setAttribute("onclick", `openLegal(${legal.id});`);
|
||||
|
||||
// Добавляем ячейки с данными
|
||||
const id = document.createElement("td");
|
||||
id.textContent = legal.id;
|
||||
legalsRow.appendChild(id);
|
||||
const name = document.createElement("td");
|
||||
name.innerHTML = legal.name;
|
||||
legalsRow.appendChild(name);
|
||||
const inn = document.createElement("td");
|
||||
inn.textContent = legal.inn;
|
||||
legalsRow.appendChild(inn);
|
||||
const ogrn = document.createElement("td");
|
||||
ogrn.textContent = legal.ogrn;
|
||||
legalsRow.appendChild(ogrn);
|
||||
const address = document.createElement("td");
|
||||
address.textContent = legal.address;
|
||||
legalsRow.appendChild(address);
|
||||
const realaddress = document.createElement("td");
|
||||
realaddress.textContent = legal.realaddress;
|
||||
legalsRow.appendChild(realaddress);
|
||||
const email = document.createElement("td");
|
||||
email.textContent = legal.email;
|
||||
legalsRow.appendChild(email);
|
||||
|
||||
legalsTbody.appendChild(legalsRow);
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
createTable();
|
||||
});
|
||||
|
||||
function getCookie(name) {
|
||||
var cookies = document.cookie.split(";");
|
||||
for (var i = 0; i < cookies.length; i++) {
|
||||
var cookie = cookies[i].trim();
|
||||
if (cookie.startsWith(name + "=")) {
|
||||
return cookie.substring(name.length + 1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function requestUpdate() {
|
||||
document.getElementById("usersTable").style.filter = "brightness(0.85)";
|
||||
document.getElementById("legalsTable").style.filter = "brightness(0.85)";
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("searchText", document.getElementById("table-search").value);
|
||||
formData.append(
|
||||
"page",
|
||||
parseInt(document.getElementById("page-number").textContent)
|
||||
);
|
||||
|
||||
const requestOptions = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: getCookie("token"),
|
||||
},
|
||||
body: formData,
|
||||
};
|
||||
|
||||
fetch(API_SERVER + "/users/getusers", requestOptions)
|
||||
.then((response) => {
|
||||
document.getElementById("usersTable").style.filter = "brightness(1)";
|
||||
document.getElementById("legalsTable").style.filter = "brightness(1)";
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
console.error("Ошибка при отправке POST запроса.");
|
||||
return "Ошибка при отправке запроса.";
|
||||
}
|
||||
})
|
||||
.then((data) => {
|
||||
users.splice(0, users.length);
|
||||
legals.splice(0, legals.length);
|
||||
|
||||
users.push(
|
||||
...data.people.map((item) => ({
|
||||
id: item.id,
|
||||
name: item.Имя,
|
||||
surname: item.Фамилия,
|
||||
secondname: item.Отчество,
|
||||
role: item.Должность,
|
||||
sub: item.Субподряд,
|
||||
department: item.Цех,
|
||||
email: item.Email,
|
||||
phone: item.Телефон,
|
||||
isblocked: item.Черный_список,
|
||||
}))
|
||||
);
|
||||
|
||||
legals.push(
|
||||
...data.legals.map((item) => ({
|
||||
id: item.id,
|
||||
name: item.Наименование,
|
||||
inn: item.ИНН,
|
||||
ogrn: item.ОГРН,
|
||||
address: item.Юридический_адрес,
|
||||
realaddress: item.Фактический_адрес,
|
||||
email: item.Email,
|
||||
}))
|
||||
);
|
||||
|
||||
createTable();
|
||||
|
||||
peopleMax = Math.ceil(data.totalCountPeople / 15);
|
||||
legalsMax = Math.ceil(data.totalCountLegal / 15);
|
||||
|
||||
if (peopleMax === 0) {
|
||||
peopleMax = 1;
|
||||
}
|
||||
if (legalsMax === 0) {
|
||||
legalsMax = 1;
|
||||
}
|
||||
|
||||
var currentPage = parseInt(pageNumberInput.textContent, 10);
|
||||
if (tableType === "People") {
|
||||
if (currentPage > peopleMax) {
|
||||
pageNumberInput.textContent = peopleMax;
|
||||
requestUpdate();
|
||||
}
|
||||
} else {
|
||||
if (currentPage > legalsMax) {
|
||||
pageNumberInput.textContent = legalsMax;
|
||||
requestUpdate();
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Ошибка при отправке запроса:", error);
|
||||
});
|
||||
}
|
||||
|
||||
// function closeForm() {
|
||||
// var formContainer = $("#form-bg");
|
||||
// var fform = $("#form");
|
||||
// formContainer.removeClass("active");
|
||||
// fform.removeClass("form-animation");
|
||||
// $("body").css("overflow", "auto");
|
||||
// }
|
||||
|
||||
// document.addEventListener("DOMContentLoaded", function () {
|
||||
// const form = document.getElementById("add-form");
|
||||
|
||||
// form.addEventListener("submit", function (event) {
|
||||
// event.preventDefault();
|
||||
|
||||
// const deleteConfirmation = document.getElementById("addInformation");
|
||||
// const closeButton = document.getElementById("closeButton");
|
||||
// const mark = document.getElementById("success-mark");
|
||||
|
||||
// closeForm();
|
||||
|
||||
// closeButton.style.display = "none";
|
||||
// deleteConfirmation.style.display = "flex";
|
||||
// mark.style.display = "none";
|
||||
|
||||
// const formData = new FormData(form);
|
||||
|
||||
// form.reset();
|
||||
|
||||
// fetch(API_SERVER + "/user", {
|
||||
// method: "POST",
|
||||
// headers: {
|
||||
// Authorization: getCookie("token"),
|
||||
// },
|
||||
// body: formData,
|
||||
// })
|
||||
// .then((response) => response.json())
|
||||
// .then((data) => {
|
||||
// showMessage("Пользователь успешно добавлен", true);
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// showMessage("Не удалось добавить пользователя", false);
|
||||
// console.error("Ошибка:", error);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
// function addUser() {
|
||||
// var formContainer = $("#form-bg");
|
||||
// var form = $("#form");
|
||||
// formContainer.addClass("active");
|
||||
// form.addClass("form-animation");
|
||||
// $("body").css("overflow", "hidden");
|
||||
// }
|
||||
|
||||
// $(document).ready(function () {
|
||||
// // Закрывает popup форму
|
||||
// $("#close-form-btn").click(function () {
|
||||
// closeForm();
|
||||
// });
|
||||
|
||||
// // Функция для закрытия формы
|
||||
// function closeForm() {
|
||||
// var formContainer = $("#form-bg");
|
||||
// var form = $("#form");
|
||||
// formContainer.removeClass("active");
|
||||
// form.removeClass("form-animation");
|
||||
// $("body").css("overflow", "auto");
|
||||
// }
|
||||
// });
|
Reference in New Issue
Block a user