0
0
Fork 0

feat: #7648 handle EntryBuys

This commit is contained in:
Javier Segarra 2024-06-29 00:08:35 +02:00
parent 4bbf0f29d5
commit 666cb519c5
4 changed files with 195 additions and 7 deletions

View File

@ -102,7 +102,7 @@ function saveUserData(param, value) {
axios.post('UserConfigs/setUserConfig', { [param]: value });
localUserData();
}
const isEmployee = computed(() => useRole().hasAny(['employee']));
const isEmployee = computed(() => useRole().isEmployee());
</script>
<template>

View File

@ -31,7 +31,7 @@ const timeStamp = ref(`timestamp=${Date.now()}`);
import noImage from '/public/no-user.png';
import { useRole } from 'src/composables/useRole';
const url = computed(() => {
const isEmployee = useRole().hasAny(['employee']);
const isEmployee = useRole().isEmployee();
return isEmployee
? `/api/${$props.storage}/${$props.collection}/${$props.size}/${$props.id}/download?access_token=${token}&${timeStamp.value}`
: noImage;

View File

@ -0,0 +1,184 @@
<script setup>
import { ref, computed, onMounted, onBeforeMount } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { QBtn } from 'quasar';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import FetchData from 'src/components/FetchData.vue';
import VnSelect from 'components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import { useQuasar } from 'quasar';
import { toCurrency } from 'src/filters';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
const quasar = useQuasar();
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const { notify } = useNotify();
const $props = defineProps({
id: {
type: String,
required: false,
default: null,
},
});
const rowsSelected = ref([]);
const entriesTableColumns = computed(() => [
{
align: 'left',
name: 'item',
label: t('entry.summary.item'),
field: 'itemFk',
format: (row) => row.item.name,
// component: 'fetchedTags',
// attrs: {
// item: (row) => row.item,
// },
},
{
align: 'left',
name: 'quantity',
label: t('entry.summary.quantity'),
field: 'quantity',
},
{
align: 'left',
name: 'packagingFk',
label: t('entry.summary.package'),
field: 'packagingFk',
},
{
align: 'left',
name: 'stickers',
label: t('entry.summary.stickers'),
field: 'stickers',
},
{
align: 'left',
name: 'printedStickers',
label: t('entry.buys.printedStickers'),
field: 'printedStickers',
},
{
align: 'left',
name: 'weight',
label: t('entry.summary.weight'),
field: 'weight',
},
{
align: 'left',
name: 'packing',
label: t('entry.summary.packing'),
field: 'packing',
},
{
align: 'left',
name: 'grouping',
label: t('entry.summary.grouping'),
field: 'grouping',
},
{
align: 'left',
name: 'buyingValue',
label: t('entry.summary.buyingValue'),
field: 'buyingValue',
format: ({ buyingValue }) => toCurrency(buyingValue),
},
{
align: 'left',
name: 'price2',
label: t('entry.buys.groupingPrice'),
field: 'price2',
},
{
align: 'left',
name: 'price3',
label: t('entry.buys.packingPrice'),
field: 'price3',
},
{
align: 'left',
name: 'import',
label: t('entry.summary.import'),
format: (row) => toCurrency(row.buyingValue * row.quantity),
},
]);
import { useArrayData } from 'src/composables/useArrayData';
import VnTable from 'src/components/VnTable/VnTable.vue';
const arrayData = useArrayData('EntryBuys');
const { store } = arrayData;
const entityId = computed(() => $props.id || route.params.id);
// import EntryBuysTable from './EntryBuysTable.vue';
store.userParams = {};
onBeforeMount(() => {});
</script>
<template>
<QDialog ref="dialogRef" full-width>
<QCard>
<QCardSection class="row items-center q-pb-none">
<QAvatar
:icon="icon"
color="primary"
text-color="white"
size="xl"
v-if="icon"
/>
<span class="text-h6 text-grey">{{ title }}</span>
<QSpace />
<QBtn icon="close" :disable="isLoading" flat round dense v-close-popup />
</QCardSection>
<QCardActions align="right">
<QBtn
:label="t('globals.print')"
color="primary"
icon="print"
:loading="isLoading"
@click="confirm()"
unelevated
autofocus
/>
</QCardActions>
<QCardSection class="row items-center">
<VnTable
ref="entryBuysPaginateRef"
data-key="EntryBuys"
:url="`Entries/${entityId}/getBuys`"
auto-load
:columns="entriesTableColumns"
default-mode="table"
:right-search="false"
:is-editable="false"
:use-model="false"
>
</VnTable> </QCardSection
></QCard>
</QDialog>
</template>
<style lang="scss" scoped>
.q-table--horizontal-separator tbody tr:nth-child(odd) > td {
border-bottom-width: 0px;
border-top-width: 2px;
border-color: var(--vn-text-color);
}
.infoRow > td {
color: var(--vn-label-color);
}
</style>
<i18n>
es:
</i18n>

View File

@ -1,5 +1,5 @@
<script setup>
import { ref } from 'vue';
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { onMounted } from 'vue';
import { useStateStore } from 'stores/useStateStore';
@ -9,6 +9,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'components/FetchData.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import { useRole } from 'src/composables/useRole';
const { t } = useI18n();
const props = defineProps({
@ -23,6 +24,7 @@ const companiesOptions = ref([]);
const suppliersOptions = ref([]);
const stateStore = useStateStore();
const isEmployee = computed(() => useRole().isEmployee());
onMounted(async () => {
stateStore.rightDrawer = true;
});
@ -30,6 +32,7 @@ onMounted(async () => {
<template>
<FetchData
v-if="isEmployee"
ref="companiesRef"
url="Companies"
:filter="{ fields: ['id', 'code'] }"
@ -46,6 +49,7 @@ onMounted(async () => {
auto-load
/>
<FetchData
v-if="isEmployee"
url="Suppliers"
:filter="{ fields: ['id', 'nickname', 'name'] }"
order="nickname"
@ -97,7 +101,7 @@ onMounted(async () => {
/>
</QItemSection>
</QItem>
<QItem>
<QItem v-if="isEmployee">
<QItemSection>
<VnSelect
:label="t('params.companyFk')"
@ -129,7 +133,7 @@ onMounted(async () => {
/>
</QItemSection>
</QItem>
<QItem>
<QItem v-if="isEmployee">
<QItemSection>
<VnSelect
:label="t('params.supplierFk')"
@ -217,7 +221,7 @@ onMounted(async () => {
<i18n>
en:
params:
invoiceNumber: Invoice number
travelFk: Travel
companyFk: Company
@ -231,7 +235,7 @@ en:
isOrdered: Ordered
es:
params:
invoiceNumber: Núm. factura
travelFk: Envío
companyFk: Empresa