Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -795,7 +795,7 @@
|
||||
import { ref, reactive, computed, watch, onMounted, onUnmounted, nextTick, toRaw } from 'vue'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useRoute, useRouter, onBeforeRouteLeave} from 'vue-router'
|
||||
import { useOrderEntryStore,schemaByKey as storeSchemaByKey,detectBedenGroup} from 'src/stores/orderentryStore'
|
||||
import { useOrderEntryStore,schemaByKey as storeSchemaByKey,detectBedenGroup,normalizeBedenLabel} from 'src/stores/orderentryStore'
|
||||
import dayjs from 'dayjs'
|
||||
import api from 'src/services/api.js'
|
||||
import { useAuthStore } from 'src/stores/authStore'
|
||||
@@ -2668,61 +2668,51 @@ async function onModelChange(modelCode) {
|
||||
})
|
||||
|
||||
/* =======================================================
|
||||
🔑 BEDEN GRUBU — TEK VE KESİN KARAR (FIXED)
|
||||
- detectBedenGroup içine "[]" verip 'tak' düşmesini engeller
|
||||
- Önce urunAnaGrubu/kategori üzerinden hard-match
|
||||
- Sonra detectBedenGroup (ürün bilgisiyle)
|
||||
- En sonda güvenli fallback: 'tak'
|
||||
🔑 BEDEN GRUBU — TEK VE KESİN KARAR
|
||||
- ÖNCE detectBedenGroup (accent/garson/yas kurallarını içerir)
|
||||
- Sonra güvenli fallback
|
||||
======================================================= */
|
||||
const ana = String(form.urunAnaGrubu || '').toLowerCase().trim()
|
||||
const kat = String(form.kategori || form.urunAltGrubu || '').toLowerCase().trim()
|
||||
const yg = String(form.askiliyan || '').toLowerCase().trim()
|
||||
const hasGarsonMeta =
|
||||
ana.includes('garson') ||
|
||||
kat.includes('garson') ||
|
||||
kat.includes('yetiskin/garson') ||
|
||||
yg.includes('garson') ||
|
||||
yg.includes('yetiskin/garson')
|
||||
|
||||
let bedenGrpKey = null
|
||||
|
||||
// ✅ Hard-match (senin ana gruplarına göre genişletebilirsin)
|
||||
if (
|
||||
hasGarsonMeta &&
|
||||
(
|
||||
ana.includes('gomlek atayaka') ||
|
||||
ana.includes('gomlek ata yaka') ||
|
||||
ana.includes('gomlek klasik')
|
||||
try {
|
||||
bedenGrpKey = detectBedenGroup(
|
||||
null,
|
||||
form.urunAnaGrubu,
|
||||
form.kategori || form.urunAltGrubu,
|
||||
form.askiliyan
|
||||
)
|
||||
) {
|
||||
bedenGrpKey = 'yas'
|
||||
} else if (hasGarsonMeta &&
|
||||
(ana.includes('ayakkabı') || ana.includes('ayakkabi') || kat.includes('ayakkabı') || kat.includes('ayakkabi'))) {
|
||||
bedenGrpKey = 'ayk_garson'
|
||||
} else if (ana.includes('pantolon') || kat.includes('pantolon')) {
|
||||
bedenGrpKey = 'pan'
|
||||
} else if (ana.includes('gömlek') || ana.includes('gomlek') || kat.includes('gömlek') || kat.includes('gomlek')) {
|
||||
bedenGrpKey = 'gom'
|
||||
} else if (ana.includes('ayakkabı') || ana.includes('ayakkabi') || kat.includes('ayakkabı') || kat.includes('ayakkabi')) {
|
||||
bedenGrpKey = 'ayk'
|
||||
} else if (ana.includes('yaş') || ana.includes('yas') || kat.includes('yaş') || kat.includes('yas')) {
|
||||
bedenGrpKey = 'yas'
|
||||
} catch (e) {
|
||||
console.warn('⚠️ detectBedenGroup hata:', e)
|
||||
bedenGrpKey = null
|
||||
}
|
||||
|
||||
// ✅ Hard-match bulamadıysa mevcut helper ile belirle
|
||||
if (!bedenGrpKey) {
|
||||
try {
|
||||
// ⚠️ Boş array verme; ürün bilgisini kullanarak belirle
|
||||
bedenGrpKey = detectBedenGroup(
|
||||
null,
|
||||
form.urunAnaGrubu,
|
||||
form.kategori || form.urunAltGrubu,
|
||||
form.askiliyan
|
||||
)
|
||||
} catch (e) {
|
||||
console.warn('⚠️ detectBedenGroup hata:', e)
|
||||
bedenGrpKey = null
|
||||
}
|
||||
const anaN = String(form.urunAnaGrubu || '')
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
const katN = String(form.kategori || form.urunAltGrubu || '')
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
const ygN = String(form.askiliyan || '')
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
|
||||
const hasGarsonMeta =
|
||||
anaN.includes('garson') ||
|
||||
katN.includes('garson') ||
|
||||
katN.includes('yetiskin/garson') ||
|
||||
ygN.includes('garson') ||
|
||||
ygN.includes('yetiskin/garson')
|
||||
|
||||
if (hasGarsonMeta) bedenGrpKey = 'yas'
|
||||
else if (anaN.includes('pantolon') || katN.includes('pantolon')) bedenGrpKey = 'pan'
|
||||
else if (anaN.includes('gomlek') || katN.includes('gomlek')) bedenGrpKey = 'gom'
|
||||
else if (anaN.includes('ayakkabi') || katN.includes('ayakkabi')) bedenGrpKey = 'ayk'
|
||||
}
|
||||
|
||||
// ✅ Son fallback
|
||||
@@ -2977,7 +2967,7 @@ async function loadOrderInventory(merge = false) {
|
||||
// 1️⃣ Normalize (gelen büyük harfli)
|
||||
const invMap = {}
|
||||
for (const x of data) {
|
||||
const beden = String(x.Beden || '').trim() || ' '
|
||||
const beden = normalizeBedenLabel(String(x.Beden || '').trim())
|
||||
const stokDeger = Number(x.KullanilabilirAdet ?? 0)
|
||||
invMap[beden] = stokDeger
|
||||
}
|
||||
|
||||
@@ -808,7 +808,10 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
localStorage.removeItem(k)
|
||||
})
|
||||
|
||||
localStorage.removeItem(this.getDraftKey)
|
||||
localStorage.removeItem('bss_active_new_header')
|
||||
localStorage.removeItem('bss_last_txn')
|
||||
this.activeNewHeaderId = null
|
||||
}
|
||||
|
||||
|
||||
@@ -1579,6 +1582,8 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
clearNewDraft() {
|
||||
localStorage.removeItem(this.getDraftKey) // ✅
|
||||
localStorage.removeItem('bss_last_txn')
|
||||
localStorage.removeItem('bss_active_new_header')
|
||||
this.activeNewHeaderId = null
|
||||
console.log('🧹 NEW taslak temizlendi')
|
||||
}
|
||||
|
||||
@@ -2553,7 +2558,7 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
const key =
|
||||
x.item_dim1_code === null || x.item_dim1_code === ''
|
||||
? ' '
|
||||
: String(x.item_dim1_code)
|
||||
: normalizeBedenLabel(String(x.item_dim1_code))
|
||||
apiStockMap[key] = Number(x.kullanilabilir_envanter ?? 0)
|
||||
}
|
||||
|
||||
@@ -2710,6 +2715,7 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
async submitAllReal($q, router, form, summaryRows, productCache) {
|
||||
let serverOrderId = null
|
||||
let serverOrderNo = null
|
||||
let purgeNewDraftOnExit = false
|
||||
|
||||
try {
|
||||
this.loading = true
|
||||
@@ -2874,6 +2880,7 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
if (!serverOrderId) {
|
||||
throw new Error('OrderHeaderID backend’den dönmedi')
|
||||
}
|
||||
purgeNewDraftOnExit = isNew
|
||||
|
||||
/* =======================================================
|
||||
🔁 MODE SWITCH → EDIT
|
||||
@@ -3012,6 +3019,11 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
})
|
||||
|
||||
} finally {
|
||||
// ✅ NEW kaydı başarılıysa taslağı exit noktasında da zorla temizle
|
||||
if (purgeNewDraftOnExit) {
|
||||
this.clearNewDraft()
|
||||
}
|
||||
|
||||
// 🔓 Guard’lar normale dönsün
|
||||
this.isControlledSubmit = false
|
||||
this.loading = false
|
||||
@@ -3531,6 +3543,13 @@ export function normalizeBedenLabel(v) {
|
||||
|
||||
s = s.toUpperCase()
|
||||
|
||||
// Yas bedenleri backendte 2Y/4Y/6Y veya 2YAS/2YAŞ gibi gelebilir.
|
||||
// UI şeması 2/4/6/8/10/12/14 ile çalıştığı için numeric'e indir.
|
||||
const yasMatch = s.match(/^(\d+)\s*(Y|YAS|YAŞ)$/)
|
||||
if (yasMatch && yasMatch[1]) {
|
||||
return yasMatch[1]
|
||||
}
|
||||
|
||||
// Backend parity: normalize common "standard size" aliases.
|
||||
switch (s) {
|
||||
case 'STD':
|
||||
|
||||
Reference in New Issue
Block a user