v7 - budget form saves data to localStorage
This commit is contained in:
parent
b8639bf03f
commit
df85618b03
@ -290,6 +290,34 @@ document.getElementById('budget-form').addEventListener('submit', async function
|
|||||||
submitBtn.textContent = 'Отправка...';
|
submitBtn.textContent = 'Отправка...';
|
||||||
submitBtn.disabled = true;
|
submitBtn.disabled = true;
|
||||||
|
|
||||||
|
// Save to localStorage for dashboard
|
||||||
|
const branch = document.getElementById('branch').value;
|
||||||
|
const month = document.getElementById('month').value;
|
||||||
|
const year = document.getElementById('year').value;
|
||||||
|
|
||||||
|
let budgetData = JSON.parse(localStorage.getItem('budget-data')) || [];
|
||||||
|
|
||||||
|
document.querySelectorAll('#articles-body tr').forEach(row => {
|
||||||
|
const articleName = row.querySelector('[name="article_name[]"]').value;
|
||||||
|
const articleCode = articleName.split(' - ')[0];
|
||||||
|
const plan = parseInt(row.querySelector('[name="article_plan[]"]').value) || 0;
|
||||||
|
const fact = parseInt(row.querySelector('[name="article_fact[]"]').value) || 0;
|
||||||
|
const cumulative = parseInt(row.querySelector('[name="article_cumulative[]"]').value) || 0;
|
||||||
|
|
||||||
|
budgetData.push({
|
||||||
|
branch: branch,
|
||||||
|
month: month,
|
||||||
|
year: year,
|
||||||
|
article: articleName,
|
||||||
|
articleCode: articleCode,
|
||||||
|
plan: plan,
|
||||||
|
fact: fact,
|
||||||
|
cumulative: cumulative
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
localStorage.setItem('budget-data', JSON.stringify(budgetData));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(form.action, {
|
const response = await fetch(form.action, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user