Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,24 +1,177 @@
|
||||
<template>
|
||||
<q-page class="q-pa-md">
|
||||
<div class="text-h6 text-weight-bold">Üretime Verilen Ürünler</div>
|
||||
<div class="text-caption text-grey-7 q-mt-xs">
|
||||
OrderHeaderID: {{ orderHeaderID || '-' }}
|
||||
<div class="row items-center justify-between">
|
||||
<div>
|
||||
<div class="text-h6 text-weight-bold">Uretime Verilen Urunleri Guncelle</div>
|
||||
<div class="text-caption text-grey-7 q-mt-xs">
|
||||
OrderHeaderID: {{ orderHeaderID || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<q-btn
|
||||
color="primary"
|
||||
icon="refresh"
|
||||
label="Yenile"
|
||||
:loading="store.loading"
|
||||
@click="refreshAll"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="filter-bar row q-col-gutter-md q-mt-md">
|
||||
<div class="col-5">
|
||||
<q-input
|
||||
:model-value="cariLabel"
|
||||
label="Cari Secimi"
|
||||
filled
|
||||
dense
|
||||
readonly
|
||||
/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<q-input
|
||||
:model-value="header?.OrderNumber || ''"
|
||||
label="Siparis No"
|
||||
filled
|
||||
dense
|
||||
readonly
|
||||
/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<q-input
|
||||
:model-value="formatDate(header?.OrderDate)"
|
||||
label="Olusturulma Tarihi"
|
||||
filled
|
||||
dense
|
||||
readonly
|
||||
/>
|
||||
</div>
|
||||
<div class="col-2">
|
||||
<q-input
|
||||
:model-value="formatDate(header?.AverageDueDate)"
|
||||
label="Tahmini Termin Tarihi"
|
||||
filled
|
||||
dense
|
||||
readonly
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<q-table
|
||||
<q-table
|
||||
class="q-mt-md"
|
||||
flat
|
||||
bordered
|
||||
dense
|
||||
separator="cell"
|
||||
row-key="OrderLineID"
|
||||
:rows="store.items"
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
:loading="store.loading"
|
||||
no-data-label="Üretime verilecek ürün bulunamadı"
|
||||
no-data-label="Uretime verilecek urun bulunamadi"
|
||||
:rows-per-page-options="[0]"
|
||||
hide-bottom
|
||||
/>
|
||||
>
|
||||
<template #body-cell-actions="props">
|
||||
<q-td :props="props" class="text-center">
|
||||
<q-btn
|
||||
color="primary"
|
||||
icon="save"
|
||||
flat
|
||||
round
|
||||
dense
|
||||
:loading="rowSavingId === props.row.OrderLineID"
|
||||
@click="onRowSubmit(props.row)"
|
||||
>
|
||||
<q-tooltip>Satiri Guncelle</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
<template #body-cell-NewItemCode="props">
|
||||
<q-td :props="props">
|
||||
<q-input
|
||||
v-model="props.row.NewItemCode"
|
||||
dense
|
||||
filled
|
||||
label="Yeni Urun"
|
||||
@update:model-value="val => onNewItemChange(props.row, val)"
|
||||
>
|
||||
<template #append>
|
||||
<q-icon name="arrow_drop_down" class="cursor-pointer" />
|
||||
</template>
|
||||
<q-menu
|
||||
anchor="bottom left"
|
||||
self="top left"
|
||||
fit
|
||||
>
|
||||
<div class="q-pa-sm" style="min-width:260px">
|
||||
<q-input
|
||||
v-model="productSearch"
|
||||
dense
|
||||
filled
|
||||
debounce="200"
|
||||
placeholder="Urun ara..."
|
||||
/>
|
||||
<q-list class="q-mt-xs" bordered separator>
|
||||
<q-item
|
||||
v-for="opt in filteredProducts"
|
||||
:key="opt.ProductCode"
|
||||
clickable
|
||||
@click="onSelectProduct(props.row, opt.ProductCode)"
|
||||
>
|
||||
<q-item-section>{{ opt.ProductCode }}</q-item-section>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</div>
|
||||
</q-menu>
|
||||
</q-input>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
<template #body-cell-NewColor="props">
|
||||
<q-td :props="props">
|
||||
<q-select
|
||||
v-model="props.row.NewColor"
|
||||
:options="getColorOptions(props.row)"
|
||||
option-label="colorLabel"
|
||||
option-value="color_code"
|
||||
emit-value
|
||||
map-options
|
||||
use-input
|
||||
dense
|
||||
filled
|
||||
label="Yeni Renk"
|
||||
@update:model-value="() => onNewColorChange(props.row)"
|
||||
/>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
<template #body-cell-NewDim2="props">
|
||||
<q-td :props="props">
|
||||
<q-select
|
||||
v-model="props.row.NewDim2"
|
||||
:options="getSecondColorOptions(props.row)"
|
||||
option-label="item_dim2_code"
|
||||
option-value="item_dim2_code"
|
||||
emit-value
|
||||
map-options
|
||||
use-input
|
||||
dense
|
||||
filled
|
||||
label="Yeni 2. Renk"
|
||||
/>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
<template #body-cell-NewDesc="props">
|
||||
<q-td :props="props">
|
||||
<q-input
|
||||
v-model="props.row.NewDesc"
|
||||
dense
|
||||
filled
|
||||
label="Yeni Aciklama"
|
||||
/>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
<q-banner v-if="store.error" class="bg-red text-white q-mt-sm">
|
||||
Hata: {{ store.error }}
|
||||
@@ -27,31 +180,193 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, watch } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useOrderProductionItemStore } from 'src/stores/OrderProductionItemStore'
|
||||
|
||||
const route = useRoute()
|
||||
const $q = useQuasar()
|
||||
const store = useOrderProductionItemStore()
|
||||
|
||||
const orderHeaderID = computed(() => String(route.params.orderHeaderID || '').trim())
|
||||
const header = computed(() => store.header || {})
|
||||
const cariLabel = computed(() => {
|
||||
const code = header.value?.CurrAccCode || ''
|
||||
const name = header.value?.CurrAccDescription || ''
|
||||
if (!code && !name) return ''
|
||||
if (!name) return code
|
||||
return `${code} - ${name}`
|
||||
})
|
||||
|
||||
const rows = ref([])
|
||||
const productOptions = ref([])
|
||||
const productSearch = ref('')
|
||||
const rowSavingId = ref('')
|
||||
|
||||
const columns = [
|
||||
{ name: 'OldItemCode', label: 'Eski Ürün Kodu', field: 'OldItemCode', align: 'left', sortable: true, style: 'min-width:140px;white-space:nowrap', headerStyle: 'min-width:140px;white-space:nowrap' },
|
||||
{ name: 'OldColor', label: 'Eski Ürün Rengi', field: 'OldColor', align: 'left', sortable: true, style: 'min-width:120px;white-space:nowrap', headerStyle: 'min-width:120px;white-space:nowrap' },
|
||||
{ name: 'OldItemCode', label: 'Eski Urun Kodu', field: 'OldItemCode', align: 'left', sortable: true, style: 'min-width:140px;white-space:nowrap', headerStyle: 'min-width:140px;white-space:nowrap' },
|
||||
{ name: 'OldColor', label: 'Eski Urun Rengi', field: 'OldColor', align: 'left', sortable: true, style: 'min-width:120px;white-space:nowrap', headerStyle: 'min-width:120px;white-space:nowrap' },
|
||||
{ name: 'OldDim2', label: 'Eski 2. Renk', field: 'OldDim2', align: 'left', sortable: true, style: 'min-width:110px;white-space:nowrap', headerStyle: 'min-width:110px;white-space:nowrap' },
|
||||
{ name: 'OldDesc', label: 'Eski Açıklama', field: 'OldDesc', align: 'left', sortable: false, style: 'min-width:180px;white-space:nowrap', headerStyle: 'min-width:180px;white-space:nowrap' },
|
||||
{ name: 'NewItemCode', label: 'Yeni Ürün Kodu', field: 'NewItemCode', align: 'left', sortable: true, style: 'min-width:140px;white-space:nowrap', headerStyle: 'min-width:140px;white-space:nowrap' },
|
||||
{ name: 'NewColor', label: 'Yeni Ürün Rengi', field: 'NewColor', align: 'left', sortable: true, style: 'min-width:120px;white-space:nowrap', headerStyle: 'min-width:120px;white-space:nowrap' },
|
||||
{ name: 'NewDim2', label: 'Yeni 2. Renk', field: 'NewDim2', align: 'left', sortable: true, style: 'min-width:110px;white-space:nowrap', headerStyle: 'min-width:110px;white-space:nowrap' },
|
||||
{ name: 'NewDesc', label: 'Yeni Açıklama', field: 'NewDesc', align: 'left', sortable: false, style: 'min-width:180px;white-space:nowrap', headerStyle: 'min-width:180px;white-space:nowrap' }
|
||||
{ name: 'OldDesc', label: 'Eski Aciklama', field: 'OldDesc', align: 'left', sortable: false, style: 'min-width:180px;white-space:nowrap', headerStyle: 'min-width:180px;white-space:nowrap' },
|
||||
{ name: 'NewItemCode', label: 'Yeni Urun Kodu', field: 'NewItemCode', align: 'left', sortable: false, style: 'min-width:190px;', headerStyle: 'min-width:190px;' },
|
||||
{ name: 'NewColor', label: 'Yeni Urun Rengi', field: 'NewColor', align: 'left', sortable: false, style: 'min-width:160px;', headerStyle: 'min-width:160px;' },
|
||||
{ name: 'NewDim2', label: 'Yeni 2. Renk', field: 'NewDim2', align: 'left', sortable: false, style: 'min-width:160px;', headerStyle: 'min-width:160px;' },
|
||||
{ name: 'NewDesc', label: 'Yeni Aciklama', field: 'NewDesc', align: 'left', sortable: false, style: 'min-width:220px;', headerStyle: 'min-width:220px;' },
|
||||
{ name: 'actions', label: '', field: 'actions', align: 'center', sortable: false, style: 'width:60px;', headerStyle: 'width:60px;' }
|
||||
]
|
||||
|
||||
onMounted(() => {
|
||||
store.fetchItems(orderHeaderID.value)
|
||||
onMounted(async () => {
|
||||
await refreshAll()
|
||||
})
|
||||
|
||||
watch(orderHeaderID, (id) => {
|
||||
store.fetchItems(id)
|
||||
watch(orderHeaderID, async (id) => {
|
||||
await refreshAll()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => store.items,
|
||||
(items) => {
|
||||
rows.value = (items || []).map(item => ({
|
||||
...item,
|
||||
NewItemCode: '',
|
||||
NewColor: '',
|
||||
NewDim2: '',
|
||||
NewDesc: ''
|
||||
}))
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
watch(
|
||||
() => store.products,
|
||||
(products) => {
|
||||
productOptions.value = products || []
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function formatDate (val) {
|
||||
if (!val) return ''
|
||||
const text = String(val)
|
||||
return text.length >= 10 ? text.slice(0, 10) : text
|
||||
}
|
||||
|
||||
const filteredProducts = computed(() => {
|
||||
const needle = String(productSearch.value || '').toLowerCase()
|
||||
if (!needle) return productOptions.value.slice(0, 50)
|
||||
return productOptions.value.filter(p =>
|
||||
String(p?.ProductCode || '').toLowerCase().includes(needle)
|
||||
).slice(0, 50)
|
||||
})
|
||||
|
||||
function onSelectProduct (row, code) {
|
||||
productSearch.value = ''
|
||||
onNewItemChange(row, code)
|
||||
}
|
||||
|
||||
function onNewItemChange (row, val) {
|
||||
const next = String(val || '').trim()
|
||||
if (next && !isValidModelCode(next)) {
|
||||
$q.notify({ type: 'negative', message: 'Model kodu formati gecersiz. Ornek: S000-DMY00001' })
|
||||
row.NewItemCode = ''
|
||||
row.NewColor = ''
|
||||
row.NewDim2 = ''
|
||||
return
|
||||
}
|
||||
row.NewItemCode = next ? next.toUpperCase() : ''
|
||||
row.NewColor = ''
|
||||
row.NewDim2 = ''
|
||||
if (row.NewItemCode) {
|
||||
store.fetchColors(row.NewItemCode)
|
||||
}
|
||||
}
|
||||
|
||||
function onNewColorChange (row) {
|
||||
row.NewDim2 = ''
|
||||
if (row.NewItemCode && row.NewColor) {
|
||||
store.fetchSecondColors(row.NewItemCode, row.NewColor)
|
||||
}
|
||||
}
|
||||
|
||||
function getColorOptions (row) {
|
||||
const code = row?.NewItemCode || ''
|
||||
const list = store.colorOptionsByCode[code] || []
|
||||
return list.map(c => ({
|
||||
...c,
|
||||
colorLabel: `${c.color_code} - ${c.color_description || ''}`.trim()
|
||||
}))
|
||||
}
|
||||
|
||||
function getSecondColorOptions (row) {
|
||||
const code = row?.NewItemCode || ''
|
||||
const color = row?.NewColor || ''
|
||||
const key = `${code}::${color}`
|
||||
return store.secondColorOptionsByKey[key] || []
|
||||
}
|
||||
|
||||
function isValidModelCode (value) {
|
||||
const text = String(value || '').trim().toUpperCase()
|
||||
return /^[A-Z][0-9]{3}-[A-Z]{3}[0-9]{5}$/.test(text)
|
||||
}
|
||||
|
||||
function buildPayloadLines () {
|
||||
return rows.value.map(r => ({
|
||||
OrderLineID: r.OrderLineID,
|
||||
NewItemCode: String(r.NewItemCode || '').trim(),
|
||||
NewColor: String(r.NewColor || '').trim(),
|
||||
NewDim2: String(r.NewDim2 || '').trim(),
|
||||
NewDesc: String(r.NewDesc || '').trim()
|
||||
}))
|
||||
}
|
||||
|
||||
async function refreshAll () {
|
||||
await store.fetchHeader(orderHeaderID.value)
|
||||
await store.fetchItems(orderHeaderID.value)
|
||||
await store.fetchProducts()
|
||||
}
|
||||
|
||||
async function onRowSubmit (row) {
|
||||
const line = {
|
||||
OrderLineID: row.OrderLineID,
|
||||
NewItemCode: String(row.NewItemCode || '').trim(),
|
||||
NewColor: String(row.NewColor || '').trim(),
|
||||
NewDim2: String(row.NewDim2 || '').trim(),
|
||||
NewDesc: String(row.NewDesc || '').trim()
|
||||
}
|
||||
|
||||
if (!line.NewItemCode || !line.NewColor) {
|
||||
$q.notify({ type: 'negative', message: 'Yeni urun ve renk zorunludur.' })
|
||||
return
|
||||
}
|
||||
|
||||
rowSavingId.value = row.OrderLineID
|
||||
try {
|
||||
const validate = await store.validateUpdates(orderHeaderID.value, [line])
|
||||
const missingCount = validate?.missingCount || 0
|
||||
if (missingCount > 0) {
|
||||
const missingList = (validate?.missing || []).map(v => (
|
||||
`${v.ItemCode} / ${v.ColorCode} / ${v.ItemDim1Code} / ${v.ItemDim2Code}`
|
||||
))
|
||||
$q.dialog({
|
||||
title: 'Eksik Varyantlar',
|
||||
message: `Eksik varyant bulundu: ${missingCount}<br><br>${missingList.join('<br>')}`,
|
||||
html: true,
|
||||
ok: { label: 'Ekle ve Guncelle', color: 'primary' },
|
||||
cancel: { label: 'Vazgec', flat: true }
|
||||
}).onOk(async () => {
|
||||
await store.applyUpdates(orderHeaderID.value, [line], true)
|
||||
await store.fetchItems(orderHeaderID.value)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
await store.applyUpdates(orderHeaderID.value, [line], false)
|
||||
await store.fetchItems(orderHeaderID.value)
|
||||
} catch (err) {
|
||||
$q.notify({ type: 'negative', message: 'Islem basarisiz.' })
|
||||
} finally {
|
||||
rowSavingId.value = ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -5,11 +5,35 @@ import api from 'src/services/api'
|
||||
export const useOrderProductionItemStore = defineStore('orderproductionitems', {
|
||||
state: () => ({
|
||||
items: [],
|
||||
header: null,
|
||||
products: [],
|
||||
colorOptionsByCode: {},
|
||||
secondColorOptionsByKey: {},
|
||||
loading: false,
|
||||
saving: false,
|
||||
error: null
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async fetchHeader (orderHeaderID) {
|
||||
if (!orderHeaderID) {
|
||||
this.header = null
|
||||
return
|
||||
}
|
||||
|
||||
this.loading = true
|
||||
this.error = null
|
||||
|
||||
try {
|
||||
const res = await api.get(`/order/get/${encodeURIComponent(orderHeaderID)}`)
|
||||
this.header = res?.data?.header || null
|
||||
} catch (err) {
|
||||
this.header = null
|
||||
this.error = err?.response?.data || err?.message || 'Siparis bilgisi alinamadi'
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
async fetchItems (orderHeaderID) {
|
||||
if (!orderHeaderID) {
|
||||
this.items = []
|
||||
@@ -25,10 +49,99 @@ export const useOrderProductionItemStore = defineStore('orderproductionitems', {
|
||||
this.items = Array.isArray(data) ? data : []
|
||||
} catch (err) {
|
||||
this.items = []
|
||||
this.error = err?.response?.data || err?.message || 'Liste alınamadı'
|
||||
this.error = err?.response?.data || err?.message || 'Liste alinamadi'
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
async fetchProducts () {
|
||||
this.error = null
|
||||
try {
|
||||
const res = await api.get('/products')
|
||||
const data = res?.data
|
||||
this.products = Array.isArray(data) ? data : []
|
||||
} catch (err) {
|
||||
this.products = []
|
||||
this.error = err?.response?.data || err?.message || 'Urun listesi alinamadi'
|
||||
}
|
||||
},
|
||||
async fetchColors (productCode) {
|
||||
const code = String(productCode || '').trim()
|
||||
if (!code) return []
|
||||
|
||||
if (this.colorOptionsByCode[code]) {
|
||||
return this.colorOptionsByCode[code]
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await api.get('/product-colors', { params: { code } })
|
||||
const data = res?.data
|
||||
const list = Array.isArray(data) ? data : []
|
||||
this.colorOptionsByCode[code] = list
|
||||
return list
|
||||
} catch (err) {
|
||||
this.error = err?.response?.data || err?.message || 'Renk listesi alinamadi'
|
||||
return []
|
||||
}
|
||||
},
|
||||
async fetchSecondColors (productCode, colorCode) {
|
||||
const code = String(productCode || '').trim()
|
||||
const color = String(colorCode || '').trim()
|
||||
if (!code || !color) return []
|
||||
|
||||
const key = `${code}::${color}`
|
||||
if (this.secondColorOptionsByKey[key]) {
|
||||
return this.secondColorOptionsByKey[key]
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await api.get('/product-secondcolor', { params: { code, color } })
|
||||
const data = res?.data
|
||||
const list = Array.isArray(data) ? data : []
|
||||
this.secondColorOptionsByKey[key] = list
|
||||
return list
|
||||
} catch (err) {
|
||||
this.error = err?.response?.data || err?.message || '2. renk listesi alinamadi'
|
||||
return []
|
||||
}
|
||||
},
|
||||
async validateUpdates (orderHeaderID, lines) {
|
||||
if (!orderHeaderID) return { missingCount: 0, missing: [] }
|
||||
|
||||
this.saving = true
|
||||
this.error = null
|
||||
|
||||
try {
|
||||
const res = await api.post(
|
||||
`/orders/production-items/${encodeURIComponent(orderHeaderID)}/validate`,
|
||||
{ lines }
|
||||
)
|
||||
return res?.data || { missingCount: 0, missing: [] }
|
||||
} catch (err) {
|
||||
this.error = err?.response?.data || err?.message || 'Kontrol basarisiz'
|
||||
throw err
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
async applyUpdates (orderHeaderID, lines, insertMissing) {
|
||||
if (!orderHeaderID) return { updated: 0, inserted: 0 }
|
||||
|
||||
this.saving = true
|
||||
this.error = null
|
||||
|
||||
try {
|
||||
const res = await api.post(
|
||||
`/orders/production-items/${encodeURIComponent(orderHeaderID)}/apply`,
|
||||
{ lines, insertMissing }
|
||||
)
|
||||
return res?.data || { updated: 0, inserted: 0 }
|
||||
} catch (err) {
|
||||
this.error = err?.response?.data || err?.message || 'Guncelleme basarisiz'
|
||||
throw err
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1701,14 +1701,15 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
: {}
|
||||
|
||||
/* ===== SAME COMBO → UPDATE ===== */
|
||||
if (sameCombo) {
|
||||
rows[idx] = {
|
||||
...prev,
|
||||
...newRow,
|
||||
id: prev.id,
|
||||
OrderLineID: prev.OrderLineID || null,
|
||||
lineIdMap: preservedLineIdMap
|
||||
}
|
||||
if (sameCombo) {
|
||||
rows[idx] = {
|
||||
...prev,
|
||||
...newRow,
|
||||
_dirty: true,
|
||||
id: prev.id,
|
||||
OrderLineID: prev.OrderLineID || null,
|
||||
lineIdMap: preservedLineIdMap
|
||||
}
|
||||
|
||||
this.summaryRows = rows
|
||||
this.orders = rows
|
||||
@@ -1761,12 +1762,13 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
comboLineIds: { ...(prev.comboLineIds || {}) }
|
||||
}
|
||||
|
||||
const insertedRow = {
|
||||
...newRow,
|
||||
id: crypto.randomUUID(),
|
||||
OrderLineID: null,
|
||||
lineIdMap: {}
|
||||
}
|
||||
const insertedRow = {
|
||||
...newRow,
|
||||
_dirty: true,
|
||||
id: crypto.randomUUID(),
|
||||
OrderLineID: null,
|
||||
lineIdMap: {}
|
||||
}
|
||||
|
||||
rows.splice(idx, 1, insertedRow)
|
||||
|
||||
@@ -1835,13 +1837,14 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
const price = Number(newRow?.fiyat ?? prev?.fiyat ?? 0)
|
||||
const totalTutar = Number((totalAdet * price).toFixed(2))
|
||||
|
||||
rows[dupIdx] = {
|
||||
...prev,
|
||||
...newRow,
|
||||
rows[dupIdx] = {
|
||||
...prev,
|
||||
...newRow,
|
||||
_dirty: true,
|
||||
|
||||
// kritik korumalar
|
||||
id: prev.id,
|
||||
OrderLineID: prev.OrderLineID || null,
|
||||
// kritik korumalar
|
||||
id: prev.id,
|
||||
OrderLineID: prev.OrderLineID || null,
|
||||
lineIdMap: { ...(prev.lineIdMap || {}) },
|
||||
|
||||
// MERGED bedenMap
|
||||
@@ -1869,12 +1872,13 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
}
|
||||
|
||||
// dup yoksa (veya dup delete satırıydı) → yeni satır
|
||||
rows.push({
|
||||
...newRow,
|
||||
id: newRow.id || crypto.randomUUID(),
|
||||
OrderLineID: null,
|
||||
lineIdMap: { ...(newRow.lineIdMap || {}) }
|
||||
})
|
||||
rows.push({
|
||||
...newRow,
|
||||
_dirty: true,
|
||||
id: newRow.id || crypto.randomUUID(),
|
||||
OrderLineID: null,
|
||||
lineIdMap: { ...(newRow.lineIdMap || {}) }
|
||||
})
|
||||
|
||||
this.summaryRows = rows
|
||||
this.orders = rows
|
||||
@@ -2633,7 +2637,12 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
// 🧪 PRE-VALIDATE — prItemVariant ön kontrol
|
||||
// - invalid varsa CREATE/UPDATE ÇALIŞMAZ
|
||||
// =======================================================
|
||||
const v = await api.post('/order/validate', { header, lines })
|
||||
const linesToValidate =
|
||||
isNew
|
||||
? lines
|
||||
: lines.filter(l => l._deleteSignal === true || l._dirty === true || !l.OrderLineID)
|
||||
|
||||
const v = await api.post('/order/validate', { header, lines: linesToValidate })
|
||||
const invalid = v?.data?.invalid || []
|
||||
|
||||
if (invalid.length > 0) {
|
||||
@@ -2969,10 +2978,12 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
// ComboKey stabil kalsın diye bedenKey kullan
|
||||
const comboKey = buildComboKey(row, bedenKey)
|
||||
|
||||
const makeLine = () => ({
|
||||
OrderLineID: orderLineId || '',
|
||||
ClientKey: makeLineClientKey(row, grpKey, bedenKey),
|
||||
ComboKey: comboKey,
|
||||
const makeLine = () => ({
|
||||
OrderLineID: orderLineId || '',
|
||||
ClientKey: makeLineClientKey(row, grpKey, bedenKey),
|
||||
ComboKey: comboKey,
|
||||
_dirty: row?._dirty === true,
|
||||
_deleteSignal: isDeleteSignal === true,
|
||||
|
||||
SortOrder: 0,
|
||||
ItemTypeCode: 1,
|
||||
@@ -3040,26 +3051,30 @@ export const useOrderEntryStore = defineStore('orderentry', {
|
||||
DOVCode: ''
|
||||
})
|
||||
|
||||
const existing = lineByCombo.get(comboKey)
|
||||
const existing = lineByCombo.get(comboKey)
|
||||
|
||||
if (!existing) {
|
||||
const ln = makeLine()
|
||||
lineByCombo.set(comboKey, ln)
|
||||
lines.push(ln)
|
||||
return
|
||||
}
|
||||
if (!existing) {
|
||||
const ln = makeLine()
|
||||
lineByCombo.set(comboKey, ln)
|
||||
lines.push(ln)
|
||||
return
|
||||
}
|
||||
|
||||
/* DELETE */
|
||||
if (isDeleteSignal) {
|
||||
if (orderLineId && !existing.OrderLineID) {
|
||||
existing.OrderLineID = orderLineId
|
||||
if (isDeleteSignal) {
|
||||
if (orderLineId && !existing.OrderLineID) {
|
||||
existing.OrderLineID = orderLineId
|
||||
}
|
||||
existing._deleteSignal = true
|
||||
existing.Qty1 = 0
|
||||
return
|
||||
}
|
||||
existing.Qty1 = 0
|
||||
return
|
||||
}
|
||||
|
||||
/* MERGE */
|
||||
existing.Qty1 += qty
|
||||
/* MERGE */
|
||||
existing.Qty1 += qty
|
||||
if (row?._dirty === true) {
|
||||
existing._dirty = true
|
||||
}
|
||||
|
||||
if (this.mode === 'edit' && orderLineId && !existing.OrderLineID) {
|
||||
existing.OrderLineID = orderLineId
|
||||
@@ -3346,66 +3361,56 @@ export function normalizeBeden(v) {
|
||||
- Keeps frontend aksbir bucket for accessory lines
|
||||
=========================================================== */
|
||||
export function detectBedenGroup(bedenList, urunAnaGrubu = '', urunKategori = '') {
|
||||
const list = Array.isArray(bedenList) ? bedenList : []
|
||||
const ana = normalizeTextForMatch(urunAnaGrubu)
|
||||
const alt = normalizeTextForMatch(urunKategori)
|
||||
const list = Array.isArray(bedenList) && bedenList.length > 0
|
||||
? bedenList.map(v => (v || '').toString().trim().toUpperCase())
|
||||
: [' ']
|
||||
|
||||
// Frontend compatibility: accessory-only products should stay in aksbir.
|
||||
const accessoryGroups = [
|
||||
'AKSESUAR', 'KRAVAT', 'PAPYON', 'KEMER', 'CORAP',
|
||||
'FULAR', 'MENDIL', 'KASKOL', 'ASKI', 'YAKA', 'KOL DUGMESI'
|
||||
const ana = (urunAnaGrubu || '')
|
||||
.toUpperCase()
|
||||
.trim()
|
||||
.replace(/\(.*?\)/g, '')
|
||||
.replace(/[^A-ZÇĞİÖŞÜ0-9\s]/g, '')
|
||||
.replace(/\s+/g, ' ')
|
||||
|
||||
const kat = (urunKategori || '').toUpperCase().trim()
|
||||
// 🔸 Aksesuar ise "aksbir"
|
||||
const aksesuarGruplari = [
|
||||
'AKSESUAR','KRAVAT','PAPYON','KEMER','CORAP','ÇORAP',
|
||||
'FULAR','MENDIL','MENDİL','KASKOL','ASKI',
|
||||
'YAKA','KOL DUGMESI','KOL DÜĞMESİ'
|
||||
]
|
||||
const clothingGroups = ['GOMLEK', 'CEKET', 'PANTOLON', 'MONT', 'YELEK', 'TAKIM', 'TSHIRT']
|
||||
const giyimGruplari = ['GÖMLEK','CEKET','PANTOLON','MONT','YELEK','TAKIM','TSHIRT','TİŞÖRT']
|
||||
// 🔸 Pantolon özel durumu
|
||||
if (
|
||||
accessoryGroups.some(g => ana.includes(g) || alt.includes(g)) &&
|
||||
!clothingGroups.some(g => ana.includes(g))
|
||||
) {
|
||||
return 'aksbir'
|
||||
aksesuarGruplari.some(g => ana.includes(g) || kat.includes(g)) &&
|
||||
!giyimGruplari.some(g => ana.includes(g))
|
||||
) return 'aksbir'
|
||||
|
||||
if (ana.includes('PANTOLON') && kat.includes('YETİŞKİN')) return 'pan'
|
||||
// 🔸 Tamamen numerik (örneğin 39-44 arası) → ayakkabı
|
||||
const allNumeric = list.every(v => /^\d+$/.test(v))
|
||||
if (allNumeric) {
|
||||
const nums = list.map(v => parseInt(v, 10)).filter(Boolean)
|
||||
const diffs = nums.slice(1).map((v, i) => v - nums[i])
|
||||
if (diffs.every(d => d === 1) && nums[0] >= 35 && nums[0] <= 46) return 'ayk'
|
||||
}
|
||||
|
||||
if (ana.includes('AYAKKABI') || alt.includes('AYAKKABI')) {
|
||||
return 'ayk'
|
||||
}
|
||||
// 🔸 Yaş grubu (çocuk/garson)
|
||||
if (kat.includes('GARSON') || kat.includes('ÇOCUK')) return 'yas'
|
||||
|
||||
let hasYasNumeric = false
|
||||
let hasAykNumeric = false
|
||||
let hasPanNumeric = false
|
||||
// 🔸 Harfli beden varsa doğrudan "gom" (gömlek, üst giyim)
|
||||
const harfliBedenler = ['XS','S','M','L','XL','XXL','3XL','4XL']
|
||||
if (list.some(b => harfliBedenler.includes(b))) return 'gom'
|
||||
|
||||
for (const raw of list) {
|
||||
const b = safeTrimUpperJs(raw)
|
||||
|
||||
switch (b) {
|
||||
case 'XS':
|
||||
case 'S':
|
||||
case 'M':
|
||||
case 'L':
|
||||
case 'XL':
|
||||
case '2XL':
|
||||
case '3XL':
|
||||
case '4XL':
|
||||
case '5XL':
|
||||
case '6XL':
|
||||
case '7XL':
|
||||
return 'gom'
|
||||
}
|
||||
|
||||
const n = parseNumericSizeJs(b)
|
||||
if (n == null) continue
|
||||
|
||||
if (n >= 2 && n <= 14) hasYasNumeric = true
|
||||
if (n >= 39 && n <= 45) hasAykNumeric = true
|
||||
if (n >= 38 && n <= 68) hasPanNumeric = true
|
||||
}
|
||||
|
||||
if (hasAykNumeric) return 'ayk'
|
||||
if (ana.includes('PANTOLON')) return 'pan'
|
||||
if (hasPanNumeric) return 'pan'
|
||||
if (alt.includes('COCUK') || alt.includes('GARSON')) return 'yas'
|
||||
if (hasYasNumeric) return 'yas'
|
||||
|
||||
// 🔸 Varsayılan: takım elbise
|
||||
return 'tak'
|
||||
}
|
||||
|
||||
|
||||
|
||||
export function toSummaryRowFromForm(form) {
|
||||
if (!form) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user