- ordinamento tabella titoli

- migliorata la lista degli argomenti
This commit is contained in:
Surya Paolo
2025-04-23 01:59:39 +02:00
parent ae4efab0f3
commit fc015404a6
11 changed files with 245 additions and 114 deletions

View File

@@ -72,6 +72,10 @@ export default defineComponent({
const modifOn = ref(false)
const sortAttribute = ref('')
const sortDirection = ref(1)
const optionscatalogo = ref(<any>{maxlength: 0})
const editOn = computed({
@@ -255,6 +259,37 @@ export default defineComponent({
}
const sortTable = (sortAttributeToSort: string) => {
if (!props.optcatalogo.showListaArgomenti)
return false
if (sortAttributeToSort) {
if (sortAttribute.value === sortAttributeToSort) {
sortDirection.value = -sortDirection.value
} else {
sortAttribute.value = sortAttributeToSort
sortDirection.value = 1
}
internalProducts.value = internalProducts.value.sort((a: any, b: any) => {
const aVal = a.productInfo?.[sortAttributeToSort] ?? ''
const bVal = b.productInfo?.[sortAttributeToSort] ?? ''
if (aVal instanceof Date && bVal instanceof Date) {
return sortDirection.value === 1 ? aVal.getTime() - bVal.getTime() : bVal.getTime() - aVal.getTime()
}
if (typeof aVal === 'number' && typeof bVal === 'number') {
return sortDirection.value === 1 ? aVal - bVal : bVal - aVal
}
if (typeof aVal === 'string' && typeof bVal === 'string') {
return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal)
}
return sortDirection.value === 1 ? String(aVal).localeCompare(String(bVal)) : String(bVal).localeCompare(String(aVal))
})
}
}
onMounted(mounted)
return {
@@ -287,6 +322,9 @@ export default defineComponent({
optionscatalogo,
t,
products,
sortTable,
sortAttribute,
sortDirection,
}
}
})