-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
221 lines (189 loc) · 8.18 KB
/
script.js
File metadata and controls
221 lines (189 loc) · 8.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// JavaScript for Warehouse System Demo
document.addEventListener('DOMContentLoaded', function () {
// Tab functionality for CRUD section
const tabBtns = document.querySelectorAll('.tab-btn');
const tabContents = document.querySelectorAll('.tab-content');
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
// Remove active class from all buttons and contents
tabBtns.forEach(b => b.classList.remove('active'));
tabContents.forEach(c => c.classList.remove('active'));
// Add active class to clicked button
btn.classList.add('active');
// Show corresponding content
const tabId = btn.getAttribute('data-tab');
document.getElementById(`${tabId}-tab`).classList.add('active');
});
});
// Form submission handling
const productForm = document.getElementById('product-form');
if (productForm) {
productForm.addEventListener('submit', function (e) {
e.preventDefault();
// Get form values
const productName = document.getElementById('product-name').value;
const productCode = document.getElementById('product-code').value;
const productCategory = document.getElementById('product-category').value;
const productQuantity = document.getElementById('product-quantity').value;
// In a real application, you would send this data to a server
// For this demo, we'll just show an alert
alert(`Товар добавлен:
Наименование: ${productName}
Артикул: ${productCode}
Категория: ${productCategory}
Количество: ${productQuantity}`);
// Reset form
productForm.reset();
});
}
// Edit and delete button functionality
document.addEventListener('click', function (e) {
if (e.target.classList.contains('btn-edit')) {
alert('Функция редактирования будет реализована в полной версии системы');
}
if (e.target.classList.contains('btn-delete')) {
if (confirm('Вы уверены, что хотите удалить этот элемент?')) {
alert('Элемент удален');
// In a real app, you would remove the row from the table
}
}
});
// Global search functionality
const searchInput = document.getElementById('global-search');
if (searchInput) {
searchInput.addEventListener('keyup', function (e) {
if (e.key === 'Enter') {
const searchTerm = this.value.trim();
if (searchTerm) {
alert(`Поиск по запросу: "${searchTerm}"\nВ реальной системе здесь будут отображены результаты поиска.`);
}
}
});
}
// Smooth scrolling for navigation links
document.querySelectorAll('.main-nav a').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
window.scrollTo({
top: targetSection.offsetTop - 80,
behavior: 'smooth'
});
// Update active nav link
document.querySelectorAll('.main-nav a').forEach(link => {
link.classList.remove('active');
});
this.classList.add('active');
}
});
});
// Set active nav link based on scroll position
window.addEventListener('scroll', function () {
const sections = document.querySelectorAll('section');
const navLinks = document.querySelectorAll('.main-nav a');
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (pageYOffset >= (sectionTop - 200)) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href') === `#${current}`) {
link.classList.add('active');
}
});
});
// Simulate real-time updates for dashboard stats
function updateStats() {
const statNumbers = document.querySelectorAll('.stat-number');
statNumbers.forEach(stat => {
const currentValue = parseInt(stat.textContent.replace(/\s/g, ''));
const increment = Math.floor(Math.random() * 5);
const newValue = currentValue + increment;
stat.textContent = newValue.toLocaleString('ru-RU');
});
}
// Update stats every 10 seconds
setInterval(updateStats, 10000);
// Add animation to stat cards on load
const statCards = document.querySelectorAll('.stat-card');
statCards.forEach((card, index) => {
setTimeout(() => {
card.style.opacity = '0';
card.style.transform = 'translateY(20px)';
card.style.transition = 'opacity 0.5s ease, transform 0.5s ease';
setTimeout(() => {
card.style.opacity = '1';
card.style.transform = 'translateY(0)';
}, 100);
}, index * 200);
});
// Simulate order status updates
function updateOrderStatus() {
const orders = document.querySelectorAll('.order-card');
orders.forEach(order => {
const statusElement = order.querySelector('.order-status');
if (statusElement && statusElement.classList.contains('processing')) {
// Randomly change some processing orders to ready
if (Math.random() > 0.7) {
statusElement.classList.remove('processing');
statusElement.classList.add('ready');
statusElement.textContent = 'Готов к отправке';
}
}
});
}
// Update order statuses every 15 seconds
setInterval(updateOrderStatus, 15000);
// Add hover effect to process steps
const steps = document.querySelectorAll('.step');
steps.forEach(step => {
step.addEventListener('mouseenter', function () {
this.style.transform = 'scale(1.02)';
this.style.transition = 'transform 0.3s ease';
});
step.addEventListener('mouseleave', function () {
this.style.transform = 'scale(1)';
});
});
// Simulate document signing
function simulateDocumentSigning() {
const documents = document.querySelectorAll('.document-item');
documents.forEach(doc => {
const statusElement = doc.querySelector('.doc-status');
if (statusElement && statusElement.classList.contains('pending')) {
// Randomly sign some pending documents
if (Math.random() > 0.8) {
statusElement.classList.remove('pending');
statusElement.classList.add('signed');
statusElement.textContent = 'Подписана ЭЦП';
}
}
});
}
// Sign documents every 20 seconds
setInterval(simulateDocumentSigning, 20000);
// Add click effect to interactive elements
const interactiveElements = document.querySelectorAll('.stat-card, .order-card, .step-card, .zone');
interactiveElements.forEach(element => {
element.addEventListener('click', function () {
this.style.transform = 'scale(0.98)';
this.style.transition = 'transform 0.1s ease';
setTimeout(() => {
this.style.transform = 'scale(1)';
}, 100);
});
});
// Initialize with some active steps in the receiving process
const receivingSteps = document.querySelectorAll('#receiving .step');
for (let i = 0; i < 3; i++) {
if (receivingSteps[i]) {
receivingSteps[i].classList.add('active');
}
}
});