feat: refs #6321 updates

This commit is contained in:
Javier Segarra 2025-01-20 14:37:13 +01:00
parent 24eaaacb19
commit 38d1beff5b
6 changed files with 76 additions and 51 deletions

View File

@ -21,7 +21,6 @@ const colorSpacer = '#ecf0f1';
const compatibilityItem = (value) => `${100 * (value / MATCH_VALUES.length)}%`; const compatibilityItem = (value) => `${100 * (value / MATCH_VALUES.length)}%`;
const gradientStyle = (value) => { const gradientStyle = (value) => {
let color = 'white'; let color = 'white';
console.error(value, extractNumericValue(compatibilityItem(value)));
const perc = extractNumericValue(compatibilityItem(value)); const perc = extractNumericValue(compatibilityItem(value));
switch (true) { switch (true) {
case perc >= 0 && perc < 33: case perc >= 0 && perc < 33:
@ -150,25 +149,25 @@ const columns = computed(() => [
name: 'located', name: 'located',
field: 'located', field: 'located',
}, },
{ // {
name: 'tableActions', // name: 'tableActions',
align: 'left', // align: 'left',
actions: [ // actions: [
{ // {
title: t('Open details'), // title: t('Open details'),
icon: 'change_circle', // icon: 'change_circle',
show: (row) => isSelectionAvailable(row), // show: (row) => isSelectionAvailable(row),
action: (row) => { // action: (row) => {
proposalSelected.value = [row]; // proposalSelected.value = [row];
confirm(); // confirm();
}, // },
isPrimary: true, // isPrimary: true,
}, // },
], // ],
}, // },
]); ]);
async function confirm() { async function confirm(row) {
try { try {
// const params = { // const params = {
// saleFk: saleFk.value, // saleFk: saleFk.value,
@ -176,7 +175,11 @@ async function confirm() {
// quantity: quantity.value, // quantity: quantity.value,
// }; // };
// const { data } = await axios.post('Sales/replaceItem', params); // const { data } = await axios.post('Sales/replaceItem', params);
const params = [saleFk.value, proposalSelected.value[0].id, quantity.value]; const params = [
saleFk.value,
row ?? proposalSelected.value[0].id,
quantity.value,
];
// const { data } = await axios.post('Applications/sale_replaceItem/execute-proc', { // const { data } = await axios.post('Applications/sale_replaceItem/execute-proc', {
// schema: 'vn', // schema: 'vn',
// params, // params,
@ -278,6 +281,16 @@ const isSelectionAvailable = (itemProposal) => {
{{ row.id }} {{ row.id }}
</QTooltip> </QTooltip>
<!-- <QBtn flat color="blue" dense>{{ }}</QBtn> --> <!-- <QBtn flat color="blue" dense>{{ }}</QBtn> -->
<QBtn
icon="change_circle"
color="primary"
flat
dense
@click="confirm(row)"
:disable="!isSelectionAvailable(row)"
>
<QTooltip> {{ t('Open_details') }}</QTooltip>
</QBtn>
<div <div
id="middle" id="middle"
style=" style="

View File

@ -139,34 +139,38 @@ function onTicketLackFetched(data) {
<VnSubToolbar> <VnSubToolbar>
<template #st-data> <template #st-data>
<QBtnGroup push style="column-gap: 1px"> <QBtnGroup push style="column-gap: 1px">
{{ selectedRows.length }}
<TicketMassiveUpdate <TicketMassiveUpdate
:disable="selectedRows.length < 2" :disable="selectedRows.length < 1"
:label="t('negative.buttonsUpdate.item')" :label="t('negative.buttonsUpdate.item')"
:tooltip="t('negative.detail.modal.changeItem.title')" :tooltip="t('negative.detail.modal.changeItem.title')"
> >
<ChangeItemDialog <ChangeItemDialog
ref="changeItemDialogRef" ref="changeItemDialogRef"
@update-item="changeItemDialogRef.hide()"
:selected-rows="selectedRows" :selected-rows="selectedRows"
></ChangeItemDialog> ></ChangeItemDialog>
</TicketMassiveUpdate> </TicketMassiveUpdate>
<TicketMassiveUpdate <TicketMassiveUpdate
:disable="selectedRows.length < 2" :disable="selectedRows.length < 1"
:label="t('negative.buttonsUpdate.state')" :label="t('negative.buttonsUpdate.state')"
:tooltip="t('negative.detail.modal.changeState.title')" :tooltip="t('negative.detail.modal.changeState.title')"
> >
<ChangeStateDialog <ChangeStateDialog
ref="changeStateDialogRef" ref="changeStateDialogRef"
@update-state="changeStateDialogRef.hide()"
:selected-rows="selectedRows" :selected-rows="selectedRows"
></ChangeStateDialog> ></ChangeStateDialog>
</TicketMassiveUpdate> </TicketMassiveUpdate>
<TicketMassiveUpdate <TicketMassiveUpdate
:disable="selectedRows.length < 1"
:label="t('negative.buttonsUpdate.quantity')" :label="t('negative.buttonsUpdate.quantity')"
:tooltip="t('negative.detail.modal.changeQuantity.title')" :tooltip="t('negative.detail.modal.changeQuantity.title')"
@click="showChangeQuantityDialog = true" @click="showChangeQuantityDialog = true"
:disable="selectedRows.length < 2"
> >
<ChangeQuantityDialog <ChangeQuantityDialog
ref="changeQuantityDialogRef" ref="changeQuantityDialogRef"
@update-quantity="changeQuantityDialogRef.hide()"
:selected-rows="selectedRows" :selected-rows="selectedRows"
> >
</ChangeQuantityDialog> </ChangeQuantityDialog>

View File

@ -137,17 +137,17 @@ const columns = computed(() => [
sortable: true, sortable: true,
// columnFilter: { // columnFilter: {
columnField: { // columnField: {
component: 'select', // component: 'select',
attrs: { // event: getInputEvents,
event: console.error, // attrs: {
// event: console.error, // event: (v) => console.error(v),
options: editableStates.value, // options: editableStates.value,
'option-value': 'id', // 'option-value': 'id',
'option-label': 'name', // 'option-label': 'name',
// }, // // },
}, // },
}, // },
}, },
{ {
name: 'zoneName', name: 'zoneName',
@ -240,6 +240,16 @@ function onTicketLackFetched(data) {
:right-search="false" :right-search="false"
v-model:selected="selectedRows" v-model:selected="selectedRows"
> >
<template #column-alertLevelCode="props">
<VnSelect
:options="editableStates"
hide-selected
option-value="id"
option-label="name"
v-model="props.row.alertLevelCode"
v-on="getInputEvents(props)"
/>
</template>
<template #column-quantity="props"> <template #column-quantity="props">
<VnInputNumber <VnInputNumber
v-model.number="props.row.quantity" v-model.number="props.row.quantity"

View File

@ -2,15 +2,14 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import { useDialogPluginComponent } from 'quasar';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
const emit = defineEmits(['update-item']);
const editableItems = ref([]); const editableItems = ref([]);
const { t } = useI18n(); const { t } = useI18n();
const showChangeItemDialog = ref(false); const showChangeItemDialog = ref(false);
const newItem = ref(null); const newItem = ref(null);
const { dialogRef } = useDialogPluginComponent();
const $props = defineProps({ const $props = defineProps({
selectedRows: { selectedRows: {
type: Array, type: Array,
@ -27,10 +26,9 @@ const updateItem = async () => {
}) })
); );
await Promise.all(rowsToUpdate); await Promise.all(rowsToUpdate);
emit('update-item');
} catch (err) { } catch (err) {
return err; return err;
} finally {
dialogRef.value.hide({ type: 'refresh', refresh: true });
} }
}; };
</script> </script>
@ -45,12 +43,16 @@ const updateItem = async () => {
<QCardSection class="row items-center justify-center column items-stretch"> <QCardSection class="row items-center justify-center column items-stretch">
<span>{{ t('negative.detail.modal.changeItem.title') }}</span> <span>{{ t('negative.detail.modal.changeItem.title') }}</span>
<VnSelect <VnSelect
:label="t('negative.detail.modal.changeItem.placeholder')" url="Items/WithName"
v-model="newItem" :fields="['id', 'name']"
:options="editableItems" :sort-by="['id DESC']"
:options="items"
option-label="name" option-label="name"
option-value="code" option-value="id"
/> v-model="newItem"
@update:model-value="updateItem(row)"
>
</VnSelect>
</QCardSection> </QCardSection>
<QCardActions align="right"> <QCardActions align="right">
<QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup /> <QBtn :label="t('globals.cancel')" color="primary" flat v-close-popup />

View File

@ -1,20 +1,19 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref, defineEmits } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import { useDialogPluginComponent } from 'quasar';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n(); const { t } = useI18n();
const showChangeQuantityDialog = ref(false); const showChangeQuantityDialog = ref(false);
const newQuantity = ref(null); const newQuantity = ref(null);
const { dialogRef } = useDialogPluginComponent();
const $props = defineProps({ const $props = defineProps({
selectedRows: { selectedRows: {
type: Array, type: Array,
default: () => [], default: () => [],
}, },
}); });
const emit = defineEmits(['update-quantity']);
const updateQuantity = async () => { const updateQuantity = async () => {
showChangeQuantityDialog.value = true; showChangeQuantityDialog.value = true;
const rowsToUpdate = $props.selectedRows.map(({ saleFk }) => const rowsToUpdate = $props.selectedRows.map(({ saleFk }) =>
@ -25,10 +24,9 @@ const updateQuantity = async () => {
try { try {
await Promise.all(rowsToUpdate); await Promise.all(rowsToUpdate);
emit('update-quantity');
} catch (err) { } catch (err) {
return err; return err;
} finally {
dialogRef.value.hide({ type: 'refresh', refresh: true });
} }
}; };
</script> </script>

View File

@ -2,15 +2,14 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import { useDialogPluginComponent } from 'quasar';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
const emit = defineEmits(['update-state']);
const editableStates = ref([]); const editableStates = ref([]);
const { t } = useI18n(); const { t } = useI18n();
const showChangeStateDialog = ref(false); const showChangeStateDialog = ref(false);
const newState = ref(null); const newState = ref(null);
const { dialogRef } = useDialogPluginComponent();
const $props = defineProps({ const $props = defineProps({
selectedRows: { selectedRows: {
type: Array, type: Array,
@ -27,10 +26,9 @@ const updateState = async () => {
}) })
); );
await Promise.all(rowsToUpdate); await Promise.all(rowsToUpdate);
emit('update-state');
} catch (err) { } catch (err) {
return err; return err;
} finally {
dialogRef.value.hide({ type: 'refresh', refresh: true });
} }
}; };
</script> </script>