Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -307,6 +307,12 @@ const menuItems = [
|
||||
label: 'Test Mail',
|
||||
to: '/app/test-mail',
|
||||
permission: 'system:update'
|
||||
},
|
||||
|
||||
{
|
||||
label: 'Piyasa Mail Eşleştirme',
|
||||
to: '/app/market-mail-mapping',
|
||||
permission: 'system:update'
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
@@ -444,6 +444,15 @@ function formatAmount(value, fraction = 2) {
|
||||
|
||||
<style scoped>
|
||||
.statement-page {
|
||||
--lvl1-top: 0px;
|
||||
--lvl1-h: 30px;
|
||||
--lvl2-h: 30px;
|
||||
--lvl3-h: 30px;
|
||||
--lvl3-shift-up: 78px;
|
||||
--lvl2-top: calc(var(--lvl1-top) + var(--lvl1-h));
|
||||
--lvl3-top: calc(var(--lvl2-top) + var(--lvl2-h));
|
||||
--lvl4-top: calc(var(--lvl3-top) + var(--lvl3-h));
|
||||
|
||||
height: calc(100vh - 56px);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -505,8 +514,8 @@ function formatAmount(value, fraction = 2) {
|
||||
|
||||
.statement-table :deep(.header-row th) {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 30;
|
||||
top: var(--lvl1-top);
|
||||
z-index: 40;
|
||||
background: var(--q-primary);
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
@@ -532,11 +541,13 @@ function formatAmount(value, fraction = 2) {
|
||||
}
|
||||
|
||||
.currency-groups {
|
||||
position: relative;
|
||||
padding: 6px;
|
||||
background: #f8faff;
|
||||
}
|
||||
|
||||
.currency-group {
|
||||
position: relative;
|
||||
border-left: 4px solid var(--q-secondary);
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.08);
|
||||
border-right: 1px solid rgba(0, 0, 0, 0.08);
|
||||
@@ -547,8 +558,8 @@ function formatAmount(value, fraction = 2) {
|
||||
|
||||
.currency-level-head {
|
||||
position: sticky;
|
||||
top: 36px;
|
||||
z-index: 26;
|
||||
top: var(--lvl2-top);
|
||||
z-index: 34;
|
||||
display: grid;
|
||||
grid-template-columns: 48px 100px 80px 1.2fr 1.2fr 1.1fr 1.1fr 100px 110px 140px;
|
||||
align-items: center;
|
||||
@@ -562,8 +573,8 @@ function formatAmount(value, fraction = 2) {
|
||||
|
||||
.currency-group-header {
|
||||
position: sticky;
|
||||
top: 72px;
|
||||
z-index: 24;
|
||||
top: var(--lvl3-top);
|
||||
z-index: 32;
|
||||
display: grid;
|
||||
grid-template-columns: 48px 100px 80px 1.2fr 1.2fr 1.1fr 1.1fr 100px 110px 140px;
|
||||
align-items: center;
|
||||
@@ -619,14 +630,20 @@ function formatAmount(value, fraction = 2) {
|
||||
line-height: 1.2 !important;
|
||||
}
|
||||
|
||||
.detail-subtable :deep(.q-table__container),
|
||||
.detail-subtable :deep(.q-table__middle) {
|
||||
overflow: visible !important;
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.detail-subtable :deep(.q-table__top) {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.detail-subtable :deep(thead th) {
|
||||
position: sticky;
|
||||
top: 72px;
|
||||
z-index: 22;
|
||||
top: calc(var(--lvl3-top) - var(--lvl3-shift-up));
|
||||
z-index: 35;
|
||||
background: #1f3b5b;
|
||||
color: #fff;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.2);
|
||||
|
||||
216
ui/src/pages/MarketMailMapping.vue
Normal file
216
ui/src/pages/MarketMailMapping.vue
Normal file
@@ -0,0 +1,216 @@
|
||||
<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="market_id"
|
||||
: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="editableByMarket[props.row.market_id] || []"
|
||||
:options="mailOptionsByMarket[props.row.market_id] || 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.market_id, val, update)"
|
||||
@update:model-value="(val) => updateRowSelection(props.row.market_id, 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 { useMarketMailMappingStore } from 'src/stores/marketMailMappingStore'
|
||||
|
||||
const $q = useQuasar()
|
||||
const store = useMarketMailMappingStore()
|
||||
|
||||
const { canUpdate } = usePermission()
|
||||
const canUpdateSystem = canUpdate('system')
|
||||
|
||||
const editableByMarket = ref({})
|
||||
const originalByMarket = ref({})
|
||||
const mailOptionsByMarket = ref({})
|
||||
|
||||
const columns = [
|
||||
{
|
||||
name: 'market_code',
|
||||
label: 'Piyasa Kodu',
|
||||
field: 'market_code',
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
name: 'market_title',
|
||||
label: 'Piyasa',
|
||||
field: 'market_title',
|
||||
align: 'left'
|
||||
},
|
||||
{
|
||||
name: 'mail_selector',
|
||||
label: 'Mail Eslestirme',
|
||||
field: 'mail_selector',
|
||||
align: 'left'
|
||||
}
|
||||
]
|
||||
|
||||
const allMailOptions = computed(() =>
|
||||
(store.mails || []).map((m) => ({
|
||||
id: m.id,
|
||||
label: m.display_name || m.email
|
||||
}))
|
||||
)
|
||||
|
||||
const changedMarketIds = computed(() => {
|
||||
return (store.rows || [])
|
||||
.map((r) => Number(r.market_id))
|
||||
.filter((marketId) => {
|
||||
const current = normalizeList(editableByMarket.value[marketId] || [])
|
||||
const original = normalizeList(originalByMarket.value[marketId] || [])
|
||||
return !isEqualList(current, original)
|
||||
})
|
||||
})
|
||||
|
||||
const hasChanges = computed(() => changedMarketIds.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 marketId = Number(row.market_id)
|
||||
const selected = normalizeList(row.mail_ids || [])
|
||||
editable[marketId] = [...selected]
|
||||
original[marketId] = [...selected]
|
||||
})
|
||||
|
||||
editableByMarket.value = editable
|
||||
originalByMarket.value = original
|
||||
mailOptionsByMarket.value = {}
|
||||
}
|
||||
|
||||
function updateRowSelection (marketId, newValue) {
|
||||
editableByMarket.value = {
|
||||
...editableByMarket.value,
|
||||
[Number(marketId)]: normalizeList(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
function filterMailOptions (marketId, search, update) {
|
||||
update(() => {
|
||||
const q = String(search || '').trim().toLowerCase()
|
||||
if (!q) {
|
||||
mailOptionsByMarket.value = {
|
||||
...mailOptionsByMarket.value,
|
||||
[Number(marketId)]: allMailOptions.value
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const filtered = allMailOptions.value.filter((opt) =>
|
||||
String(opt.label || '').toLowerCase().includes(q)
|
||||
)
|
||||
|
||||
mailOptionsByMarket.value = {
|
||||
...mailOptionsByMarket.value,
|
||||
[Number(marketId)]: filtered
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function init () {
|
||||
try {
|
||||
await Promise.all([
|
||||
store.fetchLookups(),
|
||||
store.fetchRows()
|
||||
])
|
||||
initEditableState()
|
||||
} catch (err) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: err?.message || 'Piyasa-mail verileri yuklenemedi'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async function saveChanges () {
|
||||
if (!hasChanges.value) return
|
||||
|
||||
try {
|
||||
for (const marketId of changedMarketIds.value) {
|
||||
await store.saveMarketMails(marketId, editableByMarket.value[marketId] || [])
|
||||
}
|
||||
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>
|
||||
@@ -222,6 +222,13 @@ const routes = [
|
||||
meta: { permission: 'system:update' }
|
||||
},
|
||||
|
||||
{
|
||||
path: 'market-mail-mapping',
|
||||
name: 'market-mail-mapping',
|
||||
component: () => import('../pages/MarketMailMapping.vue'),
|
||||
meta: { permission: 'system:update' }
|
||||
},
|
||||
|
||||
|
||||
/* ================= ORDERS ================= */
|
||||
|
||||
|
||||
48
ui/src/stores/marketMailMappingStore.js
Normal file
48
ui/src/stores/marketMailMappingStore.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import api from 'src/services/api'
|
||||
|
||||
export const useMarketMailMappingStore = defineStore('marketMailMapping', {
|
||||
state: () => ({
|
||||
loading: false,
|
||||
saving: false,
|
||||
markets: [],
|
||||
mails: [],
|
||||
rows: []
|
||||
}),
|
||||
|
||||
actions: {
|
||||
async fetchLookups () {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await api.get('/system/market-mail-mappings/lookups')
|
||||
const payload = res?.data || {}
|
||||
this.markets = Array.isArray(payload.markets) ? payload.markets : []
|
||||
this.mails = Array.isArray(payload.mails) ? payload.mails : []
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async fetchRows () {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await api.get('/system/market-mail-mappings')
|
||||
this.rows = Array.isArray(res?.data) ? res.data : []
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
async saveMarketMails (marketId, mailIds) {
|
||||
this.saving = true
|
||||
try {
|
||||
await api.put(`/system/market-mail-mappings/${marketId}`, {
|
||||
mail_ids: Array.isArray(mailIds) ? mailIds : []
|
||||
})
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user