Fix product performance grouped JSON build
This commit is contained in:
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user