Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-04 17:43:21 +03:00
parent 6aea7f4012
commit fea4938a9d
4 changed files with 268 additions and 26 deletions

View File

@@ -874,10 +874,7 @@ async function onImportFileChange (event) {
return
}
const rowMap = new Map(rows.value.map(row => [buildImportRowKeyFromObject(row), row]))
let matched = 0
let updated = 0
let unmatched = 0
const importItems = []
for (let i = 1; i < matrix.length; i++) {
const csvRow = matrix[i]
@@ -886,14 +883,10 @@ async function onImportFileChange (event) {
identity[field] = csvRow[keyHeaderIndexes[label]] ?? ''
}
const target = rowMap.get(buildImportRowKeyFromObject(identity))
if (!target) {
unmatched += 1
continue
const item = {
...identity,
is_active: true
}
matched += 1
let changed = false
for (const [headerLabel, field] of Object.entries(importFieldMap)) {
const idx = headers.indexOf(headerLabel)
if (idx < 0) continue
@@ -901,32 +894,33 @@ async function onImportFileChange (event) {
if (field === 'is_active') {
const next = parseImportedBoolean(rawValue)
if (next === null || next === target.is_active) continue
target.is_active = next
changed = true
if (next !== null) item.is_active = next
continue
}
const next = parseImportedNumber(rawValue)
if (Number(target[field] || 0) === next) continue
target[field] = next
changed = true
}
if (changed) {
markDirty(target)
updated += 1
item[field] = parseImportedNumber(rawValue)
}
importItems.push(item)
}
if (updated === 0 && matched === 0) {
Notify.create({ type: 'warning', message: 'CSV satirlari ekrandaki kurallarla eslesmedi' })
if (importItems.length === 0) {
Notify.create({ type: 'warning', message: 'CSV icinde islenecek satir bulunamadi' })
return
}
const response = await api.request({
method: 'POST',
url: '/pricing/pricing-rules/import',
data: { items: importItems },
timeout: 180000
})
await loadRows()
const stats = response?.data || {}
Notify.create({
type: 'positive',
message: `CSV yüklendi. Eslesen: ${matched}, guncellenen: ${updated}, eslesmeyen: ${unmatched}`
message: `CSV yuklendi. Islenen: ${stats.processed ?? importItems.length}, kaydedilen: ${stats.updated ?? importItems.length}, yeni aktiflestirilen: ${stats.activated_scope_count ?? 0}, hata: ${stats.error_count ?? 0}`
})
} catch (err) {
Notify.create({ type: 'negative', message: err?.message || 'CSV okunamadi' })