Fix product performance grouped JSON build

This commit is contained in:
M_Kececi
2026-08-18 13:04:50 +03:00
parent 9edc806345
commit dbd84f7399
3 changed files with 114 additions and 7 deletions
@@ -141,7 +141,7 @@
</template>
<script setup>
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import { usePermission } from 'src/composables/usePermission'
import { get, extractApiErrorDetail } from 'src/services/api'
@@ -186,6 +186,30 @@ const columns = [
]
const columnFilters = reactive({})
const LIST_STATE_STORAGE_KEY = 'bssapp:production-product-costing:has-cost-list-state:v1'
function persistListState () {
try {
sessionStorage.setItem(LIST_STATE_STORAGE_KEY, JSON.stringify({
filters: { search: String(filters.search || '') },
columnFilters: JSON.parse(JSON.stringify(columnFilters)),
pagination: { ...tablePagination.value }
}))
} catch {}
}
function restoreListState () {
try {
const raw = sessionStorage.getItem(LIST_STATE_STORAGE_KEY)
if (!raw) return
const saved = JSON.parse(raw)
filters.search = String(saved?.filters?.search || '')
Object.assign(columnFilters, saved?.columnFilters && typeof saved.columnFilters === 'object' ? saved.columnFilters : {})
if (saved?.pagination && typeof saved.pagination === 'object') {
tablePagination.value = { ...tablePagination.value, ...saved.pagination }
}
} catch {}
}
function getColumnFilter (name) {
if (!columnFilters[name]) {
@@ -293,9 +317,11 @@ function clearAllColumnFilters () {
}
let searchTimer = null
let filterWatchEnabled = false
watch(
() => filters.search,
() => {
if (!filterWatchEnabled) return
clearTimeout(searchTimer)
searchTimer = setTimeout(() => {
fetchRows()
@@ -352,15 +378,20 @@ function openRow (row) {
const urunKodu = String(row?.UrunKodu || '').trim()
if (!urunKodu) return
persistListState()
router.push({
name: 'production-product-costing-has-cost-history',
query: { urun_kodu: urunKodu }
})
}
onMounted(() => {
onMounted(async () => {
if (!canReadOrder.value) return
fetchRows()
restoreListState()
await nextTick()
filterWatchEnabled = true
await fetchRows()
})
</script>
@@ -5060,13 +5060,31 @@ async function saveChanges () {
// If we created a new OnML (no-cost), switch to has-cost detail mode.
if (isNoCostDetail.value && newOnMLNo > 0) {
router.replace({
await router.replace({
name: 'production-product-costing-has-cost-detail',
query: {
n_onml_no: String(newOnMLNo),
urun_kodu: String(header?.UrunKodu || productCode.value || '').trim()
}
})
$q.dialog({
title: 'Maliyet Kaydedildi',
message: 'Maliyeti olmayan urunler listesine donup kaldiginiz yerden devam etmek ister misiniz?',
ok: {
label: 'Listeye Don',
color: 'primary',
icon: 'arrow_back'
},
cancel: {
label: 'Bu Sayfada Devam Et',
color: 'grey-7',
flat: true
},
persistent: true
}).onOk(() => {
router.push({ name: 'production-product-costing-no-cost' })
})
return
}
@@ -5076,6 +5094,24 @@ async function saveChanges () {
window.setTimeout(() => {
try { refreshLast10Warnings() } catch {}
}, 1200)
$q.dialog({
title: 'Maliyet Guncellendi',
message: 'Mevcut maliyeti olan urunler listesine donup kaldiginiz yerden devam etmek ister misiniz?',
ok: {
label: 'Listeye Don',
color: 'primary',
icon: 'arrow_back'
},
cancel: {
label: 'Bu Sayfada Devam Et',
color: 'grey-7',
flat: true
},
persistent: true
}).onOk(() => {
router.push({ name: 'production-product-costing-has-cost' })
})
} catch (e) {
// Surface backend message (http.Error text) when available.
const msg = String(
@@ -176,7 +176,7 @@
</template>
<script setup>
import { computed, onMounted, reactive, ref, watch } from 'vue'
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
import { useQuasar } from 'quasar'
import { useRouter } from 'vue-router'
import { usePermission } from 'src/composables/usePermission'
@@ -262,6 +262,34 @@ const columns = [
]
const columnFilters = reactive({})
const LIST_STATE_STORAGE_KEY = 'bssapp:production-product-costing:no-cost-list-state:v1'
function persistListState () {
try {
sessionStorage.setItem(LIST_STATE_STORAGE_KEY, JSON.stringify({
filters: {
search: String(filters.search || ''),
fromDate: String(filters.fromDate || '')
},
columnFilters: JSON.parse(JSON.stringify(columnFilters)),
scrollY: Number(window.scrollY || 0)
}))
} catch {}
}
function restoreListState () {
try {
const raw = sessionStorage.getItem(LIST_STATE_STORAGE_KEY)
if (!raw) return 0
const saved = JSON.parse(raw)
filters.search = String(saved?.filters?.search || '')
filters.fromDate = String(saved?.filters?.fromDate || '2025-06-01')
Object.assign(columnFilters, saved?.columnFilters && typeof saved.columnFilters === 'object' ? saved.columnFilters : {})
return Number(saved?.scrollY || 0)
} catch {
return 0
}
}
function getColumnFilter (name) {
if (!columnFilters[name]) {
@@ -384,9 +412,11 @@ function clearAllColumnFilters () {
}
let searchTimer = null
let filterWatchEnabled = false
watch(
() => filters.search,
() => {
if (!filterWatchEnabled) return
clearTimeout(searchTimer)
searchTimer = setTimeout(() => {
fetchRows()
@@ -397,6 +427,7 @@ watch(
watch(
() => filters.fromDate,
() => {
if (!filterWatchEnabled) return
fetchRows()
}
)
@@ -449,6 +480,8 @@ function openRow (row) {
recipe_code: recipeCode
})
persistListState()
router.push({
name: 'production-product-costing-has-cost-detail',
query: {
@@ -460,9 +493,16 @@ function openRow (row) {
})
}
onMounted(() => {
onMounted(async () => {
if (!canReadOrder.value) return
fetchRows()
const savedScrollY = restoreListState()
await nextTick()
filterWatchEnabled = true
await fetchRows()
if (savedScrollY > 0) {
await nextTick()
window.scrollTo({ top: savedScrollY, behavior: 'auto' })
}
})
</script>