Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-31 12:45:22 +03:00
parent 44439f7908
commit d7d871fb8a
19 changed files with 1608 additions and 158 deletions

View File

@@ -42,20 +42,21 @@ export function buildComboKey(row, beden) {
export const BEDEN_SCHEMA = [
{ key: 'tak', title: 'TAKIM ELBISE', values: ['44','46','48','50','52','54','56','58','60','62','64','66','68','70','72','74'] },
{ key: 'ayk', title: 'AYAKKABI', values: ['39','40','41','42','43','44','45'] },
{ key: 'ayk_garson', title: 'AYAKKABI GARSON', values: ['22','23','24','25','26','27','28','29','30','31','32','33','34','35','STD'] },
{ key: 'yas', title: 'YAS', values: ['2','4','6','8','10','12','14'] },
{ key: 'pan', title: 'PANTOLON', values: ['38','40','42','44','46','48','50','52','54','56','58','60','62','64','66','68'] },
{ key: 'gom', title: 'GOMLEK', values: ['XS','S','M','L','XL','2XL','3XL','4XL','5XL','6XL','7XL'] },
{ key: 'aksbir', title: 'AKSESUAR', values: [' ', '44', 'STD', '110', '115', '120', '125', '130', '135'] }
]
const SIZE_GROUP_TITLES = {
tak: 'TAKIM ELBISE',
ayk: 'AYAKKABI',
ayk_garson: 'AYAKKABI GARSON',
yas: 'YAS',
pan: 'PANTOLON',
gom: 'GOMLEK',
aksbir: 'AKSESUAR'
}
export const schemaByKey = BEDEN_SCHEMA.reduce((m, g) => {
m[g.key] = g
return m
}, {})
const FALLBACK_SCHEMA_MAP = {
tak: { key: 'tak', title: 'TAKIM ELBISE', values: ['44', '46', '48', '50', '52', '54', '56', '58', '60', '62', '64', '66', '68', '70', '72', '74'] }
}
export const schemaByKey = { ...FALLBACK_SCHEMA_MAP }
const productSizeMatchCache = {
loaded: false,
@@ -111,6 +112,23 @@ function setProductSizeMatchCache(payload) {
productSizeMatchCache.schemas = normalizedSchemas
}
function buildSchemaMapFromCacheSchemas() {
const out = {}
const src = productSizeMatchCache.schemas || {}
for (const [keyRaw, valuesRaw] of Object.entries(src)) {
const key = String(keyRaw || '').trim()
if (!key) continue
const values = Array.isArray(valuesRaw) ? valuesRaw : []
out[key] = {
key,
title: SIZE_GROUP_TITLES[key] || key.toUpperCase(),
values: values.map(v => String(v == null ? '' : v))
}
}
if (!out.tak) out.tak = { ...FALLBACK_SCHEMA_MAP.tak }
return out
}
export const stockMap = ref({})
export const bedenStock = ref([])
@@ -257,25 +275,17 @@ export const useOrderEntryStore = defineStore('orderentry', {
,
/* ===========================================================
🧩 initSchemaMap — BEDEN ŞEMA İNİT
- TEK SOURCE OF TRUTH: BEDEN_SCHEMA
- TEK SOURCE OF TRUTH: SQL mk_size_group (cache)
=========================================================== */
initSchemaMap() {
if (this.schemaMap && Object.keys(this.schemaMap).length > 0) {
return
}
const map = {}
for (const g of BEDEN_SCHEMA) {
map[g.key] = {
key: g.key,
title: g.title,
values: [...g.values]
}
this.schemaMap = buildSchemaMapFromCacheSchemas()
if (!Object.keys(this.schemaMap).length) {
this.schemaMap = { ...FALLBACK_SCHEMA_MAP }
}
this.schemaMap = map
console.log(
'🧩 schemaMap INIT edildi:',
Object.keys(this.schemaMap)
@@ -284,17 +294,20 @@ export const useOrderEntryStore = defineStore('orderentry', {
async ensureProductSizeMatchRules($q = null, force = false) {
if (!force && productSizeMatchCache.loaded && productSizeMatchCache.rules.length > 0) {
this.schemaMap = buildSchemaMapFromCacheSchemas()
return true
}
try {
const res = await api.get('/product-size-match/rules')
setProductSizeMatchCache(res?.data || {})
this.schemaMap = buildSchemaMapFromCacheSchemas()
return true
} catch (err) {
if (force) {
resetProductSizeMatchCache()
}
this.schemaMap = { ...FALLBACK_SCHEMA_MAP }
console.warn('⚠ product-size-match rules alınamadı:', err)
$q?.notify?.({
type: 'warning',
@@ -4044,6 +4057,8 @@ export function toSummaryRowFromForm(form) {
urunAnaGrubu: form.urunAnaGrubu || '',
urunAltGrubu: form.urunAltGrubu || '',
kategori: form.kategori || '',
yetiskinGarson: form.yetiskinGarson || form.askiliyan || '',
aciklama: form.aciklama || '',
fiyat: Number(form.fiyat || 0),