Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-19 00:22:44 +03:00
parent 81d1af61be
commit 7512e7fe7c
9 changed files with 735 additions and 12 deletions

View File

@@ -413,6 +413,11 @@ const menuItems = [
label: 'Fiyatlandırma Mail Eşleştirme',
to: '/app/pricing-mail-mapping',
permission: 'system:update'
},
{
label: 'Fiyat Listesi Mail Eşleştirme',
to: '/app/order-price-list-mail-mapping',
permission: 'system:update'
}
]

View File

@@ -521,6 +521,7 @@ const serverFilterLastQuery = ref({})
const filterSearch = ref({ productCode: '', urunIlkGrubu: '', urunAnaGrubu: '' })
const imageCache = new Map()
const imageListCache = new Map()
const variantCodeCollator = new Intl.Collator('tr', { numeric: true, sensitivity: 'base' })
const mainTableRef = ref(null)
const topScrollRef = ref(null)
let syncingScroll = false
@@ -648,7 +649,7 @@ function buildRows (products, variants) {
out.push(row)
continue
}
list.sort((a, b) => toText(a?.variant_code).localeCompare(toText(b?.variant_code), 'tr'))
list.sort((a, b) => variantCodeCollator.compare(toText(a?.variant_code), toText(b?.variant_code)))
for (const v of list) {
const d1 = Number(v?.dim1 || 0)
const d3 = v?.dim3 == null ? 0 : Number(v?.dim3 || 0)
@@ -991,17 +992,17 @@ const allColumns = [
col('brandGroupSelection', 'MARKA GRUBU', 'brandGroupSelection', 86, { classes: 'ps-col sticky-col' }),
col('marka', 'MARKA', 'marka', 72, { sortable: true, classes: 'ps-col sticky-col' }),
col('productCode', 'URUN KODU', 'productCode', 112, { sortable: true, classes: 'ps-col product-code-col sticky-col' }),
col('variantCodes', 'VARYANT', 'variantCodes', 128, { classes: 'ps-col variant-col sticky-col' }),
col('variantStocks', 'STOK', 'stockQty', 72, { align: 'right', sortable: true, classes: 'ps-col variant-stock-col sticky-col' }),
col('campaignLabel', 'KAMPANYA', 'campaignLabel', 150, { classes: 'ps-col campaign-col sticky-col' }),
col('campaignRate', 'IND %', 'campaignRate', 64, { align: 'right', classes: 'ps-col campaign-rate-col sticky-col' }),
col('askiliYan', 'ASKILI YAN', 'askiliYan', 72, { sortable: true, classes: 'ps-col' }),
col('kategori', 'KATEGORI', 'kategori', 82, { sortable: true, classes: 'ps-col' }),
col('urunIlkGrubu', 'URUN ILK GRUBU', 'urunIlkGrubu', 88, { sortable: true, classes: 'ps-col' }),
col('urunAnaGrubu', 'URUN ANA GRUBU', 'urunAnaGrubu', 96, { sortable: true, classes: 'ps-col' }),
col('urunAltGrubu', 'URUN ALT GRUBU', 'urunAltGrubu', 96, { sortable: true, classes: 'ps-col' }),
col('icerik', 'ICERIK', 'icerik', 112, { sortable: true, classes: 'ps-col' }),
col('karisim', 'KARISIM', 'karisim', 96, { sortable: true, classes: 'ps-col' }),
col('variantCodes', 'VARYANT', 'variantCodes', 82, { align: 'center', classes: 'ps-col variant-col sticky-col center-col' }),
col('variantStocks', 'STOK', 'stockQty', 64, { align: 'center', sortable: true, classes: 'ps-col variant-stock-col sticky-col center-col' }),
col('campaignLabel', 'KAMPANYA', 'campaignLabel', 118, { align: 'center', classes: 'ps-col campaign-col sticky-col center-col' }),
col('campaignRate', 'IND %', 'campaignRate', 56, { align: 'center', classes: 'ps-col campaign-rate-col sticky-col center-col' }),
col('askiliYan', 'ASKILI YAN', 'askiliYan', 58, { sortable: true, classes: 'ps-col center-col' }),
col('kategori', 'KATEGORI', 'kategori', 72, { sortable: true, classes: 'ps-col center-col' }),
col('urunIlkGrubu', 'URUN ILK GRUBU', 'urunIlkGrubu', 72, { sortable: true, classes: 'ps-col center-col' }),
col('urunAnaGrubu', 'URUN ANA GRUBU', 'urunAnaGrubu', 84, { sortable: true, classes: 'ps-col center-col' }),
col('urunAltGrubu', 'URUN ALT GRUBU', 'urunAltGrubu', 84, { sortable: true, classes: 'ps-col center-col' }),
col('icerik', 'ICERIK', 'icerik', 92, { sortable: true, classes: 'ps-col' }),
col('karisim', 'KARISIM', 'karisim', 88, { sortable: true, classes: 'ps-col karisim-wrap-col' }),
...campaignPairs.flatMap((p) => [
col(p.base, p.base.toUpperCase().replace(/([A-Z]+)(\d)/, '$1 $2'), p.base, 78, { align: 'right', classes: `${p.base.slice(0, 3)}-col` }),
col(p.derived, `${p.base.toUpperCase().replace(/([A-Z]+)(\d)/, '$1 $2')} KMP`, p.derived, 88, { align: 'right', classes: `${p.base.slice(0, 3)}-col campaign-price-col` })
@@ -1131,6 +1132,7 @@ function exportVisibleExcel () {
a.click()
a.remove()
URL.revokeObjectURL(url)
void notifyExportTaken('excel')
}
function printVisibleRows () {
@@ -1154,6 +1156,24 @@ function printVisibleRows () {
win.document.open()
win.document.write(html)
win.document.close()
void notifyExportTaken('pdf')
}
async function notifyExportTaken (format) {
try {
await api.post('/order/price-list/export-notify', {
format,
row_count: filteredRows.value.length,
price_fields: [...selectedPriceOptions.value],
product_codes: [...selectedProductCodes.value],
campaign_labels: [...selectedCampaignLabels.value],
first_groups: Array.from(new Set(filteredRows.value.map((row) => toText(row.urunIlkGrubu)).filter(Boolean))).sort((a, b) => a.localeCompare(b, 'tr')),
urun_ilk_grubu: topUrunIlkGrubu.value || '',
urun_ana_grubu: topUrunAnaGrubu.value || ''
}, { timeout: 30000 })
} catch (err) {
console.warn('[order-price-list][ui] export notify failed', err?.response?.data || err?.message || err)
}
}
function getTableMiddleEl () {
@@ -1435,6 +1455,36 @@ onMounted(() => {
vertical-align: middle !important;
}
.pricing-table :deep(td.center-col) {
text-align: center !important;
}
.pricing-table :deep(td.center-col .q-badge) {
margin-left: auto;
margin-right: auto;
}
.pricing-table :deep(td.karisim-wrap-col) {
white-space: normal !important;
text-overflow: clip !important;
word-break: break-word;
overflow-wrap: anywhere;
vertical-align: top !important;
text-align: left !important;
font-size: 9px;
line-height: 1.15;
padding: 6px 4px !important;
align-content: flex-start;
}
.pricing-table :deep(td.karisim-wrap-col .q-td__content),
.pricing-table :deep(td.karisim-wrap-col > div) {
align-items: flex-start !important;
justify-content: flex-start !important;
white-space: normal !important;
overflow: hidden;
}
.order-price-list-table :deep(.campaign-price-col) {
background: #f6fbf7;
}

View File

@@ -0,0 +1,172 @@
<template>
<q-page v-if="canUpdateSystem" class="q-pa-md">
<div class="row justify-end q-mb-md">
<q-btn
color="primary"
icon="save"
label="Degisiklikleri Kaydet"
:loading="store.saving"
:disable="!hasChanges"
@click="saveChanges"
/>
</div>
<q-table
flat
bordered
dense
row-key="group_code"
:loading="store.loading"
:rows="store.rows"
:columns="columns"
:rows-per-page-options="[0]"
:pagination="{ rowsPerPage: 0 }"
>
<template #body-cell-mail_selector="props">
<q-td :props="props">
<q-select
:model-value="editableByGroup[props.row.group_code] || []"
:options="mailOptionsByGroup[props.row.group_code] || allMailOptions"
option-value="id"
option-label="label"
emit-value
map-options
multiple
use-chips
use-input
input-debounce="0"
clearable
dense
outlined
label="Mail ara ve sec"
@filter="(val, update) => filterMailOptions(props.row.group_code, val, update)"
@update:model-value="(val) => updateRowSelection(props.row.group_code, val)"
/>
</q-td>
</template>
</q-table>
</q-page>
<q-page v-else class="q-pa-md flex flex-center">
<div class="text-negative text-subtitle1">
Bu module erisim yetkiniz yok.
</div>
</q-page>
</template>
<script setup>
import { computed, onMounted, ref } from 'vue'
import { useQuasar } from 'quasar'
import { usePermission } from 'src/composables/usePermission'
import { useOrderPriceListMailMappingStore } from 'src/stores/orderPriceListMailMappingStore'
const $q = useQuasar()
const store = useOrderPriceListMailMappingStore()
const { canUpdate } = usePermission()
const canUpdateSystem = canUpdate('system')
const editableByGroup = ref({})
const originalByGroup = ref({})
const mailOptionsByGroup = ref({})
const columns = [
{ name: 'group_code', label: 'Urun Ilk Grup Kodu', field: 'group_code', align: 'left' },
{ name: 'group_title', label: 'Urun Ilk Grup Aciklama', field: 'group_title', align: 'left' },
{ name: 'mail_selector', label: 'Fiyat Listesi Mail Eslestirme', field: 'mail_selector', align: 'left' }
]
const allMailOptions = computed(() =>
(store.mails || []).map((m) => ({ id: m.id, label: m.display_name || m.email }))
)
const changedGroups = computed(() => {
return (store.rows || [])
.map((r) => String(r.group_code || r.urun_ilk_grubu || '').trim())
.filter(Boolean)
.filter((g) => {
const current = normalizeList(editableByGroup.value[g] || [])
const original = normalizeList(originalByGroup.value[g] || [])
return !isEqualList(current, original)
})
})
const hasChanges = computed(() => changedGroups.value.length > 0)
function normalizeList (list) {
return Array.from(
new Set(
(Array.isArray(list) ? list : [])
.map((x) => String(x).trim())
.filter(Boolean)
)
).sort()
}
function isEqualList (a, b) {
if (a.length !== b.length) return false
for (let i = 0; i < a.length; i += 1) {
if (a[i] !== b[i]) return false
}
return true
}
function initEditableState () {
const editable = {}
const original = {}
;(store.rows || []).forEach((row) => {
const g = String(row.group_code || row.urun_ilk_grubu || '').trim()
const selected = normalizeList(row.mail_ids || [])
editable[g] = [...selected]
original[g] = [...selected]
})
editableByGroup.value = editable
originalByGroup.value = original
mailOptionsByGroup.value = {}
}
function updateRowSelection (group, newValue) {
const g = String(group || '').trim()
editableByGroup.value = { ...editableByGroup.value, [g]: normalizeList(newValue) }
}
function filterMailOptions (group, search, update) {
const g = String(group || '').trim()
update(() => {
const q = String(search || '').trim().toLowerCase()
const filtered = !q
? allMailOptions.value
: allMailOptions.value.filter((opt) => String(opt.label || '').toLowerCase().includes(q))
mailOptionsByGroup.value = { ...mailOptionsByGroup.value, [g]: filtered }
})
}
async function init () {
try {
await Promise.all([store.fetchLookups(), store.fetchRows()])
initEditableState()
} catch (err) {
$q.notify({ type: 'negative', message: err?.message || 'Fiyat listesi mail eslestirmeleri yuklenemedi' })
}
}
async function saveChanges () {
if (!hasChanges.value) return
try {
for (const g of changedGroups.value) {
await store.saveGroupMails(g, editableByGroup.value[g] || [])
}
await store.fetchRows()
initEditableState()
$q.notify({ type: 'positive', message: 'Degisiklikler kaydedildi' })
} catch (err) {
$q.notify({ type: 'negative', message: err?.message || 'Kayit hatasi' })
}
}
onMounted(() => { init() })
</script>

View File

@@ -251,6 +251,12 @@ const routes = [
component: () => import('../pages/PricingMailMapping.vue'),
meta: { permission: 'system:update' }
},
{
path: 'order-price-list-mail-mapping',
name: 'order-price-list-mail-mapping',
component: () => import('../pages/OrderPriceListMailMapping.vue'),
meta: { permission: 'system:update' }
},
{
path: 'language/translations',
name: 'translation-table',

View File

@@ -0,0 +1,47 @@
import { defineStore } from 'pinia'
import api from 'src/services/api'
export const useOrderPriceListMailMappingStore = defineStore('orderPriceListMailMapping', {
state: () => ({
loading: false,
saving: false,
firstGroups: [],
mails: [],
rows: []
}),
actions: {
async fetchLookups () {
this.loading = true
try {
const res = await api.get('/system/order-price-list-mail-mappings/lookups')
const payload = res?.data || {}
this.firstGroups = Array.isArray(payload.first_groups) ? payload.first_groups : []
this.mails = Array.isArray(payload.mails) ? payload.mails : []
} finally {
this.loading = false
}
},
async fetchRows () {
this.loading = true
try {
const res = await api.get('/system/order-price-list-mail-mappings')
this.rows = Array.isArray(res?.data) ? res.data : []
} finally {
this.loading = false
}
},
async saveGroupMails (urunIlkGrubu, mailIds) {
this.saving = true
try {
await api.put(`/system/order-price-list-mail-mappings/${encodeURIComponent(String(urunIlkGrubu || '').trim())}`, {
mail_ids: Array.isArray(mailIds) ? mailIds : []
})
} finally {
this.saving = false
}
}
}
})