6321_negative_tickets #1371
|
@ -1,4 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { toPercentage } from 'filters/index';
|
||||||
|
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -19,7 +21,7 @@ const formattedValue = computed(() => props.value);
|
||||||
<template>
|
<template>
|
||||||
<span :class="valueClass">
|
<span :class="valueClass">
|
||||||
<QIcon :name="iconName" size="sm" class="value-icon" />
|
<QIcon :name="iconName" size="sm" class="value-icon" />
|
||||||
{{ formattedValue }}
|
{{ toPercentage(formattedValue) }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,20 @@ const columns = computed(() => [
|
||||||
name: 'located',
|
name: 'located',
|
||||||
field: 'located',
|
field: 'located',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'right',
|
||||||
|
label: '',
|
||||||
|
name: 'tableActions',
|
||||||
|
actions: [
|
||||||
|
{
|
||||||
|
title: t('Replace'),
|
||||||
|
icon: 'change_circle',
|
||||||
|
show: (row) => isSelectionAvailable(row),
|
||||||
|
action: change,
|
||||||
|
isPrimary: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const extractNumericValue = (percentageString) => {
|
const extractNumericValue = (percentageString) => {
|
||||||
|
@ -164,20 +178,8 @@ const emit = defineEmits(['onDialogClosed', 'itemReplaced']);
|
||||||
|
|
||||||
const conditionalValuePrice = (price) => (price > 1.3 ? 'match' : 'not-match');
|
const conditionalValuePrice = (price) => (price > 1.3 ? 'match' : 'not-match');
|
||||||
|
|
||||||
const isSelected = (row) =>
|
async function change({ itemFk: substitutionFk }) {
|
||||||
proposalSelected.value.some((item) => row.itemFk === item.itemFk);
|
|
||||||
|
|
||||||
function change(row) {
|
|
||||||
if (isSelected(row)) {
|
|
||||||
confirm(row);
|
|
||||||
proposalSelected.value = [];
|
|
||||||
}
|
|
||||||
proposalSelected.value = [row];
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirm() {
|
|
||||||
try {
|
try {
|
||||||
const substitutionFk = proposalSelected.value[0].itemFk;
|
|
||||||
const promises = $props.sales.map(({ saleFk, quantity }) => {
|
const promises = $props.sales.map(({ saleFk, quantity }) => {
|
||||||
const params = {
|
const params = {
|
||||||
saleFk,
|
saleFk,
|
||||||
|
@ -223,6 +225,7 @@ const isSelectionAvailable = (itemProposal) => {
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
class="full-width q-mt-md"
|
class="full-width q-mt-md"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
|
:row-click="change"
|
||||||
:is-editable="false"
|
:is-editable="false"
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
:without-header="true"
|
:without-header="true"
|
||||||
|
@ -236,23 +239,7 @@ const isSelectionAvailable = (itemProposal) => {
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ row.id }}
|
{{ row.id }}
|
||||||
</QTooltip>
|
</QTooltip>
|
||||||
<QBtn
|
|
||||||
data-cy="replaceBtn"
|
|
||||||
icon="change_circle"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
dense
|
|
||||||
:class="{
|
|
||||||
'fill-icon': isSelected(row),
|
|
||||||
}"
|
|
||||||
@click="change(row)"
|
|
||||||
:disable="!isSelectionAvailable(row)"
|
|
||||||
>
|
|
||||||
<QTooltip v-if="!isSelected(row)">
|
|
||||||
{{ t('Select to replace') }}</QTooltip
|
|
||||||
>
|
|
||||||
<QTooltip v-else> {{ t('Selected to replace') }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
<div
|
<div
|
||||||
class="middle compatibility"
|
class="middle compatibility"
|
||||||
:style="{
|
:style="{
|
||||||
|
@ -294,15 +281,14 @@ const isSelectionAvailable = (itemProposal) => {
|
||||||
</template>
|
</template>
|
||||||
<template #column-price2="{ row }">
|
<template #column-price2="{ row }">
|
||||||
<div class="flex column items-center content-center">
|
<div class="flex column items-center content-center">
|
||||||
<VnStockValueDisplay :value="sales[0].price - row.price2" />
|
{{ toCurrency(sales[0].price) }}
|
||||||
|
{{ toCurrency(row.price2) }}
|
||||||
|
<VnStockValueDisplay :value="(sales[0].price - row.price2) / 100" />
|
||||||
<span :class="[conditionalValuePrice(row.price2)]">{{
|
<span :class="[conditionalValuePrice(row.price2)]">{{
|
||||||
toCurrency(row.price2)
|
toCurrency(row.price2)
|
||||||
}}</span>
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #column-difference="{ row }">
|
|
||||||
<VnStockValueDisplay :value="sales[0].price - row.price2" />
|
|
||||||
</template>
|
|
||||||
</VnTable>
|
</VnTable>
|
||||||
</template>
|
</template>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -28,8 +28,8 @@ const emit = defineEmits([
|
||||||
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
|
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<QDialog ref="dialogRef" full-width transition-show="scale" transition-hide="scale">
|
<QDialog ref="dialogRef" transition-show="scale" transition-hide="scale">
|
||||||
<QCard>
|
<QCard class="dialog-width">
|
||||||
<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 />
|
||||||
|
@ -49,3 +49,8 @@ defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.h
|
||||||
</QCard>
|
</QCard>
|
||||||
</QDialog>
|
</QDialog>
|
||||||
</template>
|
</template>
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.dialog-width {
|
||||||
|
max-width: $width-lg;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue