feat: refs #6321 updates

This commit is contained in:
Javier Segarra 2024-09-24 22:11:41 +02:00
parent 7da3f132ea
commit d7f37eff32
7 changed files with 172 additions and 86 deletions

View File

@ -1,15 +1,14 @@
<script setup> <script setup>
import { ref, computed, onUnmounted } from 'vue'; import { ref, computed, onUnmounted } from 'vue';
import axios from 'axios'; // import axios from 'axios';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import FetchedTags from 'components/ui/FetchedTags.vue'; import FetchedTags from 'components/ui/FetchedTags.vue';
import VnImg from 'src/components/ui/VnImg.vue'; import VnImg from 'src/components/ui/VnImg.vue';
import { toCurrency } from 'filters/index'; import { toCurrency } from 'filters/index';
import VnStockValueDisplay from 'src/components/ui/VnStockValueDisplay.vue'; import VnStockValueDisplay from 'src/components/ui/VnStockValueDisplay.vue';
// import { useDialogPluginComponent } from 'quasar';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInput from 'src/components/common/VnInput.vue';
const MATCH_VALUES = [5, 6, 7, 8]; const MATCH_VALUES = [5, 6, 7, 8];
const { t } = useI18n(); const { t } = useI18n();
@ -43,10 +42,10 @@ const proposalSelected = ref([]);
const quantity = ref(-1); const quantity = ref(-1);
const defaultColumnAttrs = { const defaultColumnAttrs = {
align: 'center', align: 'center',
sortable: true, sortable: false,
}; };
const ticket = computed(() => $props.sales[0]); const sale = computed(() => $props.sales[0]);
const saleFk = computed(() => ticket.value.saleFk); const saleFk = computed(() => sale.value.saleFk);
const statusConditionalValue = (row) => { const statusConditionalValue = (row) => {
const total = MATCH_VALUES.reduce((acc, i) => acc + row[`match${i}`], 0); const total = MATCH_VALUES.reduce((acc, i) => acc + row[`match${i}`], 0);
return total; return total;
@ -62,26 +61,39 @@ const columns = computed(() => [
label: t('proposal.available'), label: t('proposal.available'),
name: 'available', name: 'available',
field: 'available', field: 'available',
type: 'number', columnClass: 'shrink',
},
{
...defaultColumnAttrs,
label: t('proposal.difference'),
name: 'difference',
style: 'max-width: 75px', style: 'max-width: 75px',
columnFilter: {
component: 'input',
type: 'number',
columnClass: 'shrink',
}, },
{
...defaultColumnAttrs,
label: t('proposal.compatibility'),
name: 'status',
field: statusConditionalValue,
sortable: true,
}, },
// {
// ...defaultColumnAttrs,
// label: t('proposal.difference'),
// name: 'difference',
// style: 'max-width: 75px',
// },
// {
// ...defaultColumnAttrs,
// label: t('proposal.compatibility'),
// name: 'status',
// field: statusConditionalValue,
// sortable: true,
// },
{ {
...defaultColumnAttrs, ...defaultColumnAttrs,
label: t('proposal.counter'), label: t('proposal.counter'),
name: 'counter', name: 'counter',
field: 'counter', field: 'counter',
columnClass: 'shrink',
style: 'max-width: 75px',
columnFilter: {
component: 'input',
type: 'number',
columnClass: 'shrink',
},
}, },
{ {
@ -91,23 +103,30 @@ const columns = computed(() => [
name: 'longName', name: 'longName',
field: 'longName', field: 'longName',
columnClass: 'expand', columnClass: 'expand',
columnFilter: { class: 'expand' },
}, },
{ {
...defaultColumnAttrs, ...defaultColumnAttrs,
label: t('proposal.price2'), label: t('proposal.price2'),
name: 'price2', name: 'price2',
class: 'shrink', style: 'max-width: 75px',
columnFilter: {
component: 'input',
type: 'number',
columnClass: 'shrink',
},
}, },
{ {
...defaultColumnAttrs, ...defaultColumnAttrs,
label: t('proposal.minQuantity'), label: t('proposal.minQuantity'),
name: 'minQuantity', name: 'minQuantity',
field: 'minQuantity', field: 'minQuantity',
style: 'max-width: 75px',
columnFilter: {
component: 'input', component: 'input',
type: 'number', type: 'number',
class: 'shrink', columnClass: 'shrink',
},
}, },
{ {
...defaultColumnAttrs, ...defaultColumnAttrs,
@ -126,13 +145,14 @@ async function confirm() {
// }; // };
// 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, 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,
}); // });
proposalTableRef.value.reload(); proposalTableRef.value.reload();
emit('itemReplaced', { emit('itemReplaced', {
type: 'refresh', type: 'refresh',
quantity: quantity.value,
itemProposal: proposalSelected.value[0], itemProposal: proposalSelected.value[0],
...params, ...params,
}); });
@ -153,18 +173,23 @@ onUnmounted(() => {});
function handleSelection(value, _) { function handleSelection(value, _) {
quantity.value = value.available; quantity.value = value.available;
} }
// const isSelectionAvailable = (data) => { const isSelectionAvailable = (itemProposal) => {
// if (!data?.row) return false; const { price2 } = itemProposal;
// const { row } = data; const salePrice = sale.value.price;
// return $props.replaceAction && row.available >= Math.abs($props.itemLack.lack); // debugger;
// }; const byPrice = (100 * price2) / salePrice > 30;
if (byPrice) {
return byPrice;
}
const byQuantity =
(100 * itemProposal.available) / Math.abs($props.itemLack.lack) < 30;
return byQuantity;
// return $props.replaceAction && row.available >= Math.abs($props.itemLack.lack);
};
// watch(proposalSelected, ({ available }) => (quantity.value = available)); // watch(proposalSelected, ({ available }) => (quantity.value = available));
</script> </script>
<template> <template>
<div style="min-width: 65vw"> <div style="min-width: 65vw">
{{ sales }}
<br />
{{ itemLack }}
<VnTable <VnTable
ref="proposalTableRef" ref="proposalTableRef"
data-key="ItemsGetSimilar" data-key="ItemsGetSimilar"
@ -197,16 +222,21 @@ function handleSelection(value, _) {
:loading="isLoading" :loading="isLoading"
@click="confirm" @click="confirm"
style="padding-block: 8px" style="padding-block: 8px"
:disable="proposalSelected.length < 1 || quantity === 0" :disable="
proposalSelected.length < 1 ||
quantity === 0 ||
quantity > Math.abs(itemLack.lack)
"
/> />
<VnInputNumber <VnInput
v-model.number="quantity" v-model="quantity"
v-if="proposalSelected.length > 0" v-if="proposalSelected.length > 0"
@update:model-value="(val) => (quantity = val)" @update:model-value="(val) => (quantity = val)"
type="number"
min="0" min="0"
:max="Math.abs(itemLack.lack)"
:label="t('proposal.quantityToReplace')" :label="t('proposal.quantityToReplace')"
dense dense
autofocus
class="q-ml-xs" class="q-ml-xs"
/></div /></div
></template> ></template>
@ -215,22 +245,32 @@ function handleSelection(value, _) {
<QCheckbox <QCheckbox
class="q-ma-xs" class="q-ma-xs"
flat flat
:disable="isSelectionAvailable(props.row)"
v-model="props.selected" v-model="props.selected"
@update:model-value="(evt, _) => handleSelection(props.row, null)" @update:model-value="(evt, _) => handleSelection(props.row, null)"
> >
<QTooltip>
<span v-if="isSelectionAvailable(props.row)">{{
t('proposal.available')
}}</span>
<span v-else>{{ t('proposal.available') }}</span>
</QTooltip>
</QCheckbox> </QCheckbox>
</template> </template>
<template #column-longName="{ row }"> <template #column-longName="{ row }">
<!-- <QTd align="left" class="text-primary"> --> <QTd style="max-width: 800px">
<QTooltip> <QTooltip>
{{ row.id }} {{ row.id }}
</QTooltip> </QTooltip>
<!-- <QBtn flat color="blue" dense>{{ }}</QBtn> --> <!-- <QBtn flat color="blue" dense>{{ }}</QBtn> -->
<span class="link">{{ row.longName }}</span> <span style="font-size: x-small">({{ row.id }})</span
><span class="link">{{ row.longName }}</span>
<ItemDescriptorProxy :id="row.id" /> <ItemDescriptorProxy :id="row.id" />
<div style="display: flex; flex-direction: row"> <div style="display: flex; flex-direction: row">
<div style="display: flex; flex-direction: column"> <div style="display: flex; flex-direction: column">
<span style="font-size: xx-small">{{ row.price2 }}</span> <!-- -->
<VnImg <VnImg
:id="row.id" :id="row.id"
spinner-color="primary" spinner-color="primary"
@ -239,15 +279,43 @@ function handleSelection(value, _) {
width="50px" width="50px"
class="image remove-bg" class="image remove-bg"
/> />
<span style="font-size: xx-small">ID: {{ row.id }}</span> <!-- <span style="font-size: xx-small">ID:</span> -->
</div> </div>
<div style="display: flex; align-items: center"> <div
<FetchedTags :item="row" /> style="
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
"
>
<FetchedTags :item="row" class="q-mb-xs" />
<div
:style="{
background: gradientStyle(
statusConditionalValue(row)
),
}"
class="compatibility"
>
<QTooltip>
{{ compatibilityItem(statusConditionalValue(row)) }}
</QTooltip>
</div> </div>
</div> </div>
<!-- </QTd> --> </div>
</QTd>
</template> </template>
<template #column-status="{ row }"> <template #column-available="{ row }">
{{ row.available }}
</template>
<template #column-counter="{ row }">
{{ row.counter }}
</template>
<template #column-minQuantity="{ row }">
{{ row.minQuantity }}
</template>
<!-- <template #column-status="{ row }">
<div <div
:style="{ background: gradientStyle(statusConditionalValue(row)) }" :style="{ background: gradientStyle(statusConditionalValue(row)) }"
class="compatibility" class="compatibility"
@ -256,14 +324,21 @@ function handleSelection(value, _) {
{{ compatibilityItem(statusConditionalValue(row)) }} {{ compatibilityItem(statusConditionalValue(row)) }}
</QTooltip> </QTooltip>
</div> </div>
</template> </template> -->
<template #column-price2="{ row }"> <template #column-price2="{ row }">
<QTooltip> <div
{{ toCurrency(row.price2) }} style="
</QTooltip> display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
"
>
<VnStockValueDisplay :value="sales[0].price - row.price2" />
<span :class="[conditionalValuePrice(row.price2)]">{{ <span :class="[conditionalValuePrice(row.price2)]">{{
toCurrency(row.price2) toCurrency(row.price2)
}}</span> }}</span>
</div>
</template> </template>
<template #column-difference="{ row }"> <template #column-difference="{ row }">
<VnStockValueDisplay :value="sales[0].price - row.price2" /> <VnStockValueDisplay :value="sales[0].price - row.price2" />
@ -273,7 +348,8 @@ function handleSelection(value, _) {
</template> </template>
<style lang="scss"> <style lang="scss">
.compatibility { .compatibility {
height: 10px; height: 1vh;
width: 100%;
} }
.match { .match {
@ -292,3 +368,7 @@ function handleSelection(value, _) {
font-size: 16px; font-size: 16px;
} }
</style> </style>
<i18n>
en:
</i18n>

View File

@ -25,7 +25,7 @@ const $props = defineProps({
</script> </script>
<template> <template>
<QPopupProxy> <QPopupProxy>
<QCard class="q-pa-sm"> <QCard>
<QCardSection class="row items-center q-pb-none"> <QCardSection class="row items-center q-pb-none">
<span class="text-h6 text-grey">{{ $t('Item proposal') }}</span> <span class="text-h6 text-grey">{{ $t('Item proposal') }}</span>
<QSpace /> <QSpace />

View File

@ -100,7 +100,7 @@ proposal:
value8: value8 value8: value8
available: Available available: Available
minQuantity: minQuantity minQuantity: minQuantity
price2: price2 price2: Price
located: Located located: Located
counter: Counter counter: Counter
groupingPrice: Grouping Price groupingPrice: Grouping Price

View File

@ -90,6 +90,9 @@ itemType:
temperature: Temperatura temperature: Temperatura
itemProposal: Artículos similares itemProposal: Artículos similares
proposal: proposal:
substitutionAvailable: Sustitución disponible
notSubstitutionAvailableByPrice: Sustitución no disponible, 30% de diferencia por precio o cantidad
compatibility: Compatibilidad
title: Items de sustitución para los tickets seleccionados title: Items de sustitución para los tickets seleccionados
itemFk: Item itemFk: Item
longName: Nombre longName: Nombre

View File

@ -30,7 +30,7 @@ const showProposalDialog = ref(false);
const showChangeQuantityDialog = ref(false); const showChangeQuantityDialog = ref(false);
const showFree = ref(true); const showFree = ref(true);
const selectedRows = ref([]); const selectedRows = ref([]);
const badgeLackRef = ref();
const route = useRoute(); const route = useRoute();
const itemLack = ref(null); const itemLack = ref(null);
const originalRowDataCopy = ref(null); const originalRowDataCopy = ref(null);
@ -76,8 +76,11 @@ defineExpose({ reload });
// return rows; // return rows;
// }; // };
const itemProposalEvt = ({ itemProposal }) => { const itemProposalEvt = (data) => {
const { itemProposal, quantity } = data;
itemProposalSelected.value = itemProposal; itemProposalSelected.value = itemProposal;
// badgeLackRef.value.reload();
itemLack.value.lack += +quantity;
tableRef.value.reload(); tableRef.value.reload();
// replaceItem(); // replaceItem();
}; };
@ -134,8 +137,8 @@ const itemProposalSelected = ref(null);
<QBtnGroup push style="column-gap: 1px"> <QBtnGroup push style="column-gap: 1px">
<TicketMassiveUpdate <TicketMassiveUpdate
:disable="selectedRows.length < 2" :disable="selectedRows.length < 2"
label="negative.buttonsUpdate.state" :label="t('negative.buttonsUpdate.state')"
tooltip="negative.detail.modal.changeState.title" :tooltip="t('negative.detail.modal.changeState.title')"
> >
<ChangeStateDialog <ChangeStateDialog
ref="changeStateDialogRef" ref="changeStateDialogRef"
@ -143,10 +146,10 @@ const itemProposalSelected = ref(null);
></ChangeStateDialog> ></ChangeStateDialog>
</TicketMassiveUpdate> </TicketMassiveUpdate>
<TicketMassiveUpdate <TicketMassiveUpdate
label="negative.buttonsUpdate.quantity" :label="t('negative.buttonsUpdate.quantity')"
:tooltip="t('negative.detail.modal.changeQuantity.title')"
@click="showChangeQuantityDialog = true" @click="showChangeQuantityDialog = true"
:disable="selectedRows.length < 2" :disable="selectedRows.length < 2"
tooltip="negative.detail.modal.changeQuantity.title"
> >
<ChangeQuantityDialog <ChangeQuantityDialog
ref="changeQuantityDialogRef" ref="changeQuantityDialogRef"
@ -210,6 +213,7 @@ const itemProposalSelected = ref(null);
" "
> >
<QBadge <QBadge
ref="badgeLackRef"
class="q-ml-xs" class="q-ml-xs"
v-if="itemLack" v-if="itemLack"
text-color="white" text-color="white"

View File

@ -177,7 +177,7 @@ const itemLackForm = ref();
const reload = async (data) => { const reload = async (data) => {
// window.location.reload(); // window.location.reload();
console.err(data); console.error(data);
}; };
defineExpose({ reload }); defineExpose({ reload });
const emit = defineEmits(['update:selection']); const emit = defineEmits(['update:selection']);
@ -187,7 +187,6 @@ watch(selectedRows, () => emit('update:selection', selectedRows));
</script> </script>
<template> <template>
{{ selectedRows }}
<FetchData <FetchData
url="States/editableStates" url="States/editableStates"
@on-fetch="(data) => (editableStates = data)" @on-fetch="(data) => (editableStates = data)"

View File

@ -268,9 +268,9 @@ negative:
totalNegative: 'Total negatives' totalNegative: 'Total negatives'
days: Days days: Days
buttonsUpdate: buttonsUpdate:
itemProposal: artículo itemProposal: Item
state: Estado state: State
quantity: Cantidad quantity: Quantity
modalOrigin: modalOrigin:
title: 'Update negatives' title: 'Update negatives'
question: 'Select a state to update' question: 'Select a state to update'