feat: refs #6123 enhance ZoneControl component with improved column definitions and dynamic event handling

This commit is contained in:
Pablo Natek 2025-05-09 09:20:54 +02:00
parent 74c1c6ae65
commit 52ac804c1d
1 changed files with 38 additions and 8 deletions

View File

@ -10,6 +10,8 @@ import VnLv from 'src/components/ui/VnLv.vue';
import VnCheckbox from 'src/components/common/VnCheckbox.vue'; import VnCheckbox from 'src/components/common/VnCheckbox.vue';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import axios from 'axios';
import { date } from 'quasar';
const { t } = useI18n(); const { t } = useI18n();
const state = useState(); const state = useState();
@ -43,6 +45,8 @@ const columns = computed(() => [
name: 'zoneFk', name: 'zoneFk',
label: t('zone.params.zoneFk'), label: t('zone.params.zoneFk'),
component: 'select', component: 'select',
columnClass: 'expand',
isEditable: false,
attrs: { attrs: {
url: 'Zones', url: 'Zones',
fields: ['id', 'name'], fields: ['id', 'name'],
@ -57,6 +61,7 @@ const columns = computed(() => [
name: 'etd', name: 'etd',
label: t('zone.params.etd'), label: t('zone.params.etd'),
component: 'time', component: 'time',
columnClass: 'shrink',
columnFilter: false, columnFilter: false,
isEditable: false, isEditable: false,
}, },
@ -64,6 +69,7 @@ const columns = computed(() => [
name: 'volume', name: 'volume',
label: t('zone.params.volume'), label: t('zone.params.volume'),
component: 'number', component: 'number',
columnClass: 'shrink',
format: ({ volume }) => Math.round(volume), format: ({ volume }) => Math.round(volume),
columnFilter: false, columnFilter: false,
isEditable: false, isEditable: false,
@ -78,12 +84,8 @@ const columns = computed(() => [
name: 'packingProgress', name: 'packingProgress',
label: t('packingProgress'), label: t('packingProgress'),
component: 'number', component: 'number',
format: ({ packingProgress }) => Math.round(packingProgress * 100) + '%', format: ({ packingProgress }) => expressAsPercent(packingProgress),
style: ({ packingProgress }) => { style: ({ packingProgress }) => progressStyle(packingProgress),
if (packingProgress == 0) return 'color: var(--vn-section-color)';
if (packingProgress < 1) return 'color: var(--q-negative)';
return 'color: var(--q-positive)';
},
columnFilter: false, columnFilter: false,
isEditable: false, isEditable: false,
}, },
@ -91,6 +93,22 @@ const columns = computed(() => [
name: 'isLate', name: 'isLate',
label: t('zone.params.isLate'), label: t('zone.params.isLate'),
component: 'checkbox', component: 'checkbox',
cellEvent: {
'update:modelValue': async (value, oldValue, row) => {
const zoneEvent = await axios.get('ZoneEvents', {
zoneFk: row.zoneFk,
type: 'day',
dated: row.landed,
});
console.log('zoneEvent: ', zoneEvent);
/* await axios.delete('ZoneEvents/1', {
zoneFk: row.zoneFk,
type: 'day',
dated: row.landed,
}); */
},
},
}, },
{ {
name: 'isFull', name: 'isFull',
@ -107,6 +125,15 @@ const productionConfig = ref();
function openDialog() { function openDialog() {
productionConfigDialogRef.value = true; productionConfigDialogRef.value = true;
} }
function expressAsPercent(value) {
return value ? Math.round(value * 100) + '%' : '-';
}
function progressStyle(value) {
if (value < 1 && value) return 'color: var(--q-negative)';
return 'color: var(--q-positive)';
}
</script> </script>
<template> <template>
<FetchData <FetchData
@ -139,7 +166,7 @@ function openDialog() {
</FormModelPopup> </FormModelPopup>
</QDialog> </QDialog>
<div class="table-container"> <div class="table-container">
<div class="column items-center" style="width: 60%"> <div class="column items-center" style="width: 80%">
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="ZoneControl" data-key="ZoneControl"
@ -188,7 +215,10 @@ function openDialog() {
<span v-text="Math.round(footer.volume)" /> <span v-text="Math.round(footer.volume)" />
</template> </template>
<template #column-footer-packingProgress> <template #column-footer-packingProgress>
<span v-text="Math.round(footer.packingProgress * 100) + '%'" /> <span
v-text="expressAsPercent(footer.packingProgress)"
:style="progressStyle(footer.packingProgress)"
/>
</template> </template>
</VnTable> </VnTable>
</div> </div>