Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into Fix-AddSearchbarToWagonModule

This commit is contained in:
Jon Elias 2024-10-29 09:37:56 +01:00
commit 8756a33422
144 changed files with 3499 additions and 2441 deletions

View File

@ -2,9 +2,11 @@ import axios from 'axios';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import { Router } from 'src/router'; import { Router } from 'src/router';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
const session = useSession(); const session = useSession();
const { notify } = useNotify(); const { notify } = useNotify();
const stateQuery = useStateQueryStore();
const baseUrl = '/api/'; const baseUrl = '/api/';
axios.defaults.baseURL = baseUrl; axios.defaults.baseURL = baseUrl;
@ -15,7 +17,7 @@ const onRequest = (config) => {
if (token.length && !config.headers.Authorization) { if (token.length && !config.headers.Authorization) {
config.headers.Authorization = token; config.headers.Authorization = token;
} }
stateQuery.add(config);
return config; return config;
}; };
@ -24,10 +26,10 @@ const onRequestError = (error) => {
}; };
const onResponse = (response) => { const onResponse = (response) => {
const { method } = response.config; const config = response.config;
stateQuery.remove(config);
const isSaveRequest = method === 'patch'; if (config.method === 'patch') {
if (isSaveRequest) {
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
} }
@ -35,37 +37,9 @@ const onResponse = (response) => {
}; };
const onResponseError = (error) => { const onResponseError = (error) => {
let message = ''; stateQuery.remove(error.config);
const response = error.response; if (session.isLoggedIn() && error.response?.status === 401) {
const responseData = response && response.data;
const responseError = responseData && response.data.error;
if (responseError) {
message = responseError.message;
}
switch (response?.status) {
case 422:
if (error.name == 'ValidationError')
message +=
' "' +
responseError.details.context +
'.' +
Object.keys(responseError.details.codes).join(',') +
'"';
break;
case 500:
message = 'errors.statusInternalServerError';
break;
case 502:
message = 'errors.statusBadGateway';
break;
case 504:
message = 'errors.statusGatewayTimeout';
break;
}
if (session.isLoggedIn() && response?.status === 401) {
session.destroy(false); session.destroy(false);
const hash = window.location.hash; const hash = window.location.hash;
const url = hash.slice(1); const url = hash.slice(1);
@ -74,8 +48,6 @@ const onResponseError = (error) => {
return Promise.reject(error); return Promise.reject(error);
} }
notify(message, 'negative');
return Promise.reject(error); return Promise.reject(error);
}; };

View File

@ -1,38 +0,0 @@
import routes from 'src/router/modules';
import { useRouter } from 'vue-router';
let isNotified = false;
export default {
created: function () {
const router = useRouter();
const keyBindingMap = routes
.filter((route) => route.meta.keyBinding)
.reduce((map, route) => {
map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
return map;
}, {});
const handleKeyDown = (event) => {
const { ctrlKey, altKey, code } = event;
if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
event.preventDefault();
router.push(keyBindingMap[code]);
isNotified = true;
}
};
const handleKeyUp = (event) => {
const { ctrlKey, altKey } = event;
// Resetea la bandera cuando se sueltan las teclas ctrl o alt
if (!ctrlKey || !altKey) {
isNotified = false;
}
};
window.addEventListener('keydown', handleKeyDown);
window.addEventListener('keyup', handleKeyUp);
},
};

View File

@ -1,16 +1,51 @@
import { boot } from 'quasar/wrappers'; import { boot } from 'quasar/wrappers';
import qFormMixin from './qformMixin'; import qFormMixin from './qformMixin';
import mainShortcutMixin from './mainShortcutMixin';
import keyShortcut from './keyShortcut'; import keyShortcut from './keyShortcut';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { CanceledError } from 'axios';
const { notify } = useNotify(); const { notify } = useNotify();
export default boot(({ app }) => { export default boot(({ app }) => {
app.mixin(qFormMixin); app.mixin(qFormMixin);
app.mixin(mainShortcutMixin);
app.directive('shortcut', keyShortcut); app.directive('shortcut', keyShortcut);
app.config.errorHandler = function (err) { app.config.errorHandler = (error) => {
console.error(err); let message;
notify('globals.error', 'negative', 'error'); const response = error.response;
const responseData = response?.data;
const responseError = responseData && response.data.error;
if (responseError) {
message = responseError.message;
}
switch (response?.status) {
case 422:
if (error.name == 'ValidationError')
message +=
' "' +
responseError.details.context +
'.' +
Object.keys(responseError.details.codes).join(',') +
'"';
break;
case 500:
message = 'errors.statusInternalServerError';
break;
case 502:
message = 'errors.statusBadGateway';
break;
case 504:
message = 'errors.statusGatewayTimeout';
break;
}
console.error(error);
if (error instanceof CanceledError) {
const env = process.env.NODE_ENV;
if (env && env !== 'development') return;
message = 'Duplicate request';
}
notify(message ?? 'globals.error', 'negative', 'error');
}; };
}); });

View File

@ -79,14 +79,20 @@ async function onProvinceCreated(data) {
watch( watch(
() => [postcodeFormData.countryFk], () => [postcodeFormData.countryFk],
async (newCountryFk, oldValueFk) => { async (newCountryFk, oldValueFk) => {
if (!!oldValueFk[0] && newCountryFk[0] !== oldValueFk[0]) { if (Array.isArray(newCountryFk)) {
newCountryFk = newCountryFk[0];
}
if (Array.isArray(oldValueFk)) {
oldValueFk = oldValueFk[0];
}
if (!!oldValueFk && newCountryFk !== oldValueFk) {
postcodeFormData.provinceFk = null; postcodeFormData.provinceFk = null;
postcodeFormData.townFk = null; postcodeFormData.townFk = null;
} }
if ((newCountryFk, newCountryFk !== postcodeFormData.countryFk)) { if (oldValueFk !== newCountryFk) {
await provincesFetchDataRef.value.fetch({ await provincesFetchDataRef.value.fetch({
where: { where: {
countryFk: newCountryFk[0], countryFk: newCountryFk,
}, },
}); });
await townsFetchDataRef.value.fetch({ await townsFetchDataRef.value.fetch({
@ -102,10 +108,13 @@ watch(
watch( watch(
() => postcodeFormData.provinceFk, () => postcodeFormData.provinceFk,
async (newProvinceFk) => { async (newProvinceFk, oldValueFk) => {
if (newProvinceFk[0] && newProvinceFk[0] !== postcodeFormData.provinceFk) { if (Array.isArray(newProvinceFk)) {
newProvinceFk = newProvinceFk[0];
}
if (newProvinceFk !== oldValueFk) {
await townsFetchDataRef.value.fetch({ await townsFetchDataRef.value.fetch({
where: { provinceFk: newProvinceFk[0] }, where: { provinceFk: newProvinceFk },
}); });
} }
} }
@ -125,16 +134,20 @@ async function handleCountries(data) {
<FetchData <FetchData
ref="provincesFetchDataRef" ref="provincesFetchDataRef"
@on-fetch="handleProvinces" @on-fetch="handleProvinces"
:sort-by="['name ASC']"
:limit="30"
auto-load auto-load
url="Provinces/location" url="Provinces/location"
/> />
<FetchData <FetchData
ref="townsFetchDataRef" ref="townsFetchDataRef"
:sort-by="['name ASC']"
:limit="30"
@on-fetch="handleTowns" @on-fetch="handleTowns"
auto-load auto-load
url="Towns/location" url="Towns/location"
/> />
<FetchData @on-fetch="handleCountries" auto-load url="Countries" />
<FormModelPopup <FormModelPopup
url-create="postcodes" url-create="postcodes"
model="postcode" model="postcode"
@ -200,8 +213,10 @@ async function handleCountries(data) {
@on-province-created="onProvinceCreated" @on-province-created="onProvinceCreated"
/> />
<VnSelect <VnSelect
url="Countries"
:sort-by="['name ASC']"
:label="t('Country')" :label="t('Country')"
:options="countriesOptions" @update:options="handleCountries"
hide-selected hide-selected
option-label="name" option-label="name"
option-value="id" option-value="id"

View File

@ -46,6 +46,8 @@ const onDataSaved = (dataSaved, requestResponse) => {
}, },
}" }"
url="Autonomies/location" url="Autonomies/location"
:sort-by="['name ASC']"
:limit="30"
/> />
<FormModelPopup <FormModelPopup
:title="t('New province')" :title="t('New province')"

View File

@ -217,9 +217,6 @@ async function save() {
updateAndEmit('onDataSaved', formData.value, response?.data); updateAndEmit('onDataSaved', formData.value, response?.data);
if ($props.reload) await arrayData.fetch({}); if ($props.reload) await arrayData.fetch({});
hasChanges.value = false; hasChanges.value = false;
} catch (err) {
console.error(err);
notify('errors.writeRequest', 'negative');
} finally { } finally {
isLoading.value = false; isLoading.value = false;
} }

View File

@ -61,6 +61,7 @@ defineExpose({
:loading="isLoading" :loading="isLoading"
@click="emit('onDataCanceled')" @click="emit('onDataCanceled')"
v-close-popup v-close-popup
data-cy="FormModelPopup_cancel"
/> />
<QBtn <QBtn
:label="t('globals.save')" :label="t('globals.save')"
@ -70,6 +71,7 @@ defineExpose({
class="q-ml-sm" class="q-ml-sm"
:disabled="isLoading" :disabled="isLoading"
:loading="isLoading" :loading="isLoading"
data-cy="FormModelPopup_save"
/> />
</div> </div>
</template> </template>

View File

@ -3,6 +3,7 @@ import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useStateQueryStore } from 'src/stores/useStateQueryStore';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import PinnedModules from './PinnedModules.vue'; import PinnedModules from './PinnedModules.vue';
import UserPanel from 'components/UserPanel.vue'; import UserPanel from 'components/UserPanel.vue';
@ -12,6 +13,7 @@ import VnAvatar from './ui/VnAvatar.vue';
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
const quasar = useQuasar(); const quasar = useQuasar();
const stateQuery = useStateQueryStore();
const state = useState(); const state = useState();
const user = state.getUser(); const user = state.getUser();
const appName = 'Lilium'; const appName = 'Lilium';
@ -50,6 +52,14 @@ const pinnedModulesRef = ref();
</QBtn> </QBtn>
</RouterLink> </RouterLink>
<VnBreadcrumbs v-if="$q.screen.gt.sm" /> <VnBreadcrumbs v-if="$q.screen.gt.sm" />
<QSpinner
color="primary"
class="q-ml-md"
:class="{
'no-visible': !stateQuery.isLoading().value,
}"
size="xs"
/>
<QSpace /> <QSpace />
<div id="searchbar" class="searchbar"></div> <div id="searchbar" class="searchbar"></div>
<QSpace /> <QSpace />

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, watch } from 'vue'; import { ref } from 'vue';
import { useValidator } from 'src/composables/useValidator'; import { useValidator } from 'src/composables/useValidator';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { markRaw, computed, defineModel } from 'vue'; import { markRaw, computed } from 'vue';
import { QIcon, QCheckbox } from 'quasar'; import { QIcon, QCheckbox } from 'quasar';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { markRaw, computed, defineModel } from 'vue'; import { markRaw, computed } from 'vue';
import { QCheckbox } from 'quasar'; import { QCheckbox } from 'quasar';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';

View File

@ -134,6 +134,7 @@ const splittedColumns = ref({ columns: [] });
const columnsVisibilitySkipped = ref(); const columnsVisibilitySkipped = ref();
const createForm = ref(); const createForm = ref();
const tableFilterRef = ref([]); const tableFilterRef = ref([]);
const tableRef = ref();
const tableModes = [ const tableModes = [
{ {
@ -150,8 +151,8 @@ const tableModes = [
}, },
]; ];
onBeforeMount(() => { onBeforeMount(() => {
setUserParams(route.query[$props.searchUrl]); const urlParams = route.query[$props.searchUrl];
hasParams.value = params.value && Object.keys(params.value).length !== 0; hasParams.value = urlParams && Object.keys(urlParams).length !== 0;
}); });
onMounted(() => { onMounted(() => {
@ -184,7 +185,8 @@ watch(
watch( watch(
() => route.query[$props.searchUrl], () => route.query[$props.searchUrl],
(val) => setUserParams(val) (val) => setUserParams(val),
{ immediate: true, deep: true }
); );
const isTableMode = computed(() => mode.value == TABLE_MODE); const isTableMode = computed(() => mode.value == TABLE_MODE);
@ -315,12 +317,20 @@ defineExpose({
selected, selected,
CrudModelRef, CrudModelRef,
params, params,
tableRef,
}); });
function handleOnDataSaved(_) { function handleOnDataSaved(_) {
if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value }); if (_.onDataSaved) _.onDataSaved({ CrudModelRef: CrudModelRef.value });
else $props.create.onDataSaved(_); else $props.create.onDataSaved(_);
} }
function handleScroll() {
const tMiddle = tableRef.value.$el.querySelector('.q-table__middle');
const { scrollHeight, scrollTop, clientHeight } = tMiddle;
const isAtBottom = Math.abs(scrollHeight - scrollTop - clientHeight) <= 40;
if (isAtBottom) CrudModelRef.value.vnPaginateRef.paginate();
}
</script> </script>
<template> <template>
<QDrawer <QDrawer
@ -405,8 +415,10 @@ function handleOnDataSaved(_) {
</template> </template>
<template #body="{ rows }"> <template #body="{ rows }">
<QTable <QTable
ref="tableRef"
v-bind="table" v-bind="table"
class="vnTable" class="vnTable"
:class="{ 'last-row-sticky': $props.footer }"
:columns="splittedColumns.columns" :columns="splittedColumns.columns"
:rows="rows" :rows="rows"
v-model:selected="selected" v-model:selected="selected"
@ -416,12 +428,7 @@ function handleOnDataSaved(_) {
flat flat
:style="isTableMode && `max-height: ${tableHeight}`" :style="isTableMode && `max-height: ${tableHeight}`"
:virtual-scroll="isTableMode" :virtual-scroll="isTableMode"
@virtual-scroll=" @virtual-scroll="handleScroll"
(event) =>
event.index > rows.length - 2 &&
($props.crudModel?.paginate ?? true) &&
CrudModelRef.vnPaginateRef.paginate()
"
@row-click="(_, row) => rowClickFunction && rowClickFunction(row)" @row-click="(_, row) => rowClickFunction && rowClickFunction(row)"
@update:selected="emit('update:selected', $event)" @update:selected="emit('update:selected', $event)"
> >
@ -451,7 +458,11 @@ function handleOnDataSaved(_) {
/> />
</template> </template>
<template #header-cell="{ col }"> <template #header-cell="{ col }">
<QTh v-if="col.visible ?? true"> <QTh
v-if="col.visible ?? true"
:style="col.headerStyle"
:class="col.headerClass"
>
<div <div
class="column self-start q-ml-xs ellipsis" class="column self-start q-ml-xs ellipsis"
:class="`text-${col?.align ?? 'left'}`" :class="`text-${col?.align ?? 'left'}`"
@ -811,6 +822,7 @@ es:
top: 0; top: 0;
} }
} }
.vnTable { .vnTable {
thead tr th { thead tr th {
position: sticky; position: sticky;
@ -849,6 +861,9 @@ es:
table tbody th { table tbody th {
position: relative; position: relative;
} }
}
.last-row-sticky {
tbody:nth-last-child(1) { tbody:nth-last-child(1) {
@extend .bg-header; @extend .bg-header;
position: sticky; position: sticky;

View File

@ -0,0 +1,19 @@
<script setup>
import VnSelect from './VnSelect.vue';
defineProps({
selectProps: { type: Object, required: true },
promise: { type: Function, default: () => {} },
});
</script>
<template>
<QBtnDropdown v-bind="$attrs" color="primary">
<VnSelect
v-bind="selectProps"
hide-selected
hide-dropdown-icon
focus-on-mount
@update:model-value="promise"
/>
</QBtnDropdown>
</template>

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, defineModel } from 'vue'; import { computed } from 'vue';
const model = defineModel(undefined, { required: true }); const model = defineModel(undefined, { required: true });
const $props = defineProps({ const $props = defineProps({

View File

@ -9,10 +9,6 @@ const $props = defineProps({
type: Number, //Progress value (1.0 > x > 0.0) type: Number, //Progress value (1.0 > x > 0.0)
required: true, required: true,
}, },
showDialog: {
type: Boolean,
required: true,
},
cancelled: { cancelled: {
type: Boolean, type: Boolean,
required: false, required: false,
@ -24,30 +20,22 @@ const emit = defineEmits(['cancel', 'close']);
const dialogRef = ref(null); const dialogRef = ref(null);
const _showDialog = computed({ const showDialog = defineModel('showDialog', {
get: () => $props.showDialog, type: Boolean,
set: (value) => { default: false,
if (value) dialogRef.value.show();
},
}); });
const _progress = computed(() => $props.progress); const _progress = computed(() => $props.progress);
const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`); const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
const cancel = () => {
dialogRef.value.hide();
emit('cancel');
};
</script> </script>
<template> <template>
<QDialog ref="dialogRef" v-model="_showDialog" @hide="onDialogHide"> <QDialog ref="dialogRef" v-model="showDialog" @hide="emit('close')">
<QCard class="full-width dialog"> <QCard class="full-width dialog">
<QCardSection class="row"> <QCardSection class="row">
<span class="text-h6">{{ t('Progress') }}</span> <span class="text-h6">{{ t('Progress') }}</span>
<QSpace /> <QSpace />
<QBtn icon="close" flat round dense @click="emit('close')" /> <QBtn icon="close" flat round dense v-close-popup />
</QCardSection> </QCardSection>
<QCardSection> <QCardSection>
<div class="column"> <div class="column">
@ -80,7 +68,7 @@ const cancel = () => {
type="button" type="button"
flat flat
class="text-primary" class="text-primary"
@click="cancel()" v-close-popup
> >
{{ t('globals.cancel') }} {{ t('globals.cancel') }}
</QBtn> </QBtn>

View File

@ -141,6 +141,7 @@ function findKeyInOptions() {
function setOptions(data) { function setOptions(data) {
myOptions.value = JSON.parse(JSON.stringify(data)); myOptions.value = JSON.parse(JSON.stringify(data));
myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
emit('update:options', data);
} }
function filter(val, options) { function filter(val, options) {

View File

@ -30,10 +30,11 @@ const props = defineProps({
}, },
}); });
defineEmits(['confirm', ...useDialogPluginComponent.emits]); const emit = defineEmits(['confirm', 'cancel', ...useDialogPluginComponent.emits]);
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
const { dialogRef, onDialogOK } = useDialogPluginComponent(); const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } =
useDialogPluginComponent();
defineExpose({ show: () => dialogRef.value.show(), hide: () => dialogRef.value.hide() });
const title = props.title || t('Confirm'); const title = props.title || t('Confirm');
const message = const message =
@ -53,9 +54,14 @@ async function confirm() {
} }
onDialogOK(props.data); onDialogOK(props.data);
} }
function cancel() {
emit('cancel');
onDialogCancel();
}
</script> </script>
<template> <template>
<QDialog ref="dialogRef"> <QDialog ref="dialogRef" @hide="onDialogHide">
<QCard class="q-pa-sm"> <QCard class="q-pa-sm">
<QCardSection class="row items-center q-pb-none"> <QCardSection class="row items-center q-pb-none">
<QAvatar <QAvatar
@ -67,7 +73,14 @@ async function confirm() {
/> />
<span class="text-h6">{{ title }}</span> <span class="text-h6">{{ title }}</span>
<QSpace /> <QSpace />
<QBtn icon="close" :disable="isLoading" flat round dense v-close-popup /> <QBtn
icon="close"
:disable="isLoading"
flat
round
dense
@click="cancel()"
/>
</QCardSection> </QCardSection>
<QCardSection class="q-pb-none"> <QCardSection class="q-pb-none">
<span v-if="message !== false" v-html="message" /> <span v-if="message !== false" v-html="message" />
@ -81,7 +94,7 @@ async function confirm() {
color="primary" color="primary"
:disable="isLoading" :disable="isLoading"
flat flat
v-close-popup @click="cancel()"
/> />
<QBtn <QBtn
:label="t('globals.confirm')" :label="t('globals.confirm')"

View File

@ -1,6 +1,3 @@
<script setup>
defineProps({ wrap: { type: Boolean, default: false } });
</script>
<template> <template>
<div class="vn-row q-gutter-md q-mb-md"> <div class="vn-row q-gutter-md q-mb-md">
<slot /> <slot />

View File

@ -0,0 +1,33 @@
<script setup>
import { useRoute } from 'vue-router';
import { defineProps } from 'vue';
const props = defineProps({
routeName: {
type: String,
required: true,
},
entityId: {
type: [String, Number],
required: true,
},
url: {
type: String,
default: null,
},
});
const route = useRoute();
const id = props.entityId;
</script>
<template>
<router-link
v-if="route?.name !== routeName"
:to="{ name: routeName, params: { id: id } }"
class="header link"
:href="url"
>
<QIcon name="open_in_new" color="white" size="sm" />
</router-link>
</template>

View File

@ -0,0 +1,55 @@
<script setup>
import { defineProps, ref } from 'vue';
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
const props = defineProps({
usesMana: {
type: Boolean,
required: true,
},
manaCode: {
type: String,
required: true,
},
manaVal: {
type: String,
default: 'mana',
},
manaLabel: {
type: String,
default: 'Promotion mana',
},
manaClaimVal: {
type: String,
default: 'manaClaim',
},
claimLabel: {
type: String,
default: 'Claim mana',
},
});
const manaCode = ref(props.manaCode);
</script>
<template>
<div class="column q-gutter-y-sm q-mt-sm">
<QRadio
v-model="manaCode"
dense
:val="manaVal"
:label="t(manaLabel)"
:dark="true"
class="q-mb-sm"
/>
<QRadio
v-model="manaCode"
dense
:val="manaClaimVal"
:label="t(claimLabel)"
:dark="true"
class="q-mb-sm"
/>
</div>
</template>

View File

@ -0,0 +1,11 @@
import axios from 'axios';
import { useRole } from './useRole';
export async function useAdvancedSummary(model, id, roles = ['hr']) {
if (useRole().hasAny(roles)) {
const { data } = await axios.get(`${model}/advancedSummary`, {
params: { filter: { where: { id } } },
});
return Array.isArray(data) ? data[0] : data;
}
}

View File

@ -248,6 +248,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
function updateStateParams() { function updateStateParams() {
const usesModuleName = userOptions.moduleName; const usesModuleName = userOptions.moduleName;
if (!route) return;
const newUrl = { path: route.path, query: { ...(route.query ?? {}) } }; const newUrl = { path: route.path, query: { ...(route.query ?? {}) } };
newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter); newUrl.query[store.searchUrl] = JSON.stringify(store.currentFilter);

View File

@ -288,3 +288,7 @@ input::-webkit-inner-spin-button {
color: $info; color: $info;
} }
} }
.no-visible {
visibility: hidden;
}

View File

@ -277,6 +277,8 @@ globals:
medical: Mutual medical: Mutual
RouteExtendedList: Router RouteExtendedList: Router
wasteRecalc: Waste recaclulate wasteRecalc: Waste recaclulate
operator: Operator
parking: Parking
supplier: Supplier supplier: Supplier
created: Created created: Created
worker: Worker worker: Worker
@ -303,12 +305,15 @@ globals:
from: From from: From
To: To To: To
stateFk: State stateFk: State
departmentFk: Department
email: Email email: Email
SSN: SSN SSN: SSN
fi: FI fi: FI
myTeam: My team
departmentFk: Department
changePass: Change password changePass: Change password
deleteConfirmTitle: Delete selected elements deleteConfirmTitle: Delete selected elements
changeState: Change state
raid: 'Raid {daysInForward} days'
errors: errors:
statusUnauthorized: Access denied statusUnauthorized: Access denied
statusInternalServerError: An internal server error has ocurred statusInternalServerError: An internal server error has ocurred
@ -366,7 +371,6 @@ entry:
companyFk: Company companyFk: Company
travelFk: Travel travelFk: Travel
isExcludedFromAvailable: Inventory isExcludedFromAvailable: Inventory
isRaid: Raid
invoiceAmount: Import invoiceAmount: Import
summary: summary:
commission: Commission commission: Commission
@ -377,7 +381,6 @@ entry:
ordered: Ordered ordered: Ordered
confirmed: Confirmed confirmed: Confirmed
booked: Booked booked: Booked
raid: Raid
excludedFromAvailable: Inventory excludedFromAvailable: Inventory
travelReference: Reference travelReference: Reference
travelAgency: Agency travelAgency: Agency
@ -410,7 +413,6 @@ entry:
ordered: Ordered ordered: Ordered
confirmed: Confirmed confirmed: Confirmed
booked: Booked booked: Booked
raid: Raid
excludedFromAvailable: Inventory excludedFromAvailable: Inventory
agency: Agency agency: Agency
warehouseOut: Warehouse Out warehouseOut: Warehouse Out
@ -473,7 +475,6 @@ entry:
packingOut: Package out packingOut: Package out
landing: Landing landing: Landing
isExcludedFromAvailable: Es inventory isExcludedFromAvailable: Es inventory
isRaid: Raid
ticket: ticket:
pageTitles: pageTitles:
tickets: Tickets tickets: Tickets
@ -555,7 +556,6 @@ ticket:
package: Package package: Package
taxClass: Tax class taxClass: Tax class
services: Services services: Services
changeState: Change state
requester: Requester requester: Requester
atender: Atender atender: Atender
request: Request request: Request
@ -661,8 +661,6 @@ parking:
sector: Sector sector: Sector
row: Row row: Row
column: Column column: Column
pageTitles:
parking: Parking
searchBar: searchBar:
info: You can search by parking code info: You can search by parking code
label: Search parking... label: Search parking...
@ -743,6 +741,7 @@ worker:
locker: Locker locker: Locker
balance: Balance balance: Balance
medical: Medical medical: Medical
operator: Operator
list: list:
name: Name name: Name
email: Email email: Email
@ -840,6 +839,18 @@ worker:
debit: Debt debit: Debt
credit: Have credit: Have
concept: Concept concept: Concept
operator:
numberOfWagons: Number of wagons
train: Train
itemPackingType: Item packing type
warehouse: Warehouse
sector: Sector
labeler: Printer
linesLimit: Lines limit
volumeLimit: Volume limit
sizeLimit: Size limit
isOnReservationMode: Reservation mode
machine: Machine
wagon: wagon:
pageTitles: pageTitles:
wagons: Wagons wagons: Wagons
@ -1027,6 +1038,7 @@ travel:
warehouseIn: Warehouse In warehouseIn: Warehouse In
delivered: Delivered delivered: Delivered
received: Received received: Received
daysInForward: Days in forward
thermographs: thermographs:
code: Code code: Code
temperature: Temperature temperature: Temperature
@ -1040,92 +1052,6 @@ travel:
warehouse: Warehouse warehouse: Warehouse
travelFileDescription: 'Travel id { travelId }' travelFileDescription: 'Travel id { travelId }'
file: File file: File
item:
descriptor:
item: Item
buyer: Buyer
color: Color
category: Category
stems: Stems
visible: Visible
available: Available
warehouseText: 'Calculated on the warehouse of { warehouseName }'
itemDiary: Item diary
producer: Producer
list:
id: Identifier
grouping: Grouping
packing: Packing
description: Description
stems: Stems
category: Category
typeName: Type
intrastat: Intrastat
isActive: Active
size: Size
origin: Origin
userName: Buyer
weightByPiece: Weight/Piece
stemMultiplier: Multiplier
producer: Producer
landed: Landed
fixedPrice:
itemFk: Item ID
groupingPrice: Grouping price
packingPrice: Packing price
hasMinPrice: Has min price
minPrice: Min price
started: Started
ended: Ended
warehouse: Warehouse
create:
name: Name
tag: Tag
priority: Priority
type: Type
intrastat: Intrastat
origin: Origin
buyRequest:
ticketId: 'Ticket ID'
shipped: 'Shipped'
requester: 'Requester'
requested: 'Requested'
price: 'Price'
attender: 'Atender'
item: 'Item'
achieved: 'Achieved'
concept: 'Concept'
state: 'State'
summary:
basicData: 'Basic data'
otherData: 'Other data'
description: 'Description'
tax: 'Tax'
tags: 'Tags'
botanical: 'Botanical'
barcode: 'Barcode'
name: 'Nombre'
completeName: 'Nombre completo'
family: 'Familia'
size: 'Medida'
origin: 'Origen'
stems: 'Tallos'
multiplier: 'Multiplicador'
buyer: 'Comprador'
doPhoto: 'Do photo'
intrastatCode: 'Código intrastat'
intrastat: 'Intrastat'
ref: 'Referencia'
relevance: 'Relevancia'
weight: 'Peso (gramos)/tallo'
units: 'Unidades/caja'
expense: 'Gasto'
generic: 'Genérico'
recycledPlastic: 'Plástico reciclado'
nonRecycledPlastic: 'Plástico no reciclado'
minSalesQuantity: 'Cantidad mínima de venta'
genus: 'Genus'
specie: 'Specie'
components: components:
topbar: {} topbar: {}
itemsFilterPanel: itemsFilterPanel:

View File

@ -281,6 +281,8 @@ globals:
serial: Facturas por serie serial: Facturas por serie
medical: Mutua medical: Mutua
wasteRecalc: Recalcular mermas wasteRecalc: Recalcular mermas
operator: Operario
parking: Parking
supplier: Proveedor supplier: Proveedor
created: Fecha creación created: Fecha creación
worker: Trabajador worker: Trabajador
@ -311,8 +313,11 @@ globals:
email: Correo email: Correo
SSN: NSS SSN: NSS
fi: NIF fi: NIF
myTeam: Mi equipo
changePass: Cambiar contraseña changePass: Cambiar contraseña
deleteConfirmTitle: Eliminar los elementos seleccionados deleteConfirmTitle: Eliminar los elementos seleccionados
changeState: Cambiar estado
raid: 'Redada {daysInForward} días'
errors: errors:
statusUnauthorized: Acceso denegado statusUnauthorized: Acceso denegado
statusInternalServerError: Ha ocurrido un error interno del servidor statusInternalServerError: Ha ocurrido un error interno del servidor
@ -368,7 +373,6 @@ entry:
companyFk: Empresa companyFk: Empresa
travelFk: Envio travelFk: Envio
isExcludedFromAvailable: Inventario isExcludedFromAvailable: Inventario
isRaid: Redada
invoiceAmount: Importe invoiceAmount: Importe
summary: summary:
commission: Comisión commission: Comisión
@ -379,7 +383,6 @@ entry:
ordered: Pedida ordered: Pedida
confirmed: Confirmada confirmed: Confirmada
booked: Contabilizada booked: Contabilizada
raid: Redada
excludedFromAvailable: Inventario excludedFromAvailable: Inventario
travelReference: Referencia travelReference: Referencia
travelAgency: Agencia travelAgency: Agencia
@ -412,7 +415,6 @@ entry:
ordered: Pedida ordered: Pedida
confirmed: Confirmado confirmed: Confirmado
booked: Asentado booked: Asentado
raid: Redada
excludedFromAvailable: Inventario excludedFromAvailable: Inventario
agency: Agencia agency: Agencia
warehouseOut: Alm. salida warehouseOut: Alm. salida
@ -475,7 +477,6 @@ entry:
packingOut: Embalaje envíos packingOut: Embalaje envíos
landing: Llegada landing: Llegada
isExcludedFromAvailable: Es inventario isExcludedFromAvailable: Es inventario
isRaid: Redada
ticket: ticket:
pageTitles: pageTitles:
tickets: Tickets tickets: Tickets
@ -564,7 +565,6 @@ ticket:
package: Embalaje package: Embalaje
taxClass: Tipo IVA taxClass: Tipo IVA
services: Servicios services: Servicios
changeState: Cambiar estado
requester: Solicitante requester: Solicitante
atender: Comprador atender: Comprador
request: Petición de compra request: Petición de compra
@ -708,8 +708,6 @@ parking:
pickingOrder: Orden de recogida pickingOrder: Orden de recogida
row: Fila row: Fila
column: Columna column: Columna
pageTitles:
parking: Parking
searchBar: searchBar:
info: Puedes buscar por código de parking info: Puedes buscar por código de parking
label: Buscar parking... label: Buscar parking...
@ -750,6 +748,7 @@ worker:
balance: Balance balance: Balance
formation: Formación formation: Formación
medical: Mutua medical: Mutua
operator: Operario
list: list:
name: Nombre name: Nombre
email: Email email: Email
@ -838,6 +837,19 @@ worker:
debit: Debe debit: Debe
credit: Haber credit: Haber
concept: Concepto concept: Concepto
operator:
numberOfWagons: Número de vagones
train: tren
itemPackingType: Tipo de embalaje
warehouse: Almacén
sector: Sector
labeler: Impresora
linesLimit: Líneas límite
volumeLimit: Volumen límite
sizeLimit: Tamaño límite
isOnReservationMode: Modo de reserva
machine: Máquina
wagon: wagon:
pageTitles: pageTitles:
wagons: Vagones wagons: Vagones
@ -1024,6 +1036,7 @@ travel:
warehouseIn: Alm. entrada warehouseIn: Alm. entrada
delivered: Enviada delivered: Enviada
received: Recibida received: Recibida
daysInForward: Días redada
thermographs: thermographs:
code: Código code: Código
temperature: Temperatura temperature: Temperatura
@ -1037,92 +1050,6 @@ travel:
warehouse: Almacén warehouse: Almacén
travelFileDescription: 'Id envío { travelId }' travelFileDescription: 'Id envío { travelId }'
file: Fichero file: Fichero
item:
descriptor:
item: Artículo
buyer: Comprador
color: Color
category: Categoría
stems: Tallos
visible: Visible
available: Disponible
warehouseText: 'Calculado sobre el almacén de { warehouseName }'
itemDiary: Registro de compra-venta
producer: Productor
list:
id: Identificador
grouping: Grouping
packing: Packing
description: Descripción
stems: Tallos
category: Reino
typeName: Tipo
intrastat: Intrastat
isActive: Activo
size: Medida
origin: Origen
weightByPiece: Peso (gramos)/tallo
userName: Comprador
stemMultiplier: Multiplicador
producer: Productor
landed: F. entrega
fixedPrice:
itemFk: ID Artículo
groupingPrice: Precio grouping
packingPrice: Precio packing
hasMinPrice: Tiene precio mínimo
minPrice: Precio min
started: Inicio
ended: Fin
warehouse: Almacén
create:
name: Nombre
tag: Etiqueta
priority: Prioridad
type: Tipo
intrastat: Intrastat
origin: Origen
summary:
basicData: 'Datos básicos'
otherData: 'Otros datos'
description: 'Descripción'
tax: 'IVA'
tags: 'Etiquetas'
botanical: 'Botánico'
barcode: 'Código de barras'
name: 'Nombre'
completeName: 'Nombre completo'
family: 'Familia'
size: 'Medida'
origin: 'Origen'
stems: 'Tallos'
multiplier: 'Multiplicador'
buyer: 'Comprador'
doPhoto: 'Hacer foto'
intrastatCode: 'Código intrastat'
intrastat: 'Intrastat'
ref: 'Referencia'
relevance: 'Relevancia'
weight: 'Peso (gramos)/tallo'
units: 'Unidades/caja'
expense: 'Gasto'
generic: 'Genérico'
recycledPlastic: 'Plástico reciclado'
nonRecycledPlastic: 'Plástico no reciclado'
minSalesQuantity: 'Cantidad mínima de venta'
genus: 'Genus'
specie: 'Specie'
buyRequest:
ticketId: 'ID Ticket'
shipped: 'F. envío'
requester: 'Solicitante'
requested: 'Solicitado'
price: 'Precio'
attender: 'Comprador'
item: 'Artículo'
achieved: 'Conseguido'
concept: 'Concepto'
state: 'Estado'
components: components:
topbar: {} topbar: {}
itemsFilterPanel: itemsFilterPanel:

View File

@ -1,7 +1,44 @@
<script setup> <script setup>
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import Navbar from 'src/components/NavBar.vue'; import Navbar from 'src/components/NavBar.vue';
import { useRouter } from 'vue-router';
import routes from 'src/router/modules';
import { onMounted } from 'vue';
const quasar = useQuasar(); const quasar = useQuasar();
onMounted(() => {
let isNotified = false;
const router = useRouter();
const keyBindingMap = routes
.filter((route) => route.meta.keyBinding)
.reduce((map, route) => {
map['Key' + route.meta.keyBinding.toUpperCase()] = route.path;
return map;
}, {});
const handleKeyDown = (event) => {
const { ctrlKey, altKey, code } = event;
if (ctrlKey && altKey && keyBindingMap[code] && !isNotified) {
event.preventDefault();
router.push(keyBindingMap[code]);
isNotified = true;
}
};
const handleKeyUp = (event) => {
const { ctrlKey, altKey } = event;
if (!ctrlKey || !altKey) {
isNotified = false;
}
};
window.addEventListener('keydown', handleKeyDown);
window.addEventListener('keyup', handleKeyUp);
});
</script> </script>
<template> <template>

View File

@ -9,6 +9,8 @@ import { useQuasar } from 'quasar';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue';
import VnConfirm from 'components/ui/VnConfirm.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
import FetchData from 'src/components/FetchData.vue';
import { useValidator } from 'src/composables/useValidator';
defineProps({ defineProps({
id: { id: {
@ -23,11 +25,18 @@ const stateStore = useStateStore();
const quasar = useQuasar(); const quasar = useQuasar();
const tableRef = ref(); const tableRef = ref();
const roles = ref();
const validationsStore = useValidator();
const { models } = validationsStore;
const exprBuilder = (param, value) => { const exprBuilder = (param, value) => {
switch (param) { switch (param) {
case 'search': case 'search':
return { model: { like: `%${value}%` } }; return {
or: [
{ model: { like: `%${value}%` } },
{ property: { like: `%${value}%` } },
],
};
default: default:
return { [param]: value }; return { [param]: value };
} }
@ -47,6 +56,13 @@ const columns = computed(() => [
label: t('model'), label: t('model'),
cardVisible: true, cardVisible: true,
create: true, create: true,
columnCreate: {
label: t('model'),
component: 'select',
attrs: {
options: Object.keys(models),
},
},
}, },
{ {
align: 'left', align: 'left',
@ -55,9 +71,10 @@ const columns = computed(() => [
cardVisible: true, cardVisible: true,
component: 'select', component: 'select',
attrs: { attrs: {
url: 'VnRoles', options: roles,
optionLabel: 'name', optionLabel: 'name',
optionValue: 'name', optionValue: 'name',
inputDebounce: 0,
}, },
create: true, create: true,
}, },
@ -130,6 +147,11 @@ const deleteAcl = async ({ id }) => {
/> />
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
</QDrawer> </QDrawer>
<FetchData
url="VnRoles?fields=['name']"
auto-load
@on-fetch="(data) => (roles = data)"
/>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="AccountAcls" data-key="AccountAcls"

View File

@ -33,6 +33,7 @@ const rolesOptions = ref([]);
:search-button="true" :search-button="true"
:hidden-tags="['search']" :hidden-tags="['search']"
:redirect="false" :redirect="false"
search-url="table"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">

View File

@ -74,7 +74,7 @@ const columns = computed(() => [
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
title: t('View Summary'), title: t('components.smartCard.viewSummary'),
icon: 'preview', icon: 'preview',
action: (row) => viewSummary(row.id, AccountSummary), action: (row) => viewSummary(row.id, AccountSummary),
isPrimary: true, isPrimary: true,

View File

@ -46,13 +46,9 @@ const columns = computed(() => [
]); ]);
const deleteAlias = async (row) => { const deleteAlias = async (row) => {
try { await axios.delete(`${urlPath.value}/${row.id}`);
await axios.delete(`${urlPath.value}/${row.id}`); notify(t('User removed'), 'positive');
notify(t('User removed'), 'positive'); fetchAliases();
fetchAliases();
} catch (error) {
console.error(error);
}
}; };
watch( watch(

View File

@ -61,23 +61,15 @@ const fetchAccountExistence = async () => {
}; };
const deleteMailAlias = async (row) => { const deleteMailAlias = async (row) => {
try { await axios.delete(`${urlPath}/${row.id}`);
await axios.delete(`${urlPath}/${row.id}`); fetchMailAliases();
fetchMailAliases(); notify(t('Unsubscribed from alias!'), 'positive');
notify(t('Unsubscribed from alias!'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const createMailAlias = async (mailAliasFormData) => { const createMailAlias = async (mailAliasFormData) => {
try { await axios.post(urlPath, mailAliasFormData);
await axios.post(urlPath, mailAliasFormData); notify(t('Subscribed to alias!'), 'positive');
notify(t('Subscribed to alias!'), 'positive'); fetchMailAliases();
fetchMailAliases();
} catch (error) {
console.error(error);
}
}; };
const fetchMailAliases = async () => { const fetchMailAliases = async () => {

View File

@ -54,7 +54,7 @@ const columns = computed(() => [
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
title: t('View Summary'), title: t('components.smartCard.viewSummary'),
icon: 'preview', icon: 'preview',
action: (row) => viewSummary(row.id, RoleSummary), action: (row) => viewSummary(row.id, RoleSummary),
isPrimary: true, isPrimary: true,

View File

@ -46,29 +46,15 @@ const columns = computed(() => [
]); ]);
const deleteSubRole = async (row) => { const deleteSubRole = async (row) => {
try { await axios.delete(`${urlPath.value}/${row.id}`);
await axios.delete(`${urlPath.value}/${row.id}`); fetchSubRoles();
fetchSubRoles(); notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive');
notify(
t('Role removed. Changes will take a while to fully propagate.'),
'positive'
);
} catch (error) {
console.error(error);
}
}; };
const createSubRole = async (subRoleFormData) => { const createSubRole = async (subRoleFormData) => {
try { await axios.post(urlPath.value, subRoleFormData);
await axios.post(urlPath.value, subRoleFormData); notify(t('Role added! Changes will take a while to fully propagate.'), 'positive');
notify( fetchSubRoles();
t('Role added! Changes will take a while to fully propagate.'),
'positive'
);
fetchSubRoles();
} catch (error) {
console.error(error);
}
}; };
watch( watch(

View File

@ -204,7 +204,7 @@ function claimUrl(section) {
top top
color="black" color="black"
text-color="white" text-color="white"
:label="t('ticket.summary.changeState')" :label="t('globals.changeState')"
> >
<QList> <QList>
<QVirtualScroll <QVirtualScroll

View File

@ -6,7 +6,7 @@ import { useRoute, useRouter } from 'vue-router';
import { date } from 'quasar'; import { date } from 'quasar';
import { toDateFormat } from 'src/filters/date.js'; import { toDateFormat } from 'src/filters/date.js';
import { toCurrency } from 'src/filters'; import { dashIfEmpty, toCurrency } from 'src/filters';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import TicketSummary from 'src/pages/Ticket/Card/TicketSummary.vue'; import TicketSummary from 'src/pages/Ticket/Card/TicketSummary.vue';
@ -32,6 +32,16 @@ const filter = {
}, },
{ relation: 'invoiceOut', scope: { fields: ['id'] } }, { relation: 'invoiceOut', scope: { fields: ['id'] } },
{ relation: 'agencyMode', scope: { fields: ['name'] } }, { relation: 'agencyMode', scope: { fields: ['name'] } },
{
relation: 'ticketSales',
scope: {
fields: ['id', 'concept', 'itemFk'],
include: { relation: 'item' },
scope: {
fields: ['id', 'name', 'itemPackingTypeFk'],
},
},
},
], ],
where: { clientFk: route.params.id }, where: { clientFk: route.params.id },
order: ['shipped DESC', 'id'], order: ['shipped DESC', 'id'],
@ -87,7 +97,12 @@ const columns = computed(() => [
label: t('Total'), label: t('Total'),
name: 'total', name: 'total',
}, },
{
align: 'left',
name: 'itemPackingTypeFk',
label: t('ticketSale.packaging'),
format: (row) => getItemPackagingType(row.ticketSales),
},
{ {
align: 'right', align: 'right',
label: '', label: '',
@ -135,6 +150,23 @@ const setShippedColor = (date) => {
if (difference == 0) return 'warning'; if (difference == 0) return 'warning';
if (difference < 0) return 'success'; if (difference < 0) return 'success';
}; };
const getItemPackagingType = (ticketSales) => {
if (!ticketSales?.length) return '-';
const packagingTypes = ticketSales.reduce((types, sale) => {
const { itemPackingTypeFk } = sale.item;
if (
!types.includes(itemPackingTypeFk) &&
(itemPackingTypeFk === 'H' || itemPackingTypeFk === 'V')
) {
types.push(itemPackingTypeFk);
}
return types;
}, []);
return dashIfEmpty(packagingTypes.join(', ') || '-');
};
</script> </script>
<template> <template>

View File

@ -168,7 +168,6 @@ const onFilterTravelSelected = (formData, id) => {
v-model="data.isExcludedFromAvailable" v-model="data.isExcludedFromAvailable"
:label="t('entry.basicData.excludedFromAvailable')" :label="t('entry.basicData.excludedFromAvailable')"
/> />
<QCheckbox v-model="data.isRaid" :label="t('entry.basicData.raid')" />
<QCheckbox <QCheckbox
v-if="isAdministrative()" v-if="isAdministrative()"
v-model="data.isBooked" v-model="data.isBooked"

View File

@ -7,7 +7,6 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import useCardDescription from 'src/composables/useCardDescription'; import useCardDescription from 'src/composables/useCardDescription';
import { useState } from 'src/composables/useState';
import { toDate } from 'src/filters'; import { toDate } from 'src/filters';
import { usePrintService } from 'composables/usePrintService'; import { usePrintService } from 'composables/usePrintService';
import { getUrl } from 'src/composables/getUrl'; import { getUrl } from 'src/composables/getUrl';
@ -23,7 +22,6 @@ const $props = defineProps({
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const { openReport } = usePrintService(); const { openReport } = usePrintService();
const state = useState();
const entryDescriptorRef = ref(null); const entryDescriptorRef = ref(null);
const url = ref(); const url = ref();
@ -32,7 +30,14 @@ const entryFilter = {
{ {
relation: 'travel', relation: 'travel',
scope: { scope: {
fields: ['id', 'landed', 'shipped', 'agencyModeFk', 'warehouseOutFk'], fields: [
'id',
'landed',
'shipped',
'agencyModeFk',
'warehouseOutFk',
'daysInForward',
],
include: [ include: [
{ {
relation: 'agency', relation: 'agency',
@ -75,8 +80,6 @@ const data = ref(useCardDescription());
const setData = (entity) => const setData = (entity) =>
(data.value = useCardDescription(entity.supplier?.nickname, entity.id)); (data.value = useCardDescription(entity.supplier?.nickname, entity.id));
const currentEntry = computed(() => state.get('entry'));
const getEntryRedirectionFilter = (entry) => { const getEntryRedirectionFilter = (entry) => {
let entryTravel = entry && entry.travel; let entryTravel = entry && entry.travel;
@ -133,10 +136,10 @@ watch;
:value="entity.travel?.warehouseOut?.name" :value="entity.travel?.warehouseOut?.name"
/> />
</template> </template>
<template #icons> <template #icons="{ entity }">
<QCardActions class="q-gutter-x-md"> <QCardActions class="q-gutter-x-md">
<QIcon <QIcon
v-if="currentEntry?.isExcludedFromAvailable" v-if="entity?.isExcludedFromAvailable"
name="vn:inventory" name="vn:inventory"
color="primary" color="primary"
size="xs" size="xs"
@ -144,12 +147,18 @@ watch;
<QTooltip>{{ t('Inventory entry') }}</QTooltip> <QTooltip>{{ t('Inventory entry') }}</QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="currentEntry?.isRaid" v-if="entity?.travel?.daysInForward"
name="vn:net" name="vn:net"
color="primary" color="primary"
size="xs" size="xs"
> >
<QTooltip>{{ t('Virtual entry') }}</QTooltip> <QTooltip>
{{
t('globals.raid', {
daysInForward: entity?.travel?.daysInForward,
})
}}</QTooltip
>
</QIcon> </QIcon>
</QCardActions> </QCardActions>
</template> </template>

View File

@ -11,6 +11,7 @@ import { toDate, toCurrency } from 'src/filters';
import { getUrl } from 'src/composables/getUrl'; import { getUrl } from 'src/composables/getUrl';
import axios from 'axios'; import axios from 'axios';
import FetchedTags from 'src/components/ui/FetchedTags.vue'; import FetchedTags from 'src/components/ui/FetchedTags.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
@ -163,14 +164,12 @@ const fetchEntryBuys = async () => {
data-key="EntrySummary" data-key="EntrySummary"
> >
<template #header-left> <template #header-left>
<router-link <VnToSummary
v-if="route?.name !== 'EntrySummary'" v-if="route?.name !== 'EntrySummary'"
:to="{ name: 'EntrySummary', params: { id: entityId } }" :route-name="'EntrySummary'"
class="header link" :entity-id="entityId"
:href="entryUrl" :url="entryUrl"
> />
<QIcon name="open_in_new" color="white" size="sm" />
</router-link>
</template> </template>
<template #header> <template #header>
<span>{{ entry.id }} - {{ entry.supplier.nickname }}</span> <span>{{ entry.id }} - {{ entry.supplier.nickname }}</span>
@ -260,11 +259,6 @@ const fetchEntryBuys = async () => {
v-model="entry.isBooked" v-model="entry.isBooked"
:disable="true" :disable="true"
/> />
<QCheckbox
:label="t('entry.summary.raid')"
v-model="entry.isRaid"
:disable="true"
/>
<QCheckbox <QCheckbox
:label="t('entry.summary.excludedFromAvailable')" :label="t('entry.summary.excludedFromAvailable')"
v-model="entry.isExcludedFromAvailable" v-model="entry.isExcludedFromAvailable"

View File

@ -121,7 +121,7 @@ const entriesTableColumns = computed(() => [
:loading="isLoading" :loading="isLoading"
@click=" @click="
openReport( openReport(
`Entries/${props.row.id}/buy-label` `Entries/${props.row.id}/buy-label-supplier`
) )
" "
unelevated unelevated

View File

@ -23,7 +23,6 @@ const columns = [
return { return {
id: row.id, id: row.id,
size: '50x50', size: '50x50',
width: '50px',
}; };
}, },
}, },
@ -34,21 +33,37 @@ const columns = [
label: t('entry.latestBuys.tableVisibleColumns.itemFk'), label: t('entry.latestBuys.tableVisibleColumns.itemFk'),
name: 'itemFk', name: 'itemFk',
isTitle: true, isTitle: true,
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.packing'), label: t('entry.latestBuys.tableVisibleColumns.packing'),
name: 'packing', name: 'packing',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.grouping'), label: t('entry.latestBuys.tableVisibleColumns.grouping'),
name: 'grouping', name: 'grouping',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.quantity'), label: t('entry.latestBuys.tableVisibleColumns.quantity'),
name: 'quantity', name: 'quantity',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -59,6 +74,10 @@ const columns = [
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.size'), label: t('entry.latestBuys.tableVisibleColumns.size'),
name: 'size', name: 'size',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -84,6 +103,10 @@ const columns = [
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.weightByPiece'), label: t('entry.latestBuys.tableVisibleColumns.weightByPiece'),
name: 'weightByPiece', name: 'weightByPiece',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -99,26 +122,46 @@ const columns = [
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.entryFk'), label: t('entry.latestBuys.tableVisibleColumns.entryFk'),
name: 'entryFk', name: 'entryFk',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.buyingValue'), label: t('entry.latestBuys.tableVisibleColumns.buyingValue'),
name: 'buyingValue', name: 'buyingValue',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.freightValue'), label: t('entry.latestBuys.tableVisibleColumns.freightValue'),
name: 'freightValue', name: 'freightValue',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.comissionValue'), label: t('entry.latestBuys.tableVisibleColumns.comissionValue'),
name: 'comissionValue', name: 'comissionValue',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.packageValue'), label: t('entry.latestBuys.tableVisibleColumns.packageValue'),
name: 'packageValue', name: 'packageValue',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -129,16 +172,28 @@ const columns = [
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.price2'), label: t('entry.latestBuys.tableVisibleColumns.price2'),
name: 'price2', name: 'price2',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.price3'), label: t('entry.latestBuys.tableVisibleColumns.price3'),
name: 'price3', name: 'price3',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.minPrice'), label: t('entry.latestBuys.tableVisibleColumns.minPrice'),
name: 'minPrice', name: 'minPrice',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -149,11 +204,19 @@ const columns = [
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.weight'), label: t('entry.latestBuys.tableVisibleColumns.weight'),
name: 'weight', name: 'weight',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
label: t('entry.latestBuys.tableVisibleColumns.packagingFk'), label: t('entry.latestBuys.tableVisibleColumns.packagingFk'),
name: 'packagingFk', name: 'packagingFk',
columnFilter: {
component: 'number',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',

View File

@ -41,6 +41,10 @@ const entryFilter = {
}; };
const columns = computed(() => [ const columns = computed(() => [
{
name: 'status',
columnFilter: false,
},
{ {
align: 'left', align: 'left',
label: t('entry.list.tableVisibleColumns.id'), label: t('entry.list.tableVisibleColumns.id'),
@ -154,27 +158,8 @@ const columns = computed(() => [
cardVisible: true, cardVisible: true,
}, },
{ {
align: 'left',
label: t('entry.list.tableVisibleColumns.isExcludedFromAvailable'), label: t('entry.list.tableVisibleColumns.isExcludedFromAvailable'),
name: 'isExcludedFromAvailable', name: 'isExcludedFromAvailable',
chip: {
color: null,
condition: (value) => value,
icon: 'vn:inventory',
},
columnFilter: {
inWhere: true,
},
},
{
align: 'left',
label: t('entry.list.tableVisibleColumns.isRaid'),
name: 'isRaid',
chip: {
color: null,
condition: (value) => value,
icon: 'vn:net',
},
columnFilter: { columnFilter: {
inWhere: true, inWhere: true,
}, },
@ -225,6 +210,26 @@ onMounted(async () => {
auto-load auto-load
:right-search="false" :right-search="false"
> >
<template #column-status="{ row }">
<div class="row q-gutter-xs">
<QIcon
v-if="!!row.isExcludedFromAvailable"
name="vn:inventory"
color="primary"
>
<QTooltip>{{
t('entry.list.tableVisibleColumns.isExcludedFromAvailable')
}}</QTooltip>
</QIcon>
<QIcon v-if="!!row.daysInForward" name="vn:net" color="primary">
<QTooltip>
{{
t('globals.raid', { daysInForward: row.daysInForward })
}}</QTooltip
>
</QIcon>
</div>
</template>
<template #column-supplierFk="{ row }"> <template #column-supplierFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row.supplierName }} {{ row.supplierName }}

View File

@ -1,7 +1,6 @@
entryList: entryList:
list: list:
inventoryEntry: Inventory entry inventoryEntry: Inventory entry
virtualEntry: Virtual entry
entryFilter: entryFilter:
filter: filter:
search: General search search: General search

View File

@ -4,7 +4,6 @@ You can search by entry reference: Puedes buscar por referencia de la entrada
entryList: entryList:
list: list:
inventoryEntry: Es inventario inventoryEntry: Es inventario
virtualEntry: Es una redada
entryFilter: entryFilter:
filter: filter:
search: Búsqueda general search: Búsqueda general

View File

@ -78,7 +78,7 @@ const ticketsColumns = ref([
align: 'left', align: 'left',
}, },
{ {
name: 'quantity', name: 'nickname',
label: t('invoiceOut.summary.nickname'), label: t('invoiceOut.summary.nickname'),
field: (row) => row.nickname, field: (row) => row.nickname,
sortable: true, sortable: true,
@ -172,11 +172,11 @@ const ticketsColumns = ref([
</QBtn> </QBtn>
</QTd> </QTd>
</template> </template>
<template #body-cell-quantity="{ value, row }"> <template #body-cell-nickname="{ value, row }">
<QTd> <QTd>
<QBtn class="no-uppercase link" flat dense> <QBtn class="no-uppercase link" flat dense>
{{ value }} {{ value }}
<CustomerDescriptorProxy :id="row.id" /> <CustomerDescriptorProxy :id="row.clientFk" />
</QBtn> </QBtn>
</QTd> </QTd>
</template> </template>

View File

@ -63,7 +63,7 @@ const onIntrastatCreated = (response, formData) => {
<template #form="{ data }"> <template #form="{ data }">
<VnRow> <VnRow>
<VnSelect <VnSelect
:label="t('itemBasicData.type')" :label="t('item.basicData.type')"
v-model="data.typeFk" v-model="data.typeFk"
:options="itemTypesOptions" :options="itemTypesOptions"
option-value="id" option-value="id"
@ -82,17 +82,26 @@ const onIntrastatCreated = (response, formData) => {
</QItem> </QItem>
</template> </template>
</VnSelect> </VnSelect>
<VnInput :label="t('itemBasicData.reference')" v-model="data.comment" /> <VnInput :label="t('item.basicData.reference')" v-model="data.comment" />
<VnInput :label="t('itemBasicData.relevancy')" v-model="data.relevancy" />
</VnRow>
<VnRow>
<VnInput :label="t('itemBasicData.stems')" v-model="data.stems" />
<VnInput <VnInput
:label="t('itemBasicData.multiplier')" :label="t('item.basicData.relevancy')"
type="number"
v-model="data.relevancy"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
:label="t('item.basicData.stems')"
type="number"
v-model="data.stems"
/>
<VnInput
:label="t('item.basicData.multiplier')"
type="number"
v-model="data.stemMultiplier" v-model="data.stemMultiplier"
/> />
<VnSelectDialog <VnSelectDialog
:label="t('itemBasicData.generic')" :label="t('item.basicData.generic')"
v-model="data.genericFk" v-model="data.genericFk"
url="Items/withName" url="Items/withName"
:fields="['id', 'name']" :fields="['id', 'name']"
@ -121,7 +130,7 @@ const onIntrastatCreated = (response, formData) => {
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelectDialog <VnSelectDialog
:label="t('itemBasicData.intrastat')" :label="t('item.basicData.intrastat')"
v-model="data.intrastatFk" v-model="data.intrastatFk"
:options="intrastatsOptions" :options="intrastatsOptions"
option-value="id" option-value="id"
@ -148,7 +157,7 @@ const onIntrastatCreated = (response, formData) => {
</VnSelectDialog> </VnSelectDialog>
<div class="col"> <div class="col">
<VnSelect <VnSelect
:label="t('itemBasicData.expense')" :label="t('item.basicData.expense')"
v-model="data.expenseFk" v-model="data.expenseFk"
:options="expensesOptions" :options="expensesOptions"
option-value="id" option-value="id"
@ -160,64 +169,67 @@ const onIntrastatCreated = (response, formData) => {
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnInput <VnInput
:label="t('itemBasicData.weightByPiece')" :label="t('item.basicData.weightByPiece')"
v-model.number="data.weightByPiece" v-model.number="data.weightByPiece"
:min="0" :min="0"
type="number" type="number"
/> />
<VnInput <VnInput
:label="t('itemBasicData.boxUnits')" :label="t('item.basicData.boxUnits')"
v-model.number="data.packingOut" v-model.number="data.packingOut"
:min="0" :min="0"
type="number" type="number"
/> />
<VnInput <VnInput
:label="t('itemBasicData.recycledPlastic')" :label="t('item.basicData.recycledPlastic')"
v-model.number="data.recycledPlastic" v-model.number="data.recycledPlastic"
:min="0" :min="0"
type="number" type="number"
/> />
<VnInput <VnInput
:label="t('itemBasicData.nonRecycledPlastic')" :label="t('item.basicData.nonRecycledPlastic')"
v-model.number="data.nonRecycledPlastic" v-model.number="data.nonRecycledPlastic"
:min="0" :min="0"
type="number" type="number"
/> />
</VnRow> </VnRow>
<VnRow> <VnRow class="row q-gutter-md q-mb-md">
<QCheckbox v-model="data.isActive" :label="t('itemBasicData.isActive')" /> <QCheckbox
v-model="data.isActive"
:label="t('item.basicData.isActive')"
/>
<QCheckbox <QCheckbox
v-model="data.hasKgPrice" v-model="data.hasKgPrice"
:label="t('itemBasicData.hasKgPrice')" :label="t('item.basicData.hasKgPrice')"
/> />
<div> <div>
<QCheckbox <QCheckbox
v-model="data.isFragile" v-model="data.isFragile"
:label="t('itemBasicData.isFragile')" :label="t('item.basicData.isFragile')"
class="q-mr-sm" class="q-mr-sm"
/> />
<QIcon name="info" class="cursor-pointer" size="xs"> <QIcon name="info" class="cursor-pointer" size="xs">
<QTooltip max-width="300px"> <QTooltip max-width="300px">
{{ t('itemBasicData.isFragileTooltip') }} {{ t('item.basicData.isFragileTooltip') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
</div> </div>
<div> <div>
<QCheckbox <QCheckbox
v-model="data.isPhotoRequested" v-model="data.isPhotoRequested"
:label="t('itemBasicData.isPhotoRequested')" :label="t('item.basicData.isPhotoRequested')"
class="q-mr-sm" class="q-mr-sm"
/> />
<QIcon name="info" class="cursor-pointer" size="xs"> <QIcon name="info" class="cursor-pointer" size="xs">
<QTooltip> <QTooltip>
{{ t('itemBasicData.isPhotoRequestedTooltip') }} {{ t('item.basicData.isPhotoRequestedTooltip') }}
</QTooltip> </QTooltip>
</QIcon> </QIcon>
</div> </div>
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnInput <VnInput
:label="t('itemBasicData.description')" :label="t('item.basicData.description')"
type="textarea" type="textarea"
v-model="data.description" v-model="data.description"
fill-input fill-input

View File

@ -20,12 +20,6 @@ let itemBotanicalsForm = reactive({ itemFk: null });
const entityId = computed(() => { const entityId = computed(() => {
return route.params.id; return route.params.id;
}); });
onMounted(async () => {
itemBotanicalsForm.itemFk = entityId.value;
itemBotanicals.value = await itemBotanicalsRef.value.fetch();
if (itemBotanicals.value.length > 0)
Object.assign(itemBotanicalsForm, itemBotanicals.value[0]);
});
</script> </script>
<template> <template>
<FetchData <FetchData
@ -37,11 +31,14 @@ onMounted(async () => {
@on-fetch="(data) => (itemBotanicals = data)" @on-fetch="(data) => (itemBotanicals = data)"
/> />
<FormModel <FormModel
url="ItemBotanicals"
url-update="ItemBotanicals" url-update="ItemBotanicals"
model="entry" model="item"
auto-load auto-load
:form-initial-data="itemBotanicalsForm" :filter="{
:clear-store-on-unmount="false" where: { itemFk: entityId },
}"
@on-fetch="(data) => (itemBotanicalsForm = data)"
> >
<template #form="{ data }"> <template #form="{ data }">
<VnRow> <VnRow>

View File

@ -1,18 +1,18 @@
<script setup> <script setup>
import { computed, ref, onMounted } from 'vue'; import { computed, ref, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import CardDescriptor from 'src/components/ui/CardDescriptor.vue'; import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import VnConfirm from 'components/ui/VnConfirm.vue';
import RegularizeStockForm from 'components/RegularizeStockForm.vue'; import RegularizeStockForm from 'components/RegularizeStockForm.vue';
import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue'; import ItemDescriptorImage from 'src/pages/Item/Card/ItemDescriptorImage.vue';
import useCardDescription from 'src/composables/useCardDescription'; import useCardDescription from 'src/composables/useCardDescription';
import axios from 'axios'; import axios from 'axios';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import { useArrayData } from 'src/composables/useArrayData';
import { cloneItem } from 'src/pages/Item/composables/cloneItem';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -38,9 +38,8 @@ const $props = defineProps({
}, },
}); });
const quasar = useQuasar(); const { openCloneDialog } = cloneItem();
const route = useRoute(); const route = useRoute();
const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const warehouseConfig = ref(null); const warehouseConfig = ref(null);
const entityId = computed(() => { const entityId = computed(() => {
@ -48,84 +47,52 @@ const entityId = computed(() => {
}); });
const regularizeStockFormDialog = ref(null); const regularizeStockFormDialog = ref(null);
const available = ref(null); const mounted = ref();
const visible = ref(null);
const arrayDataStock = useArrayData('descriptorStock', {
url: `Items/${entityId.value}/getVisibleAvailable`,
});
onMounted(async () => { onMounted(async () => {
await getItemConfigs(); await getItemConfigs();
await updateStock(); mounted.value = true;
}); });
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = async (entity) => { const setData = async (entity) => {
try { if (!entity) return;
if (!entity) return; data.value = useCardDescription(entity.name, entity.id);
data.value = useCardDescription(entity.name, entity.id); await updateStock();
await updateStock();
} catch (err) {
console.error('Error item');
}
}; };
const getItemConfigs = async () => { const getItemConfigs = async () => {
try { const { data } = await axios.get('ItemConfigs/findOne');
const { data } = await axios.get('ItemConfigs/findOne'); if (!data) return;
if (!data) return; return (warehouseConfig.value = data.warehouseFk);
return (warehouseConfig.value = data.warehouseFk);
} catch (err) {
console.error('Error item');
}
}; };
const updateStock = async () => { const updateStock = async () => {
try { if (!mounted.value) return;
available.value = null; await getItemConfigs();
visible.value = null;
const params = { const params = {
warehouseFk: $props.warehouseFk, warehouseFk: $props.warehouseFk ?? warehouseConfig.value,
dated: $props.dated, dated: $props.dated,
}; };
await getItemConfigs(); if (!params.warehouseFk) return;
if (!params.warehouseFk) {
params.warehouseFk = warehouseConfig.value; const stock = useArrayData('descriptorStock', {
} url: `Items/${entityId.value}/getVisibleAvailable`,
const { data } = await axios.get(`Items/${entityId.value}/getVisibleAvailable`, { userParams: params,
params, });
}); const storeData = stock.store.data;
available.value = data.available; if (storeData?.itemFk == entityId.value) return;
visible.value = data.visible; await stock.fetch({});
} catch (err) {
console.error('Error updating stock');
}
}; };
const openRegularizeStockForm = () => { const openRegularizeStockForm = () => {
regularizeStockFormDialog.value.show(); regularizeStockFormDialog.value.show();
}; };
const cloneItem = async () => {
try {
const { data } = await axios.post(`Items/${entityId.value}/clone`);
router.push({ name: 'ItemTags', params: { id: data.id } });
} catch (err) {
console.error('Error cloning item');
}
};
const openCloneDialog = async () => {
quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('All its properties will be copied'),
message: t('Do you want to clone this item?'),
},
})
.onOk(async () => {
await cloneItem();
});
};
</script> </script>
<template> <template>
@ -151,7 +118,7 @@ const openCloneDialog = async () => {
</QDialog> </QDialog>
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem v-ripple clickable @click="openCloneDialog()"> <QItem v-ripple clickable @click="openCloneDialog(entityId)">
<QItemSection> <QItemSection>
{{ t('globals.clone') }} {{ t('globals.clone') }}
</QItemSection> </QItemSection>
@ -160,8 +127,8 @@ const openCloneDialog = async () => {
<template #before> <template #before>
<ItemDescriptorImage <ItemDescriptorImage
:entity-id="entityId" :entity-id="entityId"
:visible="visible" :visible="arrayDataStock.store.data?.visible"
:available="available" :available="arrayDataStock.store.data?.available"
/> />
</template> </template>
<template #body="{ entity }"> <template #body="{ entity }">
@ -194,6 +161,18 @@ const openCloneDialog = async () => {
:value="entity.value7" :value="entity.value7"
/> />
</template> </template>
<template #icons="{ entity }">
<QCardActions v-if="entity" class="q-gutter-x-md">
<QIcon
v-if="!entity.isActive"
name="vn:unavailable"
color="primary"
size="xs"
>
<QTooltip>{{ t('Inactive article') }}</QTooltip>
</QIcon>
</QCardActions>
</template>
<template #actions="{}"> <template #actions="{}">
<QCardActions class="row justify-center"> <QCardActions class="row justify-center">
<QBtn <QBtn
@ -216,8 +195,7 @@ const openCloneDialog = async () => {
<i18n> <i18n>
es: es:
Regularize stock: Regularizar stock Regularize stock: Regularizar stock
All its properties will be copied: Todas sus propiedades serán copiadas Inactive article: Artículo inactivo
Do you want to clone this item?: ¿Desea clonar este artículo?
</i18n> </i18n>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -32,6 +32,10 @@ const editPhotoFormDialog = ref(null);
const showEditPhotoForm = ref(false); const showEditPhotoForm = ref(false);
const warehouseName = ref(null); const warehouseName = ref(null);
onMounted(async () => {
getItemConfigs();
});
const toggleEditPictureForm = () => { const toggleEditPictureForm = () => {
showEditPhotoForm.value = !showEditPhotoForm.value; showEditPhotoForm.value = !showEditPhotoForm.value;
}; };
@ -56,10 +60,6 @@ const getWarehouseName = async (warehouseFk) => {
warehouseName.value = data.name; warehouseName.value = data.name;
}; };
onMounted(async () => {
getItemConfigs();
});
const handlePhotoUpdated = (evt = false) => { const handlePhotoUpdated = (evt = false) => {
image.value.reload(evt); image.value.reload(evt);
}; };
@ -134,10 +134,10 @@ es:
Regularize stock: Regularizar stock Regularize stock: Regularizar stock
All it's properties will be copied: Todas sus propiedades serán copiadas All it's properties will be copied: Todas sus propiedades serán copiadas
Do you want to clone this item?: ¿Desea clonar este artículo? Do you want to clone this item?: ¿Desea clonar este artículo?
warehouseText: Calculated on the warehouse of { warehouseName } warehouseText: Calculado sobre el almacén de { warehouseName }
en: en:
warehouseText: Calculado sobre el almacén de { warehouseName } warehouseText: Calculated on the warehouse of { warehouseName }
</i18n> </i18n>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -17,6 +17,7 @@ import { toDateFormat } from 'src/filters/date.js';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import { date } from 'quasar'; import { date } from 'quasar';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useArrayData } from 'src/composables/useArrayData';
import axios from 'axios'; import axios from 'axios';
const { t } = useI18n(); const { t } = useI18n();
@ -37,6 +38,33 @@ const warehouseFk = ref(null);
const _showWhatsBeforeInventory = ref(false); const _showWhatsBeforeInventory = ref(false);
const inventoriedDate = ref(null); const inventoriedDate = ref(null);
const originTypeMap = {
entry: {
descriptor: EntryDescriptorProxy,
icon: 'vn:entry',
color: 'green',
},
ticket: {
descriptor: TicketDescriptorProxy,
icon: 'vn:ticket',
color: 'red',
},
order: {
descriptor: OrderDescriptorProxy,
icon: 'vn:basket',
color: 'yellow',
},
};
const entityTypeMap = {
client: {
descriptor: CustomerDescriptorProxy,
},
supplier: {
descriptor: SupplierDescriptorProxy,
},
};
const columns = computed(() => [ const columns = computed(() => [
{ {
name: 'claim', name: 'claim',
@ -105,6 +133,28 @@ const showWhatsBeforeInventory = computed({
}, },
}); });
onMounted(async () => {
today.value.setHours(0, 0, 0, 0);
if (route.query.warehouseFk) warehouseFk.value = route.query.warehouseFk;
else if (user.value) warehouseFk.value = user.value.warehouseFk;
itemsBalanceFilter.where.warehouseFk = warehouseFk.value;
const { data } = await axios.get('Configs/findOne');
inventoriedDate.value = data.inventoried;
await fetchItemBalances();
await scrollToToday();
await updateWarehouse(warehouseFk.value);
});
onUnmounted(() => (stateStore.rightDrawer = false));
watch(
() => router.currentRoute.value.params.id,
(newId) => {
itemsBalanceFilter.where.itemFk = newId;
itemBalancesRef.value.fetch();
}
);
const fetchItemBalances = async () => await itemBalancesRef.value.fetch(); const fetchItemBalances = async () => await itemBalancesRef.value.fetch();
const getBadgeAttrs = (_date) => { const getBadgeAttrs = (_date) => {
@ -131,53 +181,15 @@ const formatDateForAttribute = (dateValue) => {
return dateValue; return dateValue;
}; };
const originTypeMap = { async function updateWarehouse(warehouseFk) {
entry: { const stock = useArrayData('descriptorStock', {
descriptor: EntryDescriptorProxy, userParams: {
icon: 'vn:entry', warehouseFk,
color: 'green', },
}, });
ticket: { await stock.fetch({});
descriptor: TicketDescriptorProxy, stock.store.data.itemFk = route.params.id;
icon: 'vn:ticket', }
color: 'red',
},
order: {
descriptor: OrderDescriptorProxy,
icon: 'vn:basket',
color: 'yellow',
},
};
const entityTypeMap = {
client: {
descriptor: CustomerDescriptorProxy,
},
supplier: {
descriptor: SupplierDescriptorProxy,
},
};
onMounted(async () => {
today.value.setHours(0, 0, 0, 0);
if (route.query.warehouseFk) warehouseFk.value = route.query.warehouseFk;
else if (user.value) warehouseFk.value = user.value.warehouseFk;
itemsBalanceFilter.where.warehouseFk = warehouseFk.value;
const { data } = await axios.get('Configs/findOne');
inventoriedDate.value = data.inventoried;
await fetchItemBalances();
await scrollToToday();
});
onUnmounted(() => (stateStore.rightDrawer = false));
watch(
() => router.currentRoute.value.params.id,
(newId) => {
itemsBalanceFilter.where.itemFk = newId;
itemBalancesRef.value.fetch();
}
);
</script> </script>
<template> <template>
@ -193,36 +205,39 @@ watch(
auto-load auto-load
@on-fetch="(data) => (warehousesOptions = data)" @on-fetch="(data) => (warehousesOptions = data)"
/> />
<QToolbar class="justify-end"> <template v-if="stateStore.isHeaderMounted()">
<div id="st-data" class="row"> <Teleport to="#st-data">
<VnSelect <div class="row">
:label="t('itemDiary.warehouse')" <VnSelect
:options="warehousesOptions" :label="t('itemDiary.warehouse')"
hide-selected :options="warehousesOptions"
option-label="name" hide-selected
option-value="id" option-label="name"
dense option-value="id"
v-model="itemsBalanceFilter.where.warehouseFk" dense
@update:model-value="fetchItemBalances" v-model="itemsBalanceFilter.where.warehouseFk"
class="q-mr-lg" @update:model-value="
/> (value) => fetchItemBalances() && updateWarehouse(value)
<QCheckbox "
:label="t('itemDiary.showBefore')" class="q-mr-lg"
v-model="showWhatsBeforeInventory" />
@update:model-value="fetchItemBalances" <QCheckbox
class="q-mr-lg" :label="t('itemDiary.showBefore')"
/> v-model="showWhatsBeforeInventory"
<VnInputDate @update:model-value="fetchItemBalances"
v-if="showWhatsBeforeInventory" class="q-mr-lg"
:label="t('itemDiary.since')" />
dense <VnInputDate
v-model="itemsBalanceFilter.where.date" v-if="showWhatsBeforeInventory"
@update:model-value="fetchItemBalances" :label="t('itemDiary.since')"
/> dense
</div> v-model="itemsBalanceFilter.where.date"
<QSpace /> @update:model-value="fetchItemBalances"
<div id="st-actions"></div> />
</QToolbar> </div>
</Teleport>
<Teleport to="#st-actions"> </Teleport>
</template>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<QTable <QTable
:rows="itemBalances" :rows="itemBalances"

View File

@ -119,7 +119,7 @@ const getUrl = (id, param) => `#/Item/${id}/${param}`;
<VnLv <VnLv
v-for="(tag, index) in tags" v-for="(tag, index) in tags"
:key="index" :key="index"
:label="`${tag.priority} ${tag.tag.name}`" :label="`${tag.priority} ${tag.tag.name}:`"
:value="tag.value" :value="tag.value"
/> />
</QCard> </QCard>
@ -135,7 +135,7 @@ const getUrl = (id, param) => `#/Item/${id}/${param}`;
<VnLv <VnLv
v-for="(tax, index) in item.taxes" v-for="(tax, index) in item.taxes"
:key="index" :key="index"
:label="tax.country.country" :label="tax.country.name"
:value="tax.taxClass.description" :value="tax.taxClass.description"
/> />
</QCard> </QCard>
@ -155,7 +155,8 @@ const getUrl = (id, param) => `#/Item/${id}/${param}`;
:url="getUrl(entityId, 'barcode')" :url="getUrl(entityId, 'barcode')"
:text="t('item.summary.barcode')" :text="t('item.summary.barcode')"
/> />
<p <div
class="text-bold"
v-for="(barcode, index) in item.itemBarcode" v-for="(barcode, index) in item.itemBarcode"
:key="index" :key="index"
v-text="barcode.code" v-text="barcode.code"

View File

@ -22,7 +22,7 @@ const taxesFilter = {
{ {
relation: 'country', relation: 'country',
scope: { scope: {
fields: ['country'], fields: ['name'],
}, },
}, },
], ],
@ -73,7 +73,7 @@ const submitTaxes = async (data) => {
> >
<VnInput <VnInput
:label="t('tax.country')" :label="t('tax.country')"
v-model="row.country.country" v-model="row.country.name"
disable disable
/> />
<VnSelect <VnSelect

View File

@ -1,584 +1,369 @@
<script setup> <script setup>
import { onMounted, ref, computed, reactive, onUnmounted } from 'vue'; import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRoute } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import TableVisibleColumns from 'src/components/common/TableVisibleColumns.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import ItemDescriptorProxy from '../Item/Card/ItemDescriptorProxy.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import ItemSummary from '../Item/Card/ItemSummary.vue';
import VnPaginate from 'components/ui/VnPaginate.vue';
import ItemListFilter from './ItemListFilter.vue';
import { useStateStore } from 'stores/useStateStore';
import { toDateFormat } from 'src/filters/date.js';
import { dashIfEmpty } from 'src/filters';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useVnConfirm } from 'composables/useVnConfirm';
import axios from 'axios';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnImg from 'src/components/ui/VnImg.vue'; import VnImg from 'src/components/ui/VnImg.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import { toDate } from 'src/filters';
import FetchedTags from 'src/components/ui/FetchedTags.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import ItemSummary from '../Item/Card/ItemSummary.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import ItemDescriptorProxy from './Card/ItemDescriptorProxy.vue';
import { cloneItem } from 'src/pages/Item/composables/cloneItem';
const router = useRouter(); const entityId = computed(() => route.params.id);
const stateStore = useStateStore(); const { openCloneDialog } = cloneItem();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
const { openConfirmationModal } = useVnConfirm(); const { t } = useI18n();
const tableRef = ref();
const route = useRoute();
const paginateRef = ref(null); const itemFilter = {
const itemTypesOptions = ref([]); include: [
const originsOptions = ref([]); {
const buyersOptions = ref([]); relation: 'itemType',
const intrastatOptions = ref([]); scope: {
const itemCategoriesOptions = ref([]); fields: ['id', 'name'],
const visibleColumns = ref([]); },
const allColumnNames = ref([]); },
{
const exprBuilder = (param, value) => { relation: 'intrastat',
switch (param) { scope: {
case 'category': fields: ['id', 'description'],
return { 'ic.name': value }; },
case 'buyerFk': },
return { 'it.workerFk': value }; {
case 'grouping': relation: 'origin',
return { 'b.grouping': value }; scope: {
case 'packing': fields: ['id', 'name'],
return { 'b.packing': value }; },
case 'origin': },
return { 'ori.code': value }; {
case 'typeFk': relation: 'production',
return { 'i.typeFk': value }; scope: {
case 'intrastat': fields: ['id', 'name'],
return { 'intr.description': value }; },
case 'name': },
return { 'i.name': { like: `%${value}%` } }; ],
case 'producer':
return { 'pr.name': { like: `%${value}%` } };
case 'id':
case 'size':
case 'subname':
case 'isActive':
case 'weightByPiece':
case 'stemMultiplier':
case 'stems':
return { [`i.${param}`]: value };
}
}; };
const params = reactive({ isFloramondo: false, isActive: true });
const applyColumnFilter = async (col) => {
try {
const paramKey = col.columnFilter?.filterParamKey || col.field;
params[paramKey] = col.columnFilter.filterValue;
await paginateRef.value.addFilter(null, params);
} catch (err) {
console.error('Error applying column filter', err);
}
};
const getInputEvents = (col) => {
return col.columnFilter.type === 'select'
? { 'update:modelValue': () => applyColumnFilter(col) }
: {
'keyup.enter': () => applyColumnFilter(col),
};
};
const columns = computed(() => [ const columns = computed(() => [
{ {
label: '', label: '',
name: 'picture', name: 'image',
align: 'left', align: 'left',
columnFilter: null, columnField: {
component: VnImg,
attrs: ({ row }) => {
return {
id: row?.id,
zoomResolution: '1600x900',
zoom: true,
class: 'rounded',
};
},
},
columnFilter: false,
cardVisible: true,
}, },
{ {
label: t('item.list.id'), label: t('item.list.id'),
name: 'id', name: 'id',
field: 'id',
align: 'left', align: 'left',
sortable: true, isId: true,
columnFilter: { chip: {
component: VnInput, condition: () => true,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
cardVisible: true,
}, },
{ {
label: t('item.list.grouping'), label: t('item.list.grouping'),
field: 'grouping',
name: 'grouping', name: 'grouping',
align: 'left', align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, component: 'number',
type: 'text', inWhere: true,
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
format: (val) => dashIfEmpty(val),
}, },
{ {
label: t('item.list.packing'), label: t('item.list.packing'),
field: 'packing',
name: 'packing', name: 'packing',
align: 'left', align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, component: 'number',
type: 'text', inWhere: true,
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
format: (val) => dashIfEmpty(val),
}, },
{ {
label: t('globals.description'), label: t('globals.description'),
field: 'name',
name: 'description', name: 'description',
align: 'left', align: 'left',
sortable: true, create: true,
columnFilter: { columnFilter: {
component: VnInput, name: 'search',
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
cardVisible: true,
}, },
{ {
label: t('item.list.stems'), label: t('item.list.stems'),
field: 'stems',
name: 'stems', name: 'stems',
align: 'left', align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, component: 'number',
type: 'text', inWhere: true,
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
cardVisible: true,
}, },
{ {
label: t('item.list.size'), label: t('item.list.size'),
field: 'size',
name: 'size', name: 'size',
align: 'left', align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnInput, component: 'number',
type: 'text', inWhere: true,
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
}, },
cardVisible: true,
}, },
{ {
label: t('item.list.typeName'), label: t('item.list.typeName'),
field: 'typeName', name: 'typeFk',
name: 'typeName',
align: 'left', align: 'left',
sortable: true, component: 'select',
attrs: {
url: 'ItemTypes',
fields: ['id', 'name'],
},
columnFilter: { columnFilter: {
component: VnSelect, name: 'typeFk',
filterParamKey: 'typeFk',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: itemTypesOptions.value, url: 'ItemTypes',
'option-value': 'id', fields: ['id', 'name'],
'option-label': 'name',
dense: true,
}, },
}, },
columnField: {
component: null,
},
create: true,
}, },
{ {
label: t('item.list.category'), label: t('item.list.category'),
field: 'category',
name: 'category', name: 'category',
align: 'left', align: 'left',
sortable: true, component: 'select',
columnFilter: { columnFilter: {
component: VnSelect, name: 'categoryFk',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: itemCategoriesOptions.value, url: 'ItemCategories',
'option-value': 'name', fields: ['id', 'name'],
'option-label': 'name',
dense: true,
}, },
}, },
columnField: {
component: null,
},
}, },
{ {
label: t('item.list.intrastat'), label: t('item.list.intrastat'),
field: 'intrastat',
name: 'intrastat', name: 'intrastat',
align: 'left', align: 'left',
sortable: true, component: 'select',
columnFilter: { columnFilter: {
component: VnSelect, name: 'intrastat',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: intrastatOptions.value, url: 'Intrastats',
'option-value': 'description', optionValue: 'description',
'option-label': 'description', optionLabel: 'description',
dense: true,
}, },
}, },
columnField: {
component: null,
},
create: true,
cardVisible: true,
}, },
{ {
label: t('item.list.origin'), label: t('item.list.origin'),
field: 'origin',
name: 'origin', name: 'origin',
align: 'left', align: 'left',
sortable: true, component: 'select',
columnFilter: { attrs: {
component: VnSelect, url: 'Origins',
type: 'select', optionValue: 'id',
filterValue: null, optionLabel: 'code',
event: getInputEvents,
attrs: {
options: originsOptions.value,
'option-value': 'code',
'option-label': 'code',
dense: true,
},
}, },
columnFilter: {
name: 'id',
attrs: {
url: 'Origins',
optionValue: 'id',
optionLabel: 'code',
},
inWhere: true,
alias: 'ori',
},
columnField: {
component: null,
},
create: true,
cardVisible: true,
}, },
{ {
label: t('item.list.userName'), label: t('item.list.userName'),
field: 'userName',
name: 'userName', name: 'userName',
align: 'left', align: 'left',
sortable: true, component: 'select',
columnFilter: { columnFilter: {
component: VnSelect, name: 'workerFk',
filterParamKey: 'buyerFk',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: buyersOptions.value, url: 'VnUsers/preview',
'option-value': 'id', optionValue: 'id',
'option-label': 'nickname', optionLabel: 'nickname',
dense: true,
}, },
}, },
columnField: {
component: null,
},
}, },
{ {
label: t('item.list.weightByPiece'), label: t('item.list.weightByPiece'),
field: 'weightByPiece',
name: 'weightByPiece', name: 'weightByPiece',
align: 'left', align: 'left',
sortable: true, component: 'input',
columnFilter: { columnField: {
component: VnInput, component: null,
type: 'text', },
filterValue: null, columnFilter: {
event: getInputEvents, inWhere: true,
attrs: {
dense: true,
},
}, },
format: (val) => dashIfEmpty(val),
}, },
{ {
label: t('item.list.stemMultiplier'), label: t('item.list.stemMultiplier'),
field: 'stemMultiplier',
name: 'stemMultiplier', name: 'stemMultiplier',
align: 'left', align: 'left',
sortable: true, component: 'input',
columnFilter: { columnField: {
component: VnInput, component: null,
type: 'text', },
filterValue: null, columnFilter: {
event: getInputEvents, inWhere: true,
attrs: {
dense: true,
},
}, },
format: (val) => dashIfEmpty(val),
}, },
{ {
label: t('item.list.isActive'), label: t('item.list.isActive'),
field: 'isActive',
name: 'isActive', name: 'isActive',
align: 'left', align: 'center',
sortable: true, component: 'checkbox',
columnFilter: null,
}, },
{ {
label: t('item.list.producer'), label: t('item.list.producer'),
field: 'producer',
name: 'producer', name: 'producer',
align: 'left', align: 'left',
sortable: true, component: 'select',
columnFilter: { columnFilter: {
component: VnInput, name: 'producerFk',
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
dense: true, url: 'Producers',
optionValue: 'id',
optionLabel: 'name',
}, },
}, },
format: (val) => dashIfEmpty(val), columnField: {
component: null,
},
}, },
{ {
label: t('item.list.landed'), label: t('item.list.landed'),
field: 'landed',
name: 'landed', name: 'landed',
align: 'left', align: 'left',
sortable: true, component: 'date',
format: (val) => dashIfEmpty(toDateFormat(val)), columnField: {
columnFilter: null, component: null,
},
format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.landed)),
}, },
{ {
align: 'right',
label: '', label: '',
name: 'actions', name: 'tableActions',
align: 'left', actions: [
columnFilter: null, {
title: t('globals.clone'),
icon: 'vn:clone',
action: openCloneDialog,
isPrimary: true,
},
{
title: t('components.smartCard.viewSummary'),
icon: 'preview',
action: (row) => viewSummary(row.id, ItemSummary),
isPrimary: true,
},
],
}, },
]); ]);
const redirectToItemCreate = () => {
router.push({ name: 'ItemCreate' });
};
const redirectToItemSummary = (id) => {
router.push({ name: 'ItemSummary', params: { id } });
};
const cloneItem = async (itemFk) => {
try {
const { data } = await axios.post(`Items/${itemFk}/clone`);
if (!data) return;
router.push({ name: 'ItemTags', params: { id: data.id } });
} catch (err) {
console.error('Error cloning item', err);
}
};
onMounted(async () => {
stateStore.rightDrawer = true;
const filteredColumns = columns.value.filter(
(col) => col.name !== 'picture' && col.name !== 'actions'
);
allColumnNames.value = filteredColumns.map((col) => col.name);
});
onUnmounted(() => (stateStore.rightDrawer = false));
</script> </script>
<template> <template>
<FetchData <VnSearchbar
url="ItemTypes" data-key="ItemList"
:filter="{ fields: ['id', 'name'], order: 'name ASC' }" :label="t('item.searchbar.label')"
auto-load :info="t('You can search by id')"
@on-fetch="(data) => (itemTypesOptions = data)"
/> />
<FetchData <VnTable
url="ItemCategories" ref="tableRef"
:filter="{ fields: ['name'], order: 'name ASC' }" data-key="ItemList"
url="Items/filter"
url-create="Items"
:create="{
urlCreate: 'Items',
title: t('Create Item'),
onDataSaved: () => tableRef.redirect(),
formInitialData: {
editorFk: entityId,
},
}"
:order="['isActive DESC', 'name', 'id']"
:columns="columns"
auto-load auto-load
@on-fetch="(data) => (itemCategoriesOptions = data)" redirect="Item"
/> :is-editable="false"
<FetchData :filer="itemFilter"
url="Intrastats" >
:filter="{ fields: ['description'], order: 'description ASC' }" <template #column-id="{ row }">
auto-load <span class="link" @click.stop>
@on-fetch="(data) => (intrastatOptions = data)" {{ row.id }}
/> <ItemDescriptorProxy :id="row.id" />
<FetchData </span>
url="Origins"
:filter="{ fields: ['code'], order: 'code ASC' }"
auto-load
@on-fetch="(data) => (originsOptions = data)"
/>
<FetchData
url="TicketRequests/getItemTypeWorker"
:filter="{ fields: ['id', 'nickname'], order: 'nickname ASC' }"
auto-load
@on-fetch="(data) => (buyersOptions = data)"
/>
<VnSubToolbar>
<template #st-data>
<TableVisibleColumns
:all-columns="allColumnNames"
table-code="itemsIndex"
labels-traductions-path="item.list"
@on-config-saved="visibleColumns = ['picture', ...$event, 'actions']"
/>
</template> </template>
</VnSubToolbar> <template #column-userName="{ row }">
<RightMenu> <span class="link" @click.stop>
<template #right-panel> {{ row.userName }}
<ItemListFilter data-key="ItemList" /> <WorkerDescriptorProxy :id="row.workerFk" />
</span>
</template> </template>
</RightMenu> <template #column-description="{ row }">
<QPage class="column items-center q-pa-md"> <div class="row column full-width justify-between items-start">
<VnPaginate {{ row?.name }}
ref="paginateRef" <div v-if="row?.subName" class="subName">
data-key="ItemList" {{ row?.subName.toUpperCase() }}
url="Items/filter" </div>
:order="['isActive DESC', 'name', 'id']" </div>
:limit="12" <FetchedTags :item="row" :max-length="6" />
:expr-builder="exprBuilder" </template>
:user-params="params" </VnTable>
:keep-opts="['userParams']"
:offset="50"
auto-load
>
<template #body="{ rows }">
<QTable
:rows="rows"
:columns="columns"
row-key="id"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
:visible-columns="visibleColumns"
:no-data-label="t('globals.noResults')"
@row-click="(_, row) => redirectToItemSummary(row.id)"
>
<template #top-row="{ cols }">
<QTr>
<QTd
v-for="(col, index) in cols"
:key="index"
style="max-width: 100px"
>
<component
:is="col.columnFilter.component"
v-if="col.columnFilter"
v-model="col.columnFilter.filterValue"
v-bind="col.columnFilter.attrs"
v-on="col.columnFilter.event(col)"
dense
/>
</QTd>
</QTr>
</template>
<template #body-cell-picture="{ row }">
<QTd>
<VnImg
size="50x50"
zoom-resolution="1600x900"
:id="row.id"
class="image"
/>
</QTd>
</template>
<template #body-cell-id="{ row }">
<QTd @click.stop>
<QBtn flat color="primary">
{{ row.id }}
</QBtn>
<ItemDescriptorProxy :id="row.id" />
</QTd>
</template>
<template #body-cell-userName="{ row }">
<QTd @click.stop>
<QBtn flat color="primary" dense>
{{ row.userName }}
</QBtn>
<WorkerDescriptorProxy :id="row.buyerFk" />
</QTd>
</template>
<template #body-cell-description="{ row }">
<QTd class="col">
<span>{{ row.name }} {{ row.subName }}</span>
<FetchedTags :item="row" />
</QTd>
</template>
<template #body-cell-isActive="{ row }">
<QTd>
<QCheckbox :model-value="!!row.isActive" disable />
</QTd>
</template>
<template #body-cell-actions="{ row }">
<QTd>
<QIcon
@click.stop="
openConfirmationModal(
t(`All it's properties will be copied`),
t('Do you want to clone this item?'),
() => cloneItem(row.id)
)
"
class="q-ml-sm"
color="primary"
name="vn:clone"
size="sm"
>
<QTooltip>
{{ t('globals.clone') }}
</QTooltip>
</QIcon>
<QIcon
@click.stop="viewSummary(row.id, ItemSummary)"
class="q-ml-md"
color="primary"
name="preview"
size="sm"
>
<QTooltip class="text-no-wrap">
{{ t('Preview') }}
</QTooltip>
</QIcon>
</QTd>
</template>
</QTable>
</template>
</VnPaginate>
<QPageSticky :offset="[20, 20]">
<QBtn
@click="redirectToItemCreate()"
color="primary"
fab
icon="add"
shortcut="+"
/>
<QTooltip class="text-no-wrap">
{{ t('New item') }}
</QTooltip>
</QPageSticky>
</QPage>
</template> </template>
<style lang="scss" scoped>
.subName {
text-transform: uppercase;
color: var(--vn-label-color);
}
</style>
<i18n> <i18n>
es: es:
New item: Nuevo artículo New item: Nuevo artículo
All it's properties will be copied: Todas sus propiedades serán copiadas
Do you want to clone this item?: ¿Desea clonar este artículo?
Preview: Vista previa Preview: Vista previa
Regularize stock: Regularizar stock
</i18n> </i18n>

View File

@ -1,23 +1,17 @@
<script setup> <script setup>
import { ref, computed, onMounted, onBeforeMount, watch } from 'vue'; import { ref, computed, onMounted, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import VnInput from 'src/components/common/VnInput.vue';
import ItemRequestDenyForm from './ItemRequestDenyForm.vue';
import ItemRequestFilter from './ItemRequestFilter.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import VnSelect from 'components/common/VnSelect.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import { toDateFormat } from 'src/filters/date'; import { dashIfEmpty, toCurrency } from 'filters/index';
import { toCurrency } from 'filters/index';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js';
import axios from 'axios'; import axios from 'axios';
import RightMenu from 'src/components/common/RightMenu.vue'; import ItemRequestDenyForm from './ItemRequestDenyForm.vue';
import { toDate } from 'src/filters';
import VnTable from 'components/VnTable/VnTable.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n(); const { t } = useI18n();
const { notify } = useNotify(); const { notify } = useNotify();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -33,6 +27,12 @@ const arrayData = useArrayData('ItemRequests', {
}); });
const store = arrayData.store; const store = arrayData.store;
const userParams = {
state: 'pending',
daysOnward: 7,
};
const tableRef = ref();
watch( watch(
() => store.data, () => store.data,
(value) => (itemRequestsOptions.value = value) (value) => (itemRequestsOptions.value = value)
@ -41,89 +41,137 @@ watch(
const columns = computed(() => [ const columns = computed(() => [
{ {
label: t('item.buyRequest.ticketId'), label: t('item.buyRequest.ticketId'),
name: 'id', name: 'ticketFk',
field: 'id',
align: 'left', align: 'left',
sortable: true, isId: true,
chip: {
condition: () => true,
},
cardVisible: true,
}, },
{ {
label: t('item.buyRequest.shipped'), label: t('item.buyRequest.shipped'),
field: 'shipped',
name: 'shipped', name: 'shipped',
align: 'left', align: 'left',
sortable: true, component: 'date',
columnField: {
component: null,
},
format: (row, dashIfEmpty) => dashIfEmpty(toDate(row.shipped)),
columnClass: 'shrink',
}, },
{ {
label: t('globals.description'), label: t('globals.description'),
field: 'description', field: 'description',
name: 'description', name: 'description',
align: 'left', align: 'left',
sortable: true, columnClass: 'expand',
}, },
{ {
label: t('item.buyRequest.requester'), label: t('item.buyRequest.requester'),
name: 'requester', name: 'requesterName',
align: 'left', component: 'select',
sortable: true, columnFilter: {
name: 'requesterFk',
attrs: {
url: 'VnUsers/preview',
optionValue: 'id',
optionLabel: 'nickname',
},
},
columnField: {
component: null,
},
columnClass: 'shrink',
}, },
{ {
label: t('item.buyRequest.requested'), label: t('item.buyRequest.requested'),
field: 'quantity', name: 'quantity',
name: 'requested', columnClass: 'shrink',
align: 'left',
sortable: true,
}, },
{ {
label: t('item.buyRequest.price'), label: t('item.buyRequest.price'),
field: 'price',
name: 'price', name: 'price',
align: 'left', align: 'left',
sortable: true, format: (row) => toCurrency(row.price),
format: (val) => toCurrency(val), columnClass: 'shrink',
}, },
{ {
label: t('item.buyRequest.attender'), label: t('item.buyRequest.attender'),
field: 'attender', name: 'attenderName',
name: 'attender',
align: 'left', align: 'left',
sortable: true, component: 'select',
columnFilter: {
name: 'attenderFk',
attrs: {
url: 'VnUsers/preview',
optionValue: 'id',
optionLabel: 'nickname',
},
},
columnField: {
component: null,
},
columnClass: 'shrink',
}, },
{ {
label: t('item.buyRequest.item'), label: t('item.buyRequest.item'),
field: 'item',
name: 'item', name: 'item',
align: 'left', align: 'left',
sortable: true, component: 'input',
columnClass: 'expand',
}, },
{ {
label: t('item.buyRequest.achieved'), label: t('item.buyRequest.achieved'),
field: 'achieved',
name: 'achieved', name: 'achieved',
align: 'left', align: 'left',
sortable: true, component: 'input',
columnClass: 'shrink',
}, },
{ {
label: t('item.buyRequest.concept'), label: t('item.buyRequest.concept'),
field: 'concept',
name: 'concept', name: 'concept',
align: 'left', align: 'left',
sortable: true, sortable: true,
component: 'input',
columnClass: 'expand',
}, },
{ {
label: t('item.buyRequest.state'), label: t('item.buyRequest.state'),
field: 'state',
name: 'state', name: 'state',
format: (row) => getState(row.isOk),
align: 'left', align: 'left',
sortable: true,
}, },
{ {
label: '',
name: 'action',
align: 'left', align: 'left',
columnFilter: null, name: 'daysOnward',
label: t('travel.travelList.tableVisibleColumns.daysOnward'),
visible: false,
columnFilter: {
inWhere: false,
},
},
{
align: 'right',
label: '',
name: 'denyOptions',
}, },
]); ]);
const getBadgeColor = (date) => {
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
const orderLanded = new Date(date);
orderLanded.setHours(0, 0, 0, 0);
const difference = today - orderLanded;
if (difference == 0) return 'warning';
if (difference < 0) return 'success';
if (difference > 0) return 'alert';
};
const changeQuantity = async (request) => { const changeQuantity = async (request) => {
try { try {
if (request.saleFk) { if (request.saleFk) {
@ -153,7 +201,6 @@ const confirmRequest = async (request) => {
`TicketRequests/${request.id}/confirm`, `TicketRequests/${request.id}/confirm`,
params params
); );
request.itemDescription = data.concept; request.itemDescription = data.concept;
request.isOk = true; request.isOk = true;
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
@ -182,159 +229,123 @@ const onDenyAccept = (_, responseData) => {
itemRequestsOptions.value[denyRequestIndex.value].response = responseData.response; itemRequestsOptions.value[denyRequestIndex.value].response = responseData.response;
denyRequestId.value = null; denyRequestId.value = null;
denyRequestIndex.value = null; denyRequestIndex.value = null;
tableRef.value.reload();
}; };
onMounted(async () => { onMounted(async () => {
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
}); });
onBeforeMount(() => {
const today = Date.vnNew();
today.setHours(0, 0, 0, 0);
const nextWeek = Date.vnNew();
nextWeek.setHours(23, 59, 59, 59);
nextWeek.setDate(nextWeek.getDate() + 7);
filterParams.value = {
from: today,
to: nextWeek,
state: 'pending',
};
});
</script> </script>
<template> <template>
<VnSearchbar <VnTable
data-key="ItemRequests" ref="tableRef"
url="TicketRequests/filter" data-key="itemRequest"
:label="t('globals.search')" url="ticketRequests/filter"
:info="t('You can search by Id or alias')" order="shipped ASC, isOk ASC"
:redirect="false" :columns="columns"
/> :user-params="userParams"
<RightMenu> :is-editable="true"
<template #right-panel> auto-load
<ItemRequestFilter data-key="ItemRequests" /> :disable-option="{ card: true }"
chip-locale="item.params"
>
<template #column-ticketFk="{ row }">
<span class="link">
{{ row.ticketFk }}
<TicketDescriptorProxy :id="row.ticketFk" />
</span>
</template>
<template #column-shipped="{ row }">
<QTd>
<QBadge
:color="getBadgeColor(row.shipped)"
text-color="black"
class="q-pa-sm"
style="font-size: 14px"
>
{{ toDate(row.shipped) }}
</QBadge>
</QTd>
</template>
<template #column-attenderName="{ row }">
<span class="link" @click.stop>
{{ row.attenderName }}
<WorkerDescriptorProxy :id="row.attenderFk" />
</span>
</template> </template>
</RightMenu>
<QPage class="column items-center q-pa-md">
<QTable
:rows="itemRequestsOptions"
:columns="columns"
row-key="id"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
:no-data-label="t('globals.noResults')"
>
<template #body-cell-id="{ row }">
<QTd>
<QBtn flat color="primary"> {{ row.ticketFk }}</QBtn>
<TicketDescriptorProxy :id="row.ticketFk" />
</QTd>
</template>
<template #body-cell-shipped="{ row }"> <template #column-requesterName="{ row }">
<QTd> <span class="link" @click.stop>
<QBadge {{ row.requesterName }}
v-if="getDateQBadgeColor(row.shipped)" <WorkerDescriptorProxy :id="row.requesterFk" />
:color="getDateQBadgeColor(row.shipped)" </span>
text-color="black" </template>
class="q-ma-none"
dense <template #column-item="{ row }">
style="font-size: 14px" <span>
> <VnInput v-model.number="row.itemFk" dense />
{{ toDateFormat(row.shipped) }} </span>
</QBadge> </template>
<span v-else>{{ toDateFormat(row.shipped) }}</span> <template #column-achieved="{ row }">
</QTd> <span>
</template> <VnInput
<template #body-cell-requester="{ row }"> type="number"
<QTd> v-model.number="row.saleQuantity"
<QBtn flat dense color="primary"> {{ row.requesterName }}</QBtn> :disable="!row.itemFk || row.isOk != null"
<WorkerDescriptorProxy :id="row.requesterFk" /> @blur="changeQuantity(row)"
</QTd> @keyup.enter="changeQuantity(row)"
</template> dense
<template #body-cell-attender="{ row }"> />
<QTd> </span>
<VnSelect </template>
v-model="row.attenderFk" <template #column-concept="{ row }">
:where="{ role: 'buyer' }" <span @click.stop disabled="row.isOk != null">
sort-by="id" {{ row.itemDescription }}
url="Workers" </span>
hide-selected </template>
option-label="firstName" <template #moreFilterPanel="{ params }">
option-value="id" <VnInputNumber
dense :label="t('params.scopeDays')"
/> v-model.number="params.scopeDays"
</QTd> @keyup.enter="(evt) => handleScopeDays(evt.target.value)"
</template> @remove="handleScopeDays()"
<template #body-cell-item="{ row }"> class="q-px-xs q-pr-lg"
<QTd> filled
<VnInput dense
v-model.number="row.itemFk"
type="number"
:disable="row.isOk != null"
dense
/>
</QTd>
</template>
<template #body-cell-achieved="{ row }">
<QTd>
<VnInput
v-model.number="row.saleQuantity"
@blur="changeQuantity(row)"
type="number"
:disable="!row.itemFk || row.isOk != null"
dense
/>
</QTd>
</template>
<template #body-cell-concept="{ row }">
<QTd>
<QBtn flat dense color="primary"> {{ row.itemDescription }}</QBtn>
<ItemDescriptorProxy :id="row.itemFk" />
</QTd>
</template>
<template #body-cell-state="{ row }">
<QTd>
<span>{{ getState(row.isOk) }}</span>
</QTd>
</template>
<template #body-cell-action="{ row, rowIndex }">
<QTd>
<QIcon
v-if="row.response?.length"
name="insert_drive_file"
color="primary"
size="sm"
>
<QTooltip>
{{ row.response }}
</QTooltip>
</QIcon>
<QIcon
v-if="row.isOk == null"
name="thumb_down"
color="primary"
size="sm"
class="fill-icon"
@click="showDenyRequestForm(row.id, rowIndex)"
>
<QTooltip>
{{ t('Discard') }}
</QTooltip>
</QIcon>
</QTd>
</template>
</QTable>
<QDialog ref="denyFormRef" transition-show="scale" transition-hide="scale">
<ItemRequestDenyForm
:request-id="denyRequestId"
@on-data-saved="onDenyAccept"
/> />
</QDialog> </template>
</QPage> <template #column-denyOptions="{ row, rowIndex }">
<QTd class="sticky no-padding">
<QIcon
v-if="row.response?.length"
name="insert_drive_file"
color="primary"
size="sm"
>
<QTooltip>
{{ row.response }}
</QTooltip>
</QIcon>
<QIcon
v-if="row.isOk == null"
name="thumb_down"
color="primary"
size="sm"
class="fill-icon"
@click="showDenyRequestForm(row.id, rowIndex)"
>
<QTooltip>
{{ t('Discard') }}
</QTooltip>
</QIcon>
</QTd>
</template>
</VnTable>
<QDialog ref="denyFormRef" transition-show="scale" transition-hide="scale">
<ItemRequestDenyForm :request-id="denyRequestId" @on-data-saved="onDenyAccept" />
</QDialog>
</template> </template>
<i18n> <i18n>

View File

@ -10,6 +10,7 @@ defineProps({
requestId: { requestId: {
type: Number, type: Number,
default: null, default: null,
required: true,
}, },
}); });
@ -43,6 +44,7 @@ onMounted(async () => {
type="textarea" type="textarea"
v-model="data.observation" v-model="data.observation"
fill-input fill-input
:required="true"
autogrow autogrow
/> />
</div> </div>

View File

@ -174,6 +174,16 @@ const decrement = (paramsObj, key) => {
</VnSelect> </VnSelect>
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<QCheckbox
v-model="params.myTeam"
:label="t('params.myTeam')"
@update:model-value="searchFn()"
toggle-indeterminate
/>
</QItemSection>
</QItem>
<QCard bordered> <QCard bordered>
<QItem> <QItem>
<QItemSection> <QItemSection>
@ -274,11 +284,11 @@ en:
to: To to: To
mine: For me mine: For me
state: State state: State
myTeam: My team
dateFiltersTooltip: Cannot choose a range of dates and days onward at the same time dateFiltersTooltip: Cannot choose a range of dates and days onward at the same time
denied: Denied denied: Denied
accepted: Accepted accepted: Accepted
pending: Pending pending: Pending
es: es:
params: params:
search: Búsqueda general search: Búsqueda general
@ -291,6 +301,7 @@ es:
to: Hasta to: Hasta
mine: Para mi mine: Para mi
state: Estado state: Estado
myTeam: Mi equipo
dateFiltersTooltip: No se puede seleccionar un rango de fechas y días en adelante a la vez dateFiltersTooltip: No se puede seleccionar un rango de fechas y días en adelante a la vez
denied: Denegada denied: Denegada
accepted: Aceptada accepted: Aceptada

View File

@ -8,12 +8,14 @@ import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnAvatar from 'src/components/ui/VnAvatar.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const categoriesOptions = ref([]); const categoriesOptions = ref([]);
const temperaturesOptions = ref([]); const temperaturesOptions = ref([]);
const itemPackingTypesOptions = ref([]);
</script> </script>
<template> <template>
<FetchData <FetchData
@ -28,6 +30,16 @@ const temperaturesOptions = ref([]);
:filter="{ order: 'name ASC', fields: ['code', 'name'] }" :filter="{ order: 'name ASC', fields: ['code', 'name'] }"
auto-load auto-load
/> />
<FetchData
url="ItemPackingTypes"
@on-fetch="(data) => (itemPackingTypesOptions = data)"
:filter="{
where: { isActive: true },
order: 'description ASC',
fields: ['code', 'description'],
}"
auto-load
/>
<FormModel <FormModel
:url="`ItemTypes/${route.params.id}`" :url="`ItemTypes/${route.params.id}`"
:url-update="`ItemTypes/${route.params.id}`" :url-update="`ItemTypes/${route.params.id}`"
@ -41,15 +53,34 @@ const temperaturesOptions = ref([]);
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
url="Workers/search"
v-model="data.workerFk" v-model="data.workerFk"
:label="t('shared.worker')" :label="t('shared.worker')"
url="Workers" sort-by="nickname ASC"
sort-by="firstName ASC" :fields="['id', 'nickname']"
:fields="['id', 'firstName']" option-label="nickname"
option-value="id" option-value="id"
option-label="firstName"
hide-selected hide-selected
/> >
<template #prepend>
<VnAvatar
:worker-id="data.workerFk"
color="primary"
:title="title"
/>
</template>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption
>{{ scope.opt?.nickname }},
{{ scope.opt?.code }}</QItemLabel
>
</QItemSection>
</QItem>
</template></VnSelect
>
<VnSelect <VnSelect
v-model="data.categoryFk" v-model="data.categoryFk"
:label="t('shared.category')" :label="t('shared.category')"
@ -68,6 +99,21 @@ const temperaturesOptions = ref([]);
option-label="name" option-label="name"
hide-selected hide-selected
/> />
<VnInput v-model="data.life" :label="t('shared.life')" />
</VnRow>
<VnRow>
<VnSelect
v-model="data.itemPackingTypeFk"
:label="t('shared.itemPackingType')"
:options="itemPackingTypesOptions"
option-value="code"
option-label="description"
hide-selected
/>
<VnInput v-model="data.maxRefs" :label="t('shared.maxRefs')" />
</VnRow>
<VnRow>
<QCheckbox v-model="data.isFragile" :label="t('shared.fragile')" />
</VnRow> </VnRow>
</template> </template>
</FormModel> </FormModel>

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import VnCard from 'components/common/VnCard.vue'; import VnCard from 'components/common/VnCard.vue';
import ItemTypeDescriptor from 'src/pages/ItemType/Card/ItemTypeDescriptor.vue'; import ItemTypeDescriptor from 'src/pages/Item/ItemType/Card/ItemTypeDescriptor.vue';
import ItemTypeFilter from 'src/pages/ItemType/ItemTypeFilter.vue'; import ItemTypeFilter from 'src/pages/Item/ItemType/ItemTypeFilter.vue';
import ItemTypeSearchbar from '../ItemTypeSearchbar.vue'; import ItemTypeSearchbar from '../ItemTypeSearchbar.vue';
</script> </script>
<template> <template>

View File

@ -0,0 +1,7 @@
<script setup>
import VnLog from 'src/components/common/VnLog.vue';
</script>
<template>
<VnLog model="ItemType" url="/ItemTypeLogs"></VnLog>
</template>

View File

@ -6,6 +6,7 @@ import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.v
import CardSummary from 'components/ui/CardSummary.vue'; import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue';
onUpdated(() => summaryRef.value.fetch()); onUpdated(() => summaryRef.value.fetch());
@ -55,6 +56,11 @@ async function setItemTypeData(data) {
> >
<QIcon name="open_in_new" color="white" size="sm" /> <QIcon name="open_in_new" color="white" size="sm" />
</router-link> </router-link>
<VnToSummary
v-if="route?.name !== 'ItemTypeSummary'"
:route-name="'ItemTypeSummary'"
:entity-id="entityId"
/>
</template> </template>
<template #header> <template #header>
<span> <span>

View File

@ -12,6 +12,39 @@ const props = defineProps({
}); });
const emit = defineEmits(['search']); const emit = defineEmits(['search']);
const exprBuilder = (param, value) => {
switch (param) {
case 'name':
return {
name: { like: `%${value}%` },
};
case 'code':
return {
code: { like: `%${value}%` },
};
case 'search':
if (value) {
if (!isNaN(value)) {
return { id: value };
} else {
return {
or: [
{
name: {
like: `%${value}%`,
},
},
{
code: {
like: `%${value}%`,
},
},
],
};
}
}
}
};
</script> </script>
<template> <template>
@ -19,6 +52,8 @@ const emit = defineEmits(['search']);
:data-key="props.dataKey" :data-key="props.dataKey"
:search-button="true" :search-button="true"
@search="emit('search')" @search="emit('search')"
search-url="table"
:expr-builder="exprBuilder"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">

View File

@ -10,6 +10,7 @@ const { t } = useI18n();
url="ItemTypes" url="ItemTypes"
:label="t('Search item type')" :label="t('Search item type')"
:info="t('Search itemType by id, name or code')" :info="t('Search itemType by id, name or code')"
search-url="table"
/> />
</template> </template>
<i18n> <i18n>

View File

@ -4,6 +4,10 @@ shared:
worker: Worker worker: Worker
category: Category category: Category
temperature: Temperature temperature: Temperature
life: Life
itemPackingType: Item packing type
maxRefs: Maximum references
fragile: Fragile
summary: summary:
id: id id: id
life: Life life: Life

View File

@ -4,6 +4,10 @@ shared:
worker: Trabajador worker: Trabajador
category: Reino category: Reino
temperature: Temperatura temperature: Temperatura
life: Vida
itemPackingType: Tipo de embalaje
maxRefs: Referencias máximas
fragile: Frágil
summary: summary:
id: id id: id
code: Código code: Código

View File

@ -1,86 +0,0 @@
<script setup>
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
const { t } = useI18n();
const router = useRouter();
const newItemTypeForm = reactive({});
const categoriesOptions = ref([]);
const temperaturesOptions = ref([]);
const redirectToItemTypeBasicData = (_, { id }) => {
router.push({ name: 'ItemTypeBasicData', params: { id } });
};
</script>
<template>
<FetchData
url="ItemCategories"
@on-fetch="(data) => (categoriesOptions = data)"
:filter="{ order: 'name ASC', fields: ['id', 'name'] }"
auto-load
/>
<FetchData
url="Temperatures"
@on-fetch="(data) => (temperaturesOptions = data)"
:filter="{ order: 'name ASC', fields: ['code', 'name'] }"
auto-load
/>
<QPage>
<VnSubToolbar />
<FormModel
url-create="ItemTypes"
model="itemTypeCreate"
:form-initial-data="newItemTypeForm"
observe-form-changes
@on-data-saved="redirectToItemTypeBasicData"
>
<template #form="{ data }">
<VnRow>
<VnInput v-model="data.code" :label="t('itemType.shared.code')" />
<VnInput v-model="data.name" :label="t('itemType.shared.name')" />
</VnRow>
<VnRow>
<VnSelect
v-model="data.workerFk"
:label="t('itemType.shared.worker')"
url="Workers"
sort-by="firstName ASC"
:fields="['id', 'firstName']"
option-value="id"
option-label="firstName"
hide-selected
/>
<VnSelect
v-model="data.categoryFk"
:label="t('itemType.shared.category')"
:options="categoriesOptions"
option-value="id"
option-label="name"
hide-selected
/>
</VnRow>
<VnRow>
<VnSelect
v-model="data.temperatureFk"
:label="t('itemType.shared.temperature')"
:options="temperaturesOptions"
option-value="code"
option-label="name"
hide-selected
/>
</VnRow>
</template>
</FormModel>
</QPage>
</template>

View File

@ -1,113 +1,159 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { ref, computed } from 'vue';
import ItemTypeSearchbar from 'src/pages/Item/ItemType/ItemTypeSearchbar.vue';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import FetchData from 'components/FetchData.vue';
import CardList from 'src/components/ui/CardList.vue';
import ItemTypeSummary from 'src/pages/ItemType/Card/ItemTypeSummary.vue';
import ItemTypeFilter from 'src/pages/ItemType/ItemTypeFilter.vue';
import ItemTypeSearchbar from '../ItemType/ItemTypeSearchbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import ItemTypeFilter from './ItemType/ItemTypeFilter.vue';
const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const tableRef = ref();
const itemCategoriesOptions = ref([]);
const temperatureOptions = ref([]);
const redirectToItemTypeSummary = (id) => { const columns = computed(() => [
router.push({ name: 'ItemTypeSummary', params: { id } }); {
}; align: 'left',
name: 'id',
const redirectToCreateView = () => { label: t('id'),
router.push({ name: 'ItemTypeCreate' }); isId: true,
}; cardVisible: true,
},
const exprBuilder = (param, value) => { {
switch (param) { align: 'left',
case 'name': name: 'code',
return { label: t('code'),
name: { like: `%${value}%` }, isTitle: true,
}; cardVisible: true,
case 'code': create: true,
return { },
code: { like: `%${value}%` }, {
}; align: 'left',
case 'search': name: 'name',
if (value) { label: t('name'),
if (!isNaN(value)) { cardVisible: true,
return { id: value }; create: true,
} else { },
return { {
or: [ align: 'left',
{ label: t('worker'),
name: { create: true,
like: `%${value}%`, component: 'select',
}, attrs: {
}, url: 'Workers/search',
{ optionLabel: 'nickname',
code: { optionValue: 'id',
like: `%${value}%`, },
}, cardVisible: true,
}, visible: true,
], columnField: {
}; component: 'userLink',
} attrs: ({ row }) => {
} return {
} workerId: row?.worker?.id,
}; name: row.worker?.user?.name,
defaultName: true,
};
},
},
columnFilter: {
name: 'workerFk',
},
},
{
align: 'left',
name: 'categoryFk',
label: t('ItemCategory'),
create: true,
component: 'select',
attrs: {
options: itemCategoriesOptions.value,
},
cardVisible: false,
visible: false,
},
{
align: 'left',
name: 'Temperature',
label: t('Temperature'),
create: true,
component: 'select',
attrs: {
options: temperatureOptions.value,
},
cardVisible: false,
visible: false,
},
]);
</script> </script>
<template> <template>
<ItemTypeSearchbar /> <FetchData
url="ItemCategories"
:filter="{ fields: ['id', 'name'], order: ['name ASC'] }"
@on-fetch="(data) => (itemCategoriesOptions = data)"
auto-load
/>
<FetchData
url="Temperatures"
:filter="{ fields: ['id', 'name'], order: ['name ASC'] }"
@on-fetch="(data) => (temperatureOptions = data)"
auto-load
/>
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<ItemTypeFilter data-key="ItemTypeList" /> <ItemTypeFilter data-key="ItemTypeList" />
</template> </template>
</RightMenu> </RightMenu>
<QPage class="column items-center q-pa-md"> <ItemTypeSearchbar />
<div class="vn-card-list"> <VnTable
<VnPaginate ref="tableRef"
data-key="ItemTypeList" data-key="ItemTypeList"
url="ItemTypes" url="ItemTypes"
:order="['name']" :create="{
auto-load urlCreate: 'ItemTypes',
:expr-builder="exprBuilder" title: t('Create ItemTypes'),
> onDataSaved: () => tableRef.reload(),
<template #body="{ rows }"> formInitialData: {},
<CardList }"
v-for="row of rows" :user-filter="{
:key="row.id" include: {
:title="row.code" relation: 'worker',
@click="redirectToItemTypeSummary(row.id)" scope: {
:id="row.id" fields: ['id'],
> include: {
<template #list-items> relation: 'user',
<VnLv :label="t('Name')" :value="row.name" /> scope: {
</template> fields: ['id', 'name'],
<template #actions> },
<QBtn },
:label="t('components.smartCard.openSummary')" },
@click.stop="viewSummary(row.id, ItemTypeSummary)" },
color="primary" }"
type="submit" order="name ASC"
/> :columns="columns"
</template> auto-load
</CardList> :right-search="false"
</template> :is-editable="false"
</VnPaginate> :use-model="true"
</div> redirect="item/item-type"
</QPage> />
<QPageSticky :offset="[20, 20]">
<QBtn
fab
icon="add"
color="primary"
@click="redirectToCreateView()"
shortcut="+"
/>
<QTooltip>
{{ t('New item type') }}
</QTooltip>
</QPageSticky>
</template> </template>
<i18n>
es:
id: Id
code: Código
name: Nombre
worker: Trabajador
ItemCategory: Reino
Temperature: Temperatura
Create ItemTypes: Crear familia
en:
code: Code
name: Name
worker: Worker
ItemCategory: ItemCategory
Temperature: Temperature
</i18n>

View File

@ -0,0 +1,36 @@
import axios from 'axios';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import VnConfirm from 'components/ui/VnConfirm.vue';
export function cloneItem() {
const { t } = useI18n();
const quasar = useQuasar();
const router = useRouter();
const cloneItem = async (entityId) => {
const { id } = entityId;
try {
const { data } = await axios.post(`Items/${id ?? entityId}/clone`);
router.push({ name: 'ItemTags', params: { id: data.id } });
} catch (err) {
console.error('Error cloning item');
}
};
const openCloneDialog = async (entityId) => {
quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('item.descriptor.clone.title'),
message: t('item.descriptor.clone.subTitle'),
},
})
.onOk(async () => {
await cloneItem(entityId);
});
};
return { openCloneDialog };
}

View File

@ -88,3 +88,127 @@ itemType:
worker: Worker worker: Worker
category: Category category: Category
temperature: Temperature temperature: Temperature
item:
params:
daysOnward: Days onward
search: General search
ticketFk: Ticket id
attenderFk: Atender
clientFk: Client id
warehouseFk: Warehouse
requesterFk: Salesperson
from: From
to: To
mine: For me
state: State
myTeam: My team
searchbar:
label: Search item
descriptor:
item: Item
buyer: Buyer
color: Color
category: Category
stems: Stems
visible: Visible
available: Available
warehouseText: 'Calculated on the warehouse of { warehouseName }'
itemDiary: Item diary
producer: Producer
clone:
title: All its properties will be copied
subTitle: Do you want to clone this item?
list:
id: Identifier
grouping: Grouping
packing: Packing
description: Description
stems: Stems
category: Category
typeName: Type
intrastat: Intrastat
isActive: Active
size: Size
origin: Origin
userName: Buyer
weightByPiece: Weight/Piece
stemMultiplier: Multiplier
producer: Producer
landed: Landed
basicData:
type: Type
reference: Reference
relevancy: Relevancy
stems: Stems
multiplier: Multiplier
generic: Generic
intrastat: Intrastat
expense: Expense
weightByPiece: Weight/Piece
boxUnits: Units/Box
recycledPlastic: Recycled Plastic
nonRecycledPlastic: Non recycled plastic
isActive: Active
hasKgPrice: Price in kg
isFragile: Fragile
isFragileTooltip: Is shown at website, app that this item cannot travel (wreath, palms, ...)
isPhotoRequested: Do photo
isPhotoRequestedTooltip: This item does need a photo
description: Description
fixedPrice:
itemFk: Item ID
groupingPrice: Grouping price
packingPrice: Packing price
hasMinPrice: Has min price
minPrice: Min price
started: Started
ended: Ended
warehouse: Warehouse
create:
name: Name
tag: Tag
priority: Priority
type: Type
intrastat: Intrastat
origin: Origin
buyRequest:
ticketId: 'Ticket ID'
shipped: 'Shipped'
requester: 'Requester'
requested: 'Requested'
price: 'Price'
attender: 'Attender'
item: 'Item'
achieved: 'Achieved'
concept: 'Concept'
state: 'State'
summary:
basicData: 'Basic data'
otherData: 'Other data'
description: 'Description'
tax: 'Tax'
tags: 'Tags'
botanical: 'Botanical'
barcode: 'Barcode'
name: 'Nombre'
completeName: 'Nombre completo'
family: 'Familia'
size: 'Medida'
origin: 'Origen'
stems: 'Tallos'
multiplier: 'Multiplicador'
buyer: 'Comprador'
doPhoto: 'Do photo'
intrastatCode: 'Código intrastat'
intrastat: 'Intrastat'
ref: 'Referencia'
relevance: 'Relevancia'
weight: 'Peso (gramos)/tallo'
units: 'Unidades/caja'
expense: 'Gasto'
generic: 'Genérico'
recycledPlastic: 'Plástico reciclado'
nonRecycledPlastic: 'Plástico no reciclado'
minSalesQuantity: 'Cantidad mínima de venta'
genus: 'Genus'
specie: 'Specie'

View File

@ -88,3 +88,129 @@ itemType:
worker: Trabajador worker: Trabajador
category: Reino category: Reino
temperature: Temperatura temperature: Temperatura
params:
state: asfsdf
item:
params:
daysOnward: Días adelante
search: Búsqueda general
ticketFk: Id ticket
attenderFk: Comprador
clientFk: Id cliente
warehouseFk: Almacén
requesterFk: Comercial
from: Desde
to: Hasta
mine: Para mi
state: Estado
myTeam: Mi equipo
searchbar:
label: Buscar artículo
descriptor:
item: Artículo
buyer: Comprador
color: Color
category: Categoría
stems: Tallos
visible: Visible
available: Disponible
warehouseText: 'Calculado sobre el almacén de { warehouseName }'
itemDiary: Registro de compra-venta
producer: Productor
clone:
title: Todas sus propiedades serán copiadas
subTitle: ¿Desea clonar este artículo?
list:
id: Identificador
grouping: Grouping
packing: Packing
description: Descripción
stems: Tallos
category: Reino
typeName: Tipo
intrastat: Intrastat
isActive: Activo
size: Medida
origin: Origen
weightByPiece: Peso (gramos)/tallo
userName: Comprador
stemMultiplier: Multiplicador
producer: Productor
landed: F. entrega
basicData:
type: Tipo
reference: Referencia
relevancy: Relevancia
stems: Tallos
multiplier: Multiplicador
generic: Genérico
intrastat: Intrastat
expense: Gasto
weightByPiece: Peso (gramos)/tallo
boxUnits: Unidades/caja
recycledPlastic: Plastico reciclado
nonRecycledPlastic: Plático no reciclado
isActive: Activo
hasKgPrice: Precio en kg
isFragile: Frágil
isFragileTooltip: Se muestra en la web, app que este artículo no puede viajar (coronas, palmas, ...)
isPhotoRequested: Hacer foto
isPhotoRequestedTooltip: Este artículo necesita una foto
description: Descripción
fixedPrice:
itemFk: ID Artículo
groupingPrice: Precio grouping
packingPrice: Precio packing
hasMinPrice: Tiene precio mínimo
minPrice: Precio min
started: Inicio
ended: Fin
warehouse: Almacén
create:
name: Nombre
tag: Etiqueta
priority: Prioridad
type: Tipo
intrastat: Intrastat
origin: Origen
summary:
basicData: 'Datos básicos'
otherData: 'Otros datos'
description: 'Descripción'
tax: 'IVA'
tags: 'Etiquetas'
botanical: 'Botánico'
barcode: 'Código de barras'
name: 'Nombre'
completeName: 'Nombre completo'
family: 'Familia'
size: 'Medida'
origin: 'Origen'
stems: 'Tallos'
multiplier: 'Multiplicador'
buyer: 'Comprador'
doPhoto: 'Hacer foto'
intrastatCode: 'Código intrastat'
intrastat: 'Intrastat'
ref: 'Referencia'
relevance: 'Relevancia'
weight: 'Peso (gramos)/tallo'
units: 'Unidades/caja'
expense: 'Gasto'
generic: 'Genérico'
recycledPlastic: 'Plástico reciclado'
nonRecycledPlastic: 'Plástico no reciclado'
minSalesQuantity: 'Cantidad mínima de venta'
genus: 'Genus'
specie: 'Specie'
buyRequest:
ticketId: 'ID Ticket'
shipped: 'F. envío'
requester: 'Solicitante'
requested: 'Solicitado'
price: 'Precio'
attender: 'Comprador'
item: 'Artículo'
achieved: 'Conseguido'
concept: 'Concepto'
state: 'Estado'

View File

@ -2,17 +2,11 @@
import VnCard from 'components/common/VnCard.vue'; import VnCard from 'components/common/VnCard.vue';
import ParkingDescriptor from 'pages/Parking/Card/ParkingDescriptor.vue'; import ParkingDescriptor from 'pages/Parking/Card/ParkingDescriptor.vue';
import ParkingFilter from 'pages/Parking/ParkingFilter.vue'; import ParkingFilter from 'pages/Parking/ParkingFilter.vue';
const filter = {
fields: ['id', 'sectorFk', 'code', 'pickingOrder', 'row', 'column'],
include: [{ relation: 'sector', scope: { fields: ['id', 'description'] } }],
};
</script> </script>
<template> <template>
<VnCard <VnCard
data-key="Parking" data-key="Parking"
base-url="Parkings" base-url="Parkings"
:filter="filter"
:descriptor="ParkingDescriptor" :descriptor="ParkingDescriptor"
:filter-panel="ParkingFilter" :filter-panel="ParkingFilter"
search-data-key="ParkingList" search-data-key="ParkingList"

View File

@ -29,6 +29,7 @@ const filter = {
:url="`Parkings/${entityId}`" :url="`Parkings/${entityId}`"
title="code" title="code"
:filter="filter" :filter="filter"
:to-module="{ name: 'ParkingList' }"
> >
<template #body="{ entity }"> <template #body="{ entity }">
<VnLv :label="t('globals.code')" :value="entity.code" /> <VnLv :label="t('globals.code')" :value="entity.code" />

View File

@ -22,7 +22,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
const filter = { const filter = {
fields: ['id', 'sectorFk', 'code', 'pickingOrder'], fields: ['id', 'sectorFk', 'code', 'pickingOrder'],
include: [{ relation: 'sector', scope: { fields: ['id', 'description'] } }],
}; };
function exprBuilder(param, value) { function exprBuilder(param, value) {
@ -55,10 +54,9 @@ function exprBuilder(param, value) {
<VnPaginate <VnPaginate
data-key="ParkingList" data-key="ParkingList"
url="Parkings" url="Parkings"
:filter="filter" :user-filter="filter"
:expr-builder="exprBuilder" :expr-builder="exprBuilder"
:limit="20" :limit="20"
auto-load
order="code" order="code"
> >
<template #body="{ rows }"> <template #body="{ rows }">

View File

@ -126,7 +126,7 @@ const columns = computed(() => [
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
title: t('Preview'), title: t('components.smartCard.viewSummary'),
icon: 'preview', icon: 'preview',
isPrimary: true, isPrimary: true,
action: (row) => viewSummary(row?.routeFk, RouteSummary), action: (row) => viewSummary(row?.routeFk, RouteSummary),

View File

@ -204,7 +204,7 @@ const columns = computed(() => [
isPrimary: true, isPrimary: true,
}, },
{ {
title: t('route.components.smartCard.viewSummary'), title: t('components.smartCard.viewSummary'),
icon: 'preview', icon: 'preview',
action: (row) => viewSummary(row?.id, RouteSummary), action: (row) => viewSummary(row?.id, RouteSummary),
isPrimary: true, isPrimary: true,

View File

@ -12,6 +12,7 @@ import VnInputTime from 'components/common/VnInputTime.vue';
import axios from 'axios'; import axios from 'axios';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { useAcl } from 'src/composables/useAcl';
import { useValidator } from 'src/composables/useValidator'; import { useValidator } from 'src/composables/useValidator';
import { toTimeFormat } from 'filters/date.js'; import { toTimeFormat } from 'filters/date.js';
@ -28,14 +29,17 @@ const { validate } = useValidator();
const { notify } = useNotify(); const { notify } = useNotify();
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const agencyFetchRef = ref(null); const canEditZone = useAcl().hasAny([
const zonesFetchRef = ref(null); { model: 'Ticket', props: 'editZone', accessType: 'WRITE' },
]);
const agencyFetchRef = ref();
const warehousesOptions = ref([]); const warehousesOptions = ref([]);
const companiesOptions = ref([]); const companiesOptions = ref([]);
const agenciesOptions = ref([]); const agenciesOptions = ref([]);
const zonesOptions = ref([]); const zonesOptions = ref([]);
const addresses = ref([]); const addresses = ref([]);
const zoneSelectRef = ref();
const formData = ref($props.formData); const formData = ref($props.formData);
watch( watch(
@ -44,6 +48,8 @@ watch(
{ deep: true } { deep: true }
); );
onMounted(() => onFormModelInit());
const agencyByWarehouseFilter = computed(() => ({ const agencyByWarehouseFilter = computed(() => ({
fields: ['id', 'name'], fields: ['id', 'name'],
order: 'name ASC', order: 'name ASC',
@ -52,18 +58,16 @@ const agencyByWarehouseFilter = computed(() => ({
}, },
})); }));
function zoneWhere() { const zoneWhere = computed(() => {
if (formData?.value?.agencyModeFk) { return formData.value?.agencyModeFk
return formData.value?.agencyModeFk ? {
? { shipped: formData.value?.shipped,
shipped: formData.value?.shipped, addressFk: formData.value?.addressFk,
addressFk: formData.value?.addressFk, agencyModeFk: formData.value?.agencyModeFk,
agencyModeFk: formData.value?.agencyModeFk, warehouseFk: formData.value?.warehouseFk,
warehouseFk: formData.value?.warehouseFk, }
} : {};
: {}; });
}
}
const getLanded = async (params) => { const getLanded = async (params) => {
try { try {
@ -108,32 +112,20 @@ const getShipped = async (params) => {
}; };
const onChangeZone = async (zoneId) => { const onChangeZone = async (zoneId) => {
try { formData.value.agencyModeFk = null;
formData.value.agencyModeFk = null; const { data } = await axios.get(`Zones/${zoneId}`);
const { data } = await axios.get(`Zones/${zoneId}`); formData.value.agencyModeFk = data.agencyModeFk;
formData.value.agencyModeFk = data.agencyModeFk;
} catch (error) {
console.error(error);
}
}; };
const onChangeAddress = async (addressId) => { const onChangeAddress = async (addressId) => {
try { formData.value.nickname = null;
formData.value.nickname = null; const { data } = await axios.get(`Addresses/${addressId}`);
const { data } = await axios.get(`Addresses/${addressId}`); formData.value.nickname = data.nickname;
formData.value.nickname = data.nickname;
} catch (error) {
console.error(error);
}
}; };
const getClientDefaultAddress = async (clientId) => { const getClientDefaultAddress = async (clientId) => {
try { const { data } = await axios.get(`Clients/${clientId}`);
const { data } = await axios.get(`Clients/${clientId}`); if (data) addressId.value = data.defaultAddressFk;
if (data) addressId.value = data.defaultAddressFk;
} catch (error) {
console.error(error);
}
}; };
const clientAddressesList = async (value) => { const clientAddressesList = async (value) => {
@ -270,7 +262,17 @@ const redirectToCustomerAddress = () => {
}); });
}; };
onMounted(() => onFormModelInit()); async function getZone(options) {
if (!zoneId.value) return;
const zone = options.find((z) => z.id == zoneId.value);
if (zone) return;
const { data } = await axios.get('Zones/' + zoneId.value, {
params: { filter: JSON.stringify({ fields: ['id', 'name'] }) },
});
zoneSelectRef.value.opts.push(data);
}
</script> </script>
<template> <template>
<FetchData <FetchData
@ -416,6 +418,7 @@ onMounted(() => onFormModelInit());
:rules="validate('basicData.agency')" :rules="validate('basicData.agency')"
/> />
<VnSelect <VnSelect
ref="zoneSelectRef"
:label="t('basicData.zone')" :label="t('basicData.zone')"
v-model="zoneId" v-model="zoneId"
option-value="id" option-value="id"
@ -424,11 +427,10 @@ onMounted(() => onFormModelInit());
:fields="['id', 'name']" :fields="['id', 'name']"
sort-by="id" sort-by="id"
:where="zoneWhere" :where="zoneWhere"
hide-selected
map-options
:required="true"
@focus="zonesFetchRef.fetch()"
:rules="validate('basicData.zone')" :rules="validate('basicData.zone')"
:required="true"
:disable="!canEditZone"
@update:options="getZone"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">

View File

@ -70,60 +70,51 @@ const isFormInvalid = () => {
}; };
const getPriceDifference = async () => { const getPriceDifference = async () => {
try { const params = {
const params = { landed: formData.value.landed,
landed: formData.value.landed, addressId: formData.value.addressFk,
addressId: formData.value.addressFk, agencyModeId: formData.value.agencyModeFk,
agencyModeId: formData.value.agencyModeFk, zoneId: formData.value.zoneFk,
zoneId: formData.value.zoneFk, warehouseId: formData.value.warehouseFk,
warehouseId: formData.value.warehouseFk, shipped: formData.value.shipped,
shipped: formData.value.shipped, };
}; const { data } = await axios.post(
const { data } = await axios.post( `tickets/${formData.value.id}/priceDifference`,
`tickets/${formData.value.id}/priceDifference`, params
params );
); formData.value.sale = data;
formData.value.sale = data;
} catch (error) {
console.error(error);
}
}; };
const submit = async () => { const submit = async () => {
try { if (!formData.value.option) return notify(t('basicData.chooseAnOption'), 'negative');
if (!formData.value.option)
return notify(t('basicData.chooseAnOption'), 'negative');
const params = { const params = {
clientFk: formData.value.clientFk, clientFk: formData.value.clientFk,
nickname: formData.value.nickname, nickname: formData.value.nickname,
agencyModeFk: formData.value.agencyModeFk, agencyModeFk: formData.value.agencyModeFk,
addressFk: formData.value.addressFk, addressFk: formData.value.addressFk,
zoneFk: formData.value.zoneFk, zoneFk: formData.value.zoneFk,
warehouseFk: formData.value.warehouseFk, warehouseFk: formData.value.warehouseFk,
companyFk: formData.value.companyFk, companyFk: formData.value.companyFk,
shipped: formData.value.shipped, shipped: formData.value.shipped,
landed: formData.value.landed, landed: formData.value.landed,
isDeleted: formData.value.isDeleted, isDeleted: formData.value.isDeleted,
option: formData.value.option, option: formData.value.option,
isWithoutNegatives: formData.value.withoutNegatives, isWithoutNegatives: formData.value.withoutNegatives,
withWarningAccept: formData.value.withWarningAccept, withWarningAccept: formData.value.withWarningAccept,
keepPrice: false, keepPrice: false,
}; };
const { data } = await axios.post( const { data } = await axios.post(
`tickets/${formData.value.id}/componentUpdate`, `tickets/${formData.value.id}/componentUpdate`,
params params
); );
if (!data) return; if (!data) return;
const ticketToMove = data.id; const ticketToMove = data.id;
notify(t('basicData.unroutedTicket'), 'positive'); notify(t('basicData.unroutedTicket'), 'positive');
router.push({ name: 'TicketSummary', params: { id: ticketToMove } }); router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
} catch (error) {
console.error(error);
}
}; };
const submitWithNegatives = async () => { const submitWithNegatives = async () => {

View File

@ -34,26 +34,20 @@ const newTicketFormData = reactive({});
const date = new Date(); const date = new Date();
const createTicket = async () => { const createTicket = async () => {
try { const expeditionIds = $props.selectedExpeditions.map((expedition) => expedition.id);
const expeditionIds = $props.selectedExpeditions.map( const params = {
(expedition) => expedition.id clientId: $props.ticket.clientFk,
); landed: newTicketFormData.landed,
const params = { warehouseId: $props.ticket.warehouseFk,
clientId: $props.ticket.clientFk, addressId: $props.ticket.addressFk,
landed: newTicketFormData.landed, agencyModeId: $props.ticket.agencyModeFk,
warehouseId: $props.ticket.warehouseFk, routeId: newTicketFormData.routeFk,
addressId: $props.ticket.addressFk, expeditionIds: expeditionIds,
agencyModeId: $props.ticket.agencyModeFk, };
routeId: newTicketFormData.routeFk,
expeditionIds: expeditionIds,
};
const { data } = await axios.post('Expeditions/moveExpeditions', params); const { data } = await axios.post('Expeditions/moveExpeditions', params);
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
router.push({ name: 'TicketSummary', params: { id: data.id } }); router.push({ name: 'TicketSummary', params: { id: data.id } });
} catch (error) {
console.error(error);
}
}; };
</script> </script>

View File

@ -150,31 +150,19 @@ const getTotal = computed(() => {
}); });
const getComponentsSum = async () => { const getComponentsSum = async () => {
try { const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`); componentsList.value = data;
componentsList.value = data;
} catch (error) {
console.error(error);
}
}; };
const getTheoricalCost = async () => { const getTheoricalCost = async () => {
try { const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`); theoricalCost.value = data;
theoricalCost.value = data;
} catch (error) {
console.error(error);
}
}; };
const getTicketVolume = async () => { const getTicketVolume = async () => {
try { if (!ticketData.value) return;
if (!ticketData.value) return; const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`); ticketVolume.value = data[0].volume;
ticketVolume.value = data[0].volume;
} catch (error) {
console.error(error);
}
}; };
onMounted(() => { onMounted(() => {

View File

@ -3,7 +3,7 @@ import axios from 'axios';
import { ref, toRefs } from 'vue'; import { ref, toRefs } from 'vue';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { usePrintService } from 'composables/usePrintService'; import { usePrintService } from 'composables/usePrintService';
import SendEmailDialog from 'components/common/SendEmailDialog.vue'; import SendEmailDialog from 'components/common/SendEmailDialog.vue';
import VnConfirm from 'components/ui/VnConfirm.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
@ -23,6 +23,7 @@ const props = defineProps({
required: true, required: true,
}, },
}); });
const route = useRoute();
const { push, currentRoute } = useRouter(); const { push, currentRoute } = useRouter();
const { dialog, notify } = useQuasar(); const { dialog, notify } = useQuasar();
@ -40,6 +41,8 @@ const isEditable = ref();
const hasInvoicing = useAcl('invoicing'); const hasInvoicing = useAcl('invoicing');
const hasPdf = ref(); const hasPdf = ref();
const weight = ref(); const weight = ref();
const hasDocuwareFile = ref();
const quasar = useQuasar();
const actions = { const actions = {
clone: async () => { clone: async () => {
const opts = { message: t('Ticket cloned'), type: 'positive' }; const opts = { message: t('Ticket cloned'), type: 'positive' };
@ -331,10 +334,48 @@ async function handleInvoiceOutData() {
}); });
hasPdf.value = data[0]?.hasPdf; hasPdf.value = data[0]?.hasPdf;
} }
async function docuwareDownload() {
await axios.get(`Tickets/${ticketId}/docuwareDownload`);
}
async function hasDocuware() {
const { data } = await axios.post(`Docuwares/${ticketId}/checkFile`, {
fileCabinet: 'deliveryNote',
signed: true,
});
hasDocuwareFile.value = data;
}
async function uploadDocuware(force) {
if (!force)
return quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('Send PDF to tablet'),
message: t('Are you sure you want to replace this delivery note?'),
},
})
.onOk(async () => {
uploadDocuware(true);
});
const { data } = await axios.post(`Docuwares/upload`, {
fileCabinet: 'deliveryNote',
ticketIds: [parseInt(ticketId)],
});
if (data) notify({ message: t('PDF sent!'), type: 'positive' });
}
</script> </script>
<template> <template>
<FetchData <FetchData
:url="`Tickets/${ticketId}/isEditable`" :url="
route.path.startsWith('/ticket')
? `Tickets/${ticketId}/isEditable`
: `Tickets/${ticket}/isEditable`
"
auto-load auto-load
@on-fetch="handleFetchData" @on-fetch="handleFetchData"
/> />
@ -452,7 +493,13 @@ async function handleInvoiceOutData() {
<QItemSection side> <QItemSection side>
<QIcon name="keyboard_arrow_right" /> <QIcon name="keyboard_arrow_right" />
</QItemSection> </QItemSection>
<QMenu anchor="top end" self="top start" auto-close bordered> <QMenu
anchor="top end"
self="top start"
auto-close
bordered
@click="hasDocuware()"
>
<QList> <QList>
<QItem @click="openDeliveryNote('deliveryNote')" v-ripple clickable> <QItem @click="openDeliveryNote('deliveryNote')" v-ripple clickable>
<QItemSection>{{ t('as PDF') }}</QItemSection> <QItemSection>{{ t('as PDF') }}</QItemSection>
@ -460,6 +507,14 @@ async function handleInvoiceOutData() {
<QItem @click="openDeliveryNote('withoutPrices')" v-ripple clickable> <QItem @click="openDeliveryNote('withoutPrices')" v-ripple clickable>
<QItemSection>{{ t('as PDF without prices') }}</QItemSection> <QItemSection>{{ t('as PDF without prices') }}</QItemSection>
</QItem> </QItem>
<QItem
v-if="hasDocuwareFile"
@click="docuwareDownload()"
v-ripple
clickable
>
<QItemSection>{{ t('as PDF signed') }}</QItemSection>
</QItem>
<QItem <QItem
@click="openDeliveryNote('deliveryNote', 'csv')" @click="openDeliveryNote('deliveryNote', 'csv')"
v-ripple v-ripple
@ -478,7 +533,7 @@ async function handleInvoiceOutData() {
<QItemSection side> <QItemSection side>
<QIcon name="keyboard_arrow_right" /> <QIcon name="keyboard_arrow_right" />
</QItemSection> </QItemSection>
<QMenu anchor="top end" self="top start" auto-close> <QMenu anchor="top end" self="top start" auto-close @click="hasDocuware()">
<QList> <QList>
<QItem <QItem
@click="sendDeliveryNoteConfirmation('deliveryNote')" @click="sendDeliveryNoteConfirmation('deliveryNote')"
@ -487,11 +542,7 @@ async function handleInvoiceOutData() {
> >
<QItemSection>{{ t('Send PDF') }}</QItemSection> <QItemSection>{{ t('Send PDF') }}</QItemSection>
</QItem> </QItem>
<QItem <QItem @click="uploadDocuware(!hasDocuwareFile)" v-ripple clickable>
@click="sendDeliveryNoteConfirmation('withoutPrices')"
v-ripple
clickable
>
<QItemSection>{{ t('Send PDF to tablet') }}</QItemSection> <QItemSection>{{ t('Send PDF to tablet') }}</QItemSection>
</QItem> </QItem>
<QItem <QItem
@ -695,4 +746,6 @@ es:
invoiceIds: "Se han generado las facturas con los siguientes ids: {invoiceIds}" invoiceIds: "Se han generado las facturas con los siguientes ids: {invoiceIds}"
This ticket will be removed from current route! Continue anyway?: ¡Se eliminará el ticket de la ruta actual! ¿Continuar de todas formas? This ticket will be removed from current route! Continue anyway?: ¡Se eliminará el ticket de la ruta actual! ¿Continuar de todas formas?
You are going to delete this ticket: Vas a eliminar este ticket You are going to delete this ticket: Vas a eliminar este ticket
as PDF signed: como PDF firmado
Are you sure you want to replace this delivery note?: ¿Seguro que quieres reemplazar este albarán?
</i18n> </i18n>

View File

@ -1,8 +1,8 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { toCurrency } from 'src/filters'; import { toCurrency } from 'src/filters';
import VnUsesMana from 'components/ui/VnUsesMana.vue';
const $props = defineProps({ const $props = defineProps({
mana: { mana: {
@ -13,12 +13,21 @@ const $props = defineProps({
type: Number, type: Number,
default: 0, default: 0,
}, },
usesMana: {
type: Boolean,
default: false,
},
manaCode: {
type: String,
default: 'mana',
},
}); });
const emit = defineEmits(['save', 'cancel']); const emit = defineEmits(['save', 'cancel']);
const { t } = useI18n(); const { t } = useI18n();
const QPopupProxyRef = ref(null); const QPopupProxyRef = ref(null);
const manaCode = ref($props.manaCode);
const save = () => { const save = () => {
emit('save'); emit('save');
@ -47,6 +56,9 @@ const cancel = () => {
</div> </div>
</div> </div>
</div> </div>
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
<VnUsesMana :mana-code="manaCode" />
</div>
<div class="row"> <div class="row">
<QBtn <QBtn
color="primary" color="primary"

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onMounted, ref, computed, onUnmounted, watch } from 'vue'; import { onMounted, ref, computed, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -15,6 +15,8 @@ import useNotify from 'src/composables/useNotify.js';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import VnBtnSelect from 'src/components/common/VnBtnSelect.vue';
import FetchData from 'src/components/FetchData.vue';
const route = useRoute(); const route = useRoute();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -23,50 +25,24 @@ const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const newTicketDialogRef = ref(null); const newTicketDialogRef = ref(null);
const logsTableDialogRef = ref(null); const logsTableDialogRef = ref(null);
const tableRef = ref(); const vnTableRef = ref();
const expeditionsLogsData = ref([]); const expeditionsLogsData = ref([]);
const selectedExpeditions = ref([]); const selectedExpeditions = ref([]);
const allColumnNames = ref([]); const allColumnNames = ref([]);
const newTicketWithRoute = ref(false); const newTicketWithRoute = ref(false);
const selectedRows = ref([]); const selectedRows = ref([]);
const hasSelectedRows = computed(() => selectedRows.value.length > 0); const hasSelectedRows = computed(() => selectedRows.value.length > 0);
const expeditionStateTypes = ref([]);
const exprBuilder = (param, value) => {
switch (param) {
case 'expeditionFk':
return { id: value };
case 'packageItemName':
return { packagingItemFk: value };
}
};
const expeditionsFilter = computed(() => ({ const expeditionsFilter = computed(() => ({
where: { ticketFk: route.params.id }, where: { ticketFk: route.params.id },
order: ['created DESC'], order: ['created DESC'],
})); }));
const expeditionsArrayData = useArrayData('ticketExpeditions', {
url: 'Expeditions/filter',
filter: expeditionsFilter.value,
exprBuilder: exprBuilder,
});
const ticketArrayData = useArrayData('ticketData'); const ticketArrayData = useArrayData('ticketData');
const ticketStore = ticketArrayData.store; const ticketStore = ticketArrayData.store;
const ticketData = computed(() => ticketStore.data); const ticketData = computed(() => ticketStore.data);
const refetchExpeditions = async () => {
await expeditionsArrayData.applyFilter({
filter: expeditionsFilter.value,
});
};
watch(
() => route.params.id,
async () => await refetchExpeditions(),
{ immediate: true }
);
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -187,18 +163,12 @@ const showNewTicketDialog = (withRoute = false) => {
}; };
const deleteExpedition = async () => { const deleteExpedition = async () => {
try { const expeditionIds = selectedRows.value.map((expedition) => expedition.id);
const expeditionIds = selectedExpeditions.value.map( const params = { expeditionIds };
(expedition) => expedition.id await axios.post('Expeditions/deleteExpeditions', params);
); vnTableRef.value.reload();
const params = { expeditionIds }; selectedExpeditions.value = [];
await axios.post('Expeditions/deleteExpeditions', params); notify(t('expedition.expeditionRemoved'), 'positive');
await refetchExpeditions();
selectedExpeditions.value = [];
notify(t('expedition.expeditionRemoved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const showLog = async (expedition) => { const showLog = async (expedition) => {
@ -207,29 +177,19 @@ const showLog = async (expedition) => {
}; };
const getExpeditionState = async (expedition) => { const getExpeditionState = async (expedition) => {
try { const filter = {
const filter = { where: { expeditionFk: expedition.id },
where: { expeditionFk: expedition.id }, order: ['created DESC'],
order: ['created DESC'], };
};
const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, { const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
params: { filter: JSON.stringify(filter) }, params: { filter: JSON.stringify(filter) },
}); });
const { data: scannedStates } = await axios.get(`ExpeditionStates`, {
params: { filter: JSON.stringify(filter), fields: ['id', 'isScanned'] },
});
expeditionsLogsData.value = expeditionStates.map((state) => { expeditionsLogsData.value = expeditionStates.map((state) => ({
const scannedState = scannedStates.find((s) => s.id === state.id); ...state,
return { isScanned: !!state.isScanned,
...state, }));
isScanned: scannedState ? scannedState.isScanned : false,
};
});
} catch (error) {
console.error(error);
}
}; };
onMounted(async () => { onMounted(async () => {
@ -242,9 +202,36 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</script> </script>
<template> <template>
<FetchData
url="expeditionStateTypes"
@on-fetch="(data) => (expeditionStateTypes = data)"
auto-load
/>
<VnSubToolbar> <VnSubToolbar>
<template #st-actions> <template #st-actions>
<QBtnGroup push class="q-gutter-x-sm" flat> <QBtnGroup push class="q-gutter-x-sm" flat>
<VnBtnSelect
data-cy="change-state"
:disable="!hasSelectedRows"
color="primary"
:label="t('globals.changeState')"
:select-props="{
options: expeditionStateTypes,
optionLabel: 'description',
optionValue: 'code',
}"
:promise="
async (stateCode) => {
await axios.post('ExpeditionStates/addExpeditionState', {
expeditions: selectedRows.map(({ id }) => {
return { expeditionFk: id, stateCode };
}),
});
vnTableRef.tableRef.clearSelection();
vnTableRef.reload();
}
"
/>
<QBtnDropdown <QBtnDropdown
ref="btnDropdownRef" ref="btnDropdownRef"
color="primary" color="primary"
@ -298,11 +285,11 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QBtnGroup> </QBtnGroup>
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<VnTable <VnTable
ref="tableRef" ref="vnTableRef"
data-key="TicketExpedition" data-key="TicketExpedition"
url="Expeditions/filter" url="Expeditions/filter"
search-url="expeditions"
:columns="columns" :columns="columns"
:filter="expeditionsFilter" :filter="expeditionsFilter"
v-model:selected="selectedRows" v-model:selected="selectedRows"
@ -311,6 +298,16 @@ onUnmounted(() => (stateStore.rightDrawer = false));
selection: 'multiple', selection: 'multiple',
}" }"
auto-load auto-load
:expr-builder="
(param, value) => {
switch (param) {
case 'expeditionFk':
return { id: value };
case 'packageItemName':
return { packagingItemFk: value };
}
}
"
order="created DESC" order="created DESC"
> >
<template #column-packagingItemFk="{ row }"> <template #column-packagingItemFk="{ row }">
@ -324,7 +321,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<ExpeditionNewTicket <ExpeditionNewTicket
:ticket="ticketData" :ticket="ticketData"
:with-route="newTicketWithRoute" :with-route="newTicketWithRoute"
:selected-expeditions="selectedExpeditions" :selected-expeditions="selectedRows"
/> />
</QDialog> </QDialog>
<QDialog ref="logsTableDialogRef" transition-show="scale" transition-hide="scale"> <QDialog ref="logsTableDialogRef" transition-show="scale" transition-hide="scale">
@ -345,11 +342,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</template> </template>
<template #body-cell-isScanned="{ row }"> <template #body-cell-isScanned="{ row }">
<QTd style="text-align: center"> <QTd style="text-align: center">
<QCheckbox disable v-model="row.isScanned"> <QCheckbox disable v-model="row.isScanned" />
{{
row.isScanned === 1 ? t('expedition.yes') : t('expedition.no')
}}
</QCheckbox>
</QTd> </QTd>
</template> </template>
</QTable> </QTable>

View File

@ -2,6 +2,7 @@
import { onMounted, ref, computed, onUnmounted, watch } from 'vue'; import { onMounted, ref, computed, onUnmounted, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter, useRoute } from 'vue-router'; import { useRouter, useRoute } from 'vue-router';
import { useQuasar } from 'quasar';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import FetchedTags from 'components/ui/FetchedTags.vue'; import FetchedTags from 'components/ui/FetchedTags.vue';
@ -22,6 +23,8 @@ import { useVnConfirm } from 'composables/useVnConfirm';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import VnUsesMana from 'src/components/ui/VnUsesMana.vue';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@ -31,7 +34,7 @@ const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const editPriceProxyRef = ref(null); const editPriceProxyRef = ref(null);
const stateBtnDropdownRef = ref(null); const stateBtnDropdownRef = ref(null);
const quasar = useQuasar();
const arrayData = useArrayData('ticketData'); const arrayData = useArrayData('ticketData');
const { store } = arrayData; const { store } = arrayData;
const selectedRows = ref([]); const selectedRows = ref([]);
@ -50,6 +53,7 @@ const transfer = ref({
sales: [], sales: [],
}); });
const tableRef = ref([]); const tableRef = ref([]);
const canProceed = ref();
watch( watch(
() => route.params.id, () => route.params.id,
@ -213,7 +217,9 @@ const addSale = async (sale) => {
} }
}; };
const changeQuantity = (sale) => { const changeQuantity = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
if ( if (
!sale.itemFk || !sale.itemFk ||
sale.quantity == null || sale.quantity == null ||
@ -225,6 +231,8 @@ const changeQuantity = (sale) => {
}; };
const updateConcept = async (sale) => { const updateConcept = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
try { try {
const data = { newConcept: sale.concept }; const data = { newConcept: sale.concept };
await axios.post(`Sales/${sale.id}/updateConcept`, data); await axios.post(`Sales/${sale.id}/updateConcept`, data);
@ -285,6 +293,8 @@ const onOpenEditDiscountPopover = async (sale) => {
}; };
const updatePrice = async (sale) => { const updatePrice = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
try { try {
const newPrice = edit.value.price; const newPrice = edit.value.price;
if (newPrice != null && newPrice != sale.price) { if (newPrice != null && newPrice != sale.price) {
@ -299,12 +309,18 @@ const updatePrice = async (sale) => {
} }
}; };
const changeDiscount = (sale) => { const changeDiscount = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
const newDiscount = edit.value.discount; const newDiscount = edit.value.discount;
if (newDiscount != null && newDiscount != sale.discount) updateDiscount([sale]); if (newDiscount != null && newDiscount != sale.discount) updateDiscount([sale]);
}; };
const updateDiscount = async (sales, newDiscount = null) => { const updateDiscount = async (sales, newDiscount = null) => {
for (const sale of sales) {
const canProceed = await isSalePrepared(sale);
if (!canProceed) return;
}
const saleIds = sales.map((sale) => sale.id); const saleIds = sales.map((sale) => sale.id);
const _newDiscount = newDiscount || edit.value.discount; const _newDiscount = newDiscount || edit.value.discount;
const params = { const params = {
@ -432,7 +448,9 @@ onUnmounted(() => (stateStore.rightDrawer = false));
const items = ref([]); const items = ref([]);
const newRow = ref({}); const newRow = ref({});
const updateItem = (row) => { const updateItem = async (row) => {
canProceed.value = await isSalePrepared(row);
if (!canProceed.value) return;
const selectedItem = items.value.find((item) => item.id === row.itemFk); const selectedItem = items.value.find((item) => item.id === row.itemFk);
if (selectedItem) { if (selectedItem) {
row.item = selectedItem; row.item = selectedItem;
@ -475,6 +493,55 @@ const endNewRow = (row) => {
} }
}; };
async function isSalePrepared(item) {
const filter = {
params: {
where: { ticketFk: route.params.id },
order: ['concept ASC', 'quantity DESC'],
},
};
const { data } = await axios.get(`SaleTrackings/${route.params.id}/filter`, {
params: {
filter: JSON.stringify(filter),
},
});
const matchingSale = data.find((sale) => sale.itemFk === item.itemFk);
if (!matchingSale) {
return true;
}
if (
matchingSale.hasSaleGroupDetail ||
matchingSale.isControled ||
matchingSale.isPrepared ||
matchingSale.isPrevious ||
matchingSale.isPreviousSelected
) {
try {
await new Promise((resolve, reject) => {
quasar
.dialog({
component: VnConfirm,
componentProps: {
title: t('Item prepared'),
message: t(
'This item is already prepared. Do you want to continue?'
),
data: item,
},
})
.onOk(() => resolve(true))
.onCancel(() => reject(new Error('cancelled')));
});
} catch (error) {
tableRef.value.reload();
return false;
}
}
return true;
}
watch( watch(
() => newRow.value.itemFk, () => newRow.value.itemFk,
(newItemFk) => { (newItemFk) => {
@ -538,6 +605,7 @@ watch(
:ticket-config="ticketConfig" :ticket-config="ticketConfig"
@get-mana="getMana()" @get-mana="getMana()"
@update-discounts="updateDiscount" @update-discounts="updateDiscount"
@refresh-table="resetChanges"
/> />
<QBtn <QBtn
color="primary" color="primary"
@ -768,6 +836,8 @@ watch(
<TicketEditManaProxy <TicketEditManaProxy
:mana="mana" :mana="mana"
:new-price="getNewPrice" :new-price="getNewPrice"
:uses-mana="usesMana"
:mana-code="manaCode"
@save="changeDiscount(row)" @save="changeDiscount(row)"
> >
<VnInput <VnInput
@ -775,6 +845,9 @@ watch(
:label="t('ticketSale.discount')" :label="t('ticketSale.discount')"
type="number" type="number"
/> />
<div v-if="usesMana" class="column q-gutter-y-sm q-mt-sm">
<VnUsesMana :mana-code="manaCode" />
</div>
</TicketEditManaProxy> </TicketEditManaProxy>
</template> </template>
<span v-else>{{ toPercentage(row.discount / 100) }}</span> <span v-else>{{ toPercentage(row.discount / 100) }}</span>
@ -814,4 +887,6 @@ es:
You are going to delete lines of the ticket: Vas a eliminar lineas del ticket You are going to delete lines of the ticket: Vas a eliminar lineas del ticket
Add item: Añadir artículo Add item: Añadir artículo
Transfer lines: Transferir líneas Transfer lines: Transferir líneas
Item prepared: Artículo preparado
This item is already prepared. Do you want to continue?: Este artículo ya esta preparado. Desea continuar?
</i18n> </i18n>

View File

@ -14,7 +14,7 @@ import { toDateFormat } from 'src/filters/date';
import { useRole } from 'src/composables/useRole'; import { useRole } from 'src/composables/useRole';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
const emit = defineEmits(['updateDiscounts', 'getMana']); const emit = defineEmits(['updateDiscounts', 'getMana', 'refreshTable']);
const props = defineProps({ const props = defineProps({
disable: { disable: {
@ -107,6 +107,7 @@ const calculateSalePrice = async () => {
await axios.post(`Sales/recalculatePrice`, props.sales); await axios.post(`Sales/recalculatePrice`, props.sales);
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
emit('refreshTable', props.sales);
}; };
const changeMultipleDiscount = () => { const changeMultipleDiscount = () => {
@ -165,14 +166,10 @@ const createRefund = async (withWarehouse) => {
negative: true, negative: true,
}; };
try { const { data } = await axios.post('Tickets/cloneAll', params);
const { data } = await axios.post('Tickets/cloneAll', params); const [refundTicket] = data;
const [refundTicket] = data; notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive'); push({ name: 'TicketSale', params: { id: refundTicket.id } });
push({ name: 'TicketSale', params: { id: refundTicket.id } });
} catch (error) {
console.error(error);
}
}; };
</script> </script>

View File

@ -150,18 +150,14 @@ const shelvingsTableColumns = computed(() => [
]); ]);
const getSaleTrackings = async (sale) => { const getSaleTrackings = async (sale) => {
try { const filter = {
const filter = { where: { saleFk: sale.saleFk },
where: { saleFk: sale.saleFk }, order: ['itemFk DESC'],
order: ['itemFk DESC'], };
}; const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); saleTrackings.value = data;
saleTrackings.value = data;
} catch (error) {
console.error(error);
}
}; };
const showLog = async (sale) => { const showLog = async (sale) => {
@ -170,17 +166,13 @@ const showLog = async (sale) => {
}; };
const getItemShelvingSales = async (sale) => { const getItemShelvingSales = async (sale) => {
try { const filter = {
const filter = { where: { saleFk: sale.saleFk },
where: { saleFk: sale.saleFk }, };
}; const { data } = await axios.get(`ItemShelvingSales/filter`, {
const { data } = await axios.get(`ItemShelvingSales/filter`, { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); itemShelvingsSales.value = data;
itemShelvingsSales.value = data;
} catch (error) {
console.error(error);
}
}; };
const showShelving = async (sale) => { const showShelving = async (sale) => {
@ -189,36 +181,28 @@ const showShelving = async (sale) => {
}; };
const updateQuantity = async (sale) => { const updateQuantity = async (sale) => {
try { if (oldQuantity.value === sale.quantity) return;
if (oldQuantity.value === sale.quantity) return; const params = {
const params = { quantity: sale.quantity,
quantity: sale.quantity, };
}; await axios.patch(`ItemShelvingSales/${sale.id}`, params);
await axios.patch(`ItemShelvingSales/${sale.id}`, params); oldQuantity.value = null;
oldQuantity.value = null;
} catch (error) {
console.error(error);
}
}; };
const updateParking = async (sale) => { const updateParking = async (sale) => {
try { const filter = {
const filter = { fields: ['id'],
fields: ['id'], where: {
where: { code: sale.shelvingFk,
code: sale.shelvingFk, },
}, };
}; const { data } = await axios.get(`Shelvings/findOne`, {
const { data } = await axios.get(`Shelvings/findOne`, { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); const params = {
const params = { parkingFk: sale.parkingFk,
parkingFk: sale.parkingFk, };
}; await axios.patch(`Shelvings/${data.id}`, params);
await axios.patch(`Shelvings/${data.id}`, params);
} catch (error) {
console.error(error);
}
}; };
const updateShelving = async (sale) => { const updateShelving = async (sale) => {
@ -241,61 +225,41 @@ const updateShelving = async (sale) => {
}; };
const saleTrackingNew = async (sale, stateCode, isChecked) => { const saleTrackingNew = async (sale, stateCode, isChecked) => {
try { const params = {
const params = { saleFk: sale.saleFk,
saleFk: sale.saleFk, isChecked,
isChecked, quantity: sale.quantity,
quantity: sale.quantity, stateCode,
stateCode, };
}; await axios.post(`SaleTrackings/new`, params);
await axios.post(`SaleTrackings/new`, params); notify(t('globals.dataSaved'), 'positive');
notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const saleTrackingDel = async ({ saleFk }, stateCode) => { const saleTrackingDel = async ({ saleFk }, stateCode) => {
try { const params = {
const params = { saleFk,
saleFk, stateCodes: [stateCode],
stateCodes: [stateCode], };
}; await axios.post(`SaleTrackings/delete`, params);
await axios.post(`SaleTrackings/delete`, params); notify(t('globals.dataSaved'), 'positive');
notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const clickSaleGroupDetail = async (sale) => { const clickSaleGroupDetail = async (sale) => {
try { if (!sale.saleGroupDetailFk) return;
if (!sale.saleGroupDetailFk) return;
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`); await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
sale.hasSaleGroupDetail = false; sale.hasSaleGroupDetail = false;
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const clickPreviousSelected = (sale) => { const clickPreviousSelected = (sale) => {
try { qCheckBoxController(sale, 'isPreviousSelected');
qCheckBoxController(sale, 'isPreviousSelected'); if (!sale.isPreviousSelected) sale.isPrevious = false;
if (!sale.isPreviousSelected) sale.isPrevious = false;
} catch (error) {
console.error(error);
}
}; };
const clickPrevious = (sale) => { const clickPrevious = (sale) => {
try { qCheckBoxController(sale, 'isPrevious');
qCheckBoxController(sale, 'isPrevious'); if (sale.isPrevious) sale.isPreviousSelected = true;
if (sale.isPrevious) sale.isPreviousSelected = true;
} catch (error) {
console.error(error);
}
}; };
const qCheckBoxController = (sale, action) => { const qCheckBoxController = (sale, action) => {
@ -306,16 +270,12 @@ const qCheckBoxController = (sale, action) => {
isPreviousSelected: 'PREVIOUS_PREPARATION', isPreviousSelected: 'PREVIOUS_PREPARATION',
}; };
const stateCode = STATE_CODES[action]; const stateCode = STATE_CODES[action];
try { if (!sale[action]) {
if (!sale[action]) { saleTrackingNew(sale, stateCode, true);
saleTrackingNew(sale, stateCode, true); sale[action] = true;
sale[action] = true; } else {
} else { saleTrackingDel(sale, stateCode);
saleTrackingDel(sale, stateCode); sale[action] = false;
sale[action] = false;
}
} catch (error) {
console.error(error);
} }
}; };
</script> </script>

View File

@ -46,40 +46,32 @@ watch(
onMounted(async () => await getDefaultTaxClass()); onMounted(async () => await getDefaultTaxClass());
const createRefund = async () => { const createRefund = async () => {
try { if (!selected.value.length) return;
if (!selected.value.length) return;
const params = { const params = {
servicesIds: selected.value.map((s) => +s.id), servicesIds: selected.value.map((s) => +s.id),
withWarehouse: false, withWarehouse: false,
negative: true, negative: true,
}; };
const { data } = await axios.post('Sales/clone', params); const { data } = await axios.post('Sales/clone', params);
const [refundTicket] = data; const [refundTicket] = data;
notify( notify(
t('service.createRefundSuccess', { t('service.createRefundSuccess', {
ticketId: refundTicket.id, ticketId: refundTicket.id,
}), }),
'positive' 'positive'
); );
router.push({ name: 'TicketSale', params: { id: refundTicket.id } }); router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
} catch (error) {
console.error(error);
}
}; };
const getDefaultTaxClass = async () => { const getDefaultTaxClass = async () => {
try { let filter = {
let filter = { where: { code: 'G' },
where: { code: 'G' }, };
}; const { data } = await axios.get('TaxClasses/findOne', {
const { data } = await axios.get('TaxClasses/findOne', { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); defaultTaxClass.value = data;
defaultTaxClass.value = data;
} catch (error) {
console.error(error);
}
}; };
const columns = computed(() => [ const columns = computed(() => [

View File

@ -19,6 +19,8 @@ import VnTitle from 'src/components/common/VnTitle.vue';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue'; import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue';
const route = useRoute(); const route = useRoute();
const { notify } = useNotify(); const { notify } = useNotify();
@ -68,7 +70,7 @@ function isEditable() {
async function changeState(value) { async function changeState(value) {
try { try {
stateBtnDropdownRef.value.hide(); stateBtnDropdownRef.value?.hide();
const formData = { const formData = {
ticketFk: entityId.value, ticketFk: entityId.value,
code: value, code: value,
@ -85,6 +87,10 @@ async function changeState(value) {
function toTicketUrl(section) { function toTicketUrl(section) {
return '#/ticket/' + entityId.value + '/' + section; return '#/ticket/' + entityId.value + '/' + section;
} }
function isOnTicketCard() {
const currentPath = route.path;
return currentPath.startsWith('/ticket');
}
</script> </script>
<template> <template>
@ -99,6 +105,14 @@ function toTicketUrl(section) {
:url="`Tickets/${entityId}/summary`" :url="`Tickets/${entityId}/summary`"
data-key="TicketSummary" data-key="TicketSummary"
> >
<template #header-left>
<VnToSummary
v-if="route?.name !== 'TicketSummary'"
:route-name="'TicketSummary'"
:entity-id="entityId"
:url="ticketUrl"
/>
</template>
<template #header="{ entity }"> <template #header="{ entity }">
<div> <div>
Ticket #{{ entity.id }} - {{ entity.client?.name }} ({{ Ticket #{{ entity.id }} - {{ entity.client?.name }} ({{
@ -112,7 +126,7 @@ function toTicketUrl(section) {
ref="stateBtnDropdownRef" ref="stateBtnDropdownRef"
color="black" color="black"
text-color="white" text-color="white"
:label="t('ticket.summary.changeState')" :label="t('globals.changeState')"
:disable="!isEditable()" :disable="!isEditable()"
> >
<VnSelect <VnSelect

View File

@ -75,22 +75,18 @@ const columns = computed(() => [
]); ]);
const applyVolumes = async (salesData) => { const applyVolumes = async (salesData) => {
try { if (!salesData.length) return;
if (!salesData.length) return;
sales.value = salesData; sales.value = salesData;
const ticket = sales.value[0].ticketFk; const ticket = sales.value[0].ticketFk;
const { data } = await axios.get(`Tickets/${ticket}/getVolume`); const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume])); const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
sales.value.forEach((sale) => { sales.value.forEach((sale) => {
sale.saleVolume = volumes.get(sale.id); sale.saleVolume = volumes.get(sale.id);
}); });
packingTypeVolume.value = data.packingTypeVolume; packingTypeVolume.value = data.packingTypeVolume;
} catch (error) {
console.error(error);
}
}; };
onMounted(() => (stateStore.rightDrawer = true)); onMounted(() => (stateStore.rightDrawer = true));

View File

@ -1,24 +1,19 @@
<script setup> <script setup>
import { onMounted, ref, computed, reactive } from 'vue'; import { ref, computed, reactive, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import VnProgress from 'src/components/common/VnProgressModal.vue'; import VnProgress from 'src/components/common/VnProgressModal.vue';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import TicketAdvanceFilter from './TicketAdvanceFilter.vue'; import TicketAdvanceFilter from './TicketAdvanceFilter.vue';
import { dashIfEmpty, toCurrency } from 'src/filters'; import { dashIfEmpty, toCurrency } from 'src/filters';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
import { useArrayData } from 'composables/useArrayData';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { toDateFormat } from 'src/filters/date.js'; import { toDateFormat } from 'src/filters/date.js';
import axios from 'axios'; import axios from 'axios';
import VnTable from 'src/components/VnTable/VnTable.vue';
const state = useState(); const state = useState();
const { t } = useI18n(); const { t } = useI18n();
@ -29,109 +24,58 @@ const user = state.getUser();
const itemPackingTypesOptions = ref([]); const itemPackingTypesOptions = ref([]);
const zonesOptions = ref([]); const zonesOptions = ref([]);
const selectedTickets = ref([]); const selectedTickets = ref([]);
const vnTableRef = ref({});
const exprBuilder = (param, value) => { const originElRef = ref(null);
switch (param) { const destinationElRef = ref(null);
case 'id': let today = Date.vnNew().toISOString();
case 'futureId': const tomorrow = new Date(today);
case 'liters': tomorrow.setDate(tomorrow.getDate() + 1);
case 'futureLiters': const userParams = reactive({
case 'lines': dateFuture: tomorrow,
case 'futureLines': dateToAdvance: today,
case 'totalWithVat': warehouseFk: user.value.warehouseFk,
case 'futureTotalWithVat': ipt: 'H',
case 'futureZone': futureIpt: 'H',
case 'notMovableLines': isFullMovable: true,
case 'futureZoneFk':
return { [param]: value };
case 'iptColFilter':
return { ipt: { like: `%${value}%` } };
case 'futureIptColFilter':
return { futureIpt: { like: `%${value}%` } };
}
};
const userParams = reactive({});
const arrayData = useArrayData('AdvanceTickets', {
url: 'Tickets/getTicketsAdvance',
userParams: userParams,
exprBuilder: exprBuilder,
limit: 0,
}); });
const { store } = arrayData;
const tickets = computed(() =>
(store.data || []).map((ticket, index) => ({ ...ticket, index: index }))
);
const applyColumnFilter = async (col) => {
try {
const paramKey = col.columnFilter?.filterParamKey || col.field;
userParams[paramKey] = col.columnFilter.filterValue;
await arrayData.addFilter({ params: userParams });
} catch (err) {
console.error('Error applying column filter', err);
}
};
const getInputEvents = (col) => {
return col.columnFilter.type === 'select'
? { 'update:modelValue': () => applyColumnFilter(col) }
: {
'keyup.enter': () => applyColumnFilter(col),
};
};
const ticketColumns = computed(() => [ const ticketColumns = computed(() => [
{ {
label: '', label: '',
name: 'icons', name: 'icons',
align: 'left', hidden: true,
columnFilter: null, headerClass: 'horizontal-separator',
}, },
{ {
label: t('advanceTickets.ticketId'),
name: 'ticketId',
align: 'center', align: 'center',
sortable: true, label: t('advanceTickets.ticketId'),
columnFilter: { name: 'id',
component: VnInput, headerClass: 'horizontal-separator',
type: 'text',
filterValue: null,
filterParamKey: 'id',
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.ipt'), label: t('advanceTickets.ipt'),
name: 'ipt', name: 'ipt',
field: 'ipt',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: 'select',
filterParamKey: 'iptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: itemPackingTypesOptions.value, url: 'itemPackingTypes',
'option-value': 'code', fields: ['code', 'description'],
'option-label': 'description', where: { isActive: true },
dense: true, optionValue: 'code',
optionLabel: 'description',
inWhere: false,
}, },
}, },
format: (val) => dashIfEmpty(val), format: (row, dashIfEmpty) => dashIfEmpty(row.ipt),
headerClass: 'horizontal-separator',
}, },
{ {
align: 'left',
label: t('advanceTickets.state'), label: t('advanceTickets.state'),
name: 'state', name: 'state',
align: 'left', headerClass: 'horizontal-separator',
sortable: true, hidden: true,
columnFilter: null,
}, },
{ {
label: t('advanceTickets.preparation'), label: t('advanceTickets.preparation'),
@ -139,171 +83,105 @@ const ticketColumns = computed(() => [
field: 'preparation', field: 'preparation',
align: 'left', align: 'left',
sortable: true, sortable: true,
columnFilter: null, headerClass: 'horizontal-separator',
columnFilter: false,
}, },
{ {
label: t('advanceTickets.liters'),
name: 'liters',
field: 'liters',
align: 'left', align: 'left',
sortable: true, label: t('advanceTickets.liters'),
columnFilter: { headerClass: 'horizontal-separator',
component: VnInput, name: 'liters',
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.lines'), label: t('advanceTickets.lines'),
name: 'lines', name: 'lines',
field: 'lines', headerClass: 'horizontal-separator',
align: 'left', format: (row, dashIfEmpty) => dashIfEmpty(row.lines),
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.import'), label: t('advanceTickets.import'),
field: 'import', name: 'totalWithVat',
name: 'import', hidden: true,
align: 'left', headerClass: 'horizontal-separator',
sortable: true, format: (row) => toCurrency(row.totalWithVat),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureId'), label: t('advanceTickets.futureId'),
name: 'futureId', name: 'futureId',
align: 'left', headerClass: 'vertical-separator horizontal-separator',
sortable: true, columnClass: 'vertical-separator',
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
filterParamKey: 'futureId',
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.futureIpt'), label: t('advanceTickets.futureIpt'),
name: 'futureIpt', name: 'futureIpt',
field: 'futureIpt',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: 'select',
filterParamKey: 'futureIptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
options: itemPackingTypesOptions.value, url: 'itemPackingTypes',
'option-value': 'code', fields: ['code', 'description'],
'option-label': 'description', where: { isActive: true },
dense: true, optionValue: 'code',
optionLabel: 'description',
}, },
}, },
format: (val) => dashIfEmpty(val), headerClass: 'horizontal-separator',
format: (row, dashIfEmpty) => dashIfEmpty(row.futureIpt),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureState'), label: t('advanceTickets.futureState'),
name: 'futureState', name: 'futureState',
align: 'left', headerClass: 'horizontal-separator',
sortable: true, hidden: true,
columnFilter: null,
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureLiters'), label: t('advanceTickets.futureLiters'),
headerClass: 'horizontal-separator',
name: 'futureLiters', name: 'futureLiters',
field: 'futureLiters',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureZone'), label: t('advanceTickets.futureZone'),
name: 'futureZoneName', name: 'futureZoneFk',
field: 'futureZoneName', columnClass: 'expand',
align: 'left',
sortable: true,
columnFilter: { columnFilter: {
component: VnSelect, component: 'select',
type: 'select', inWhere: true,
filterValue: null,
filterParamKey: 'futureZoneFk',
event: getInputEvents,
attrs: { attrs: {
options: zonesOptions.value, url: 'Zones',
'option-value': 'id', fields: ['id', 'name'],
'option-label': 'name',
dense: true,
}, },
}, },
format: (val) => dashIfEmpty(val), columnField: {
component: null,
},
headerClass: 'horizontal-separator',
format: (row, dashIfEmpty) => dashIfEmpty(row.futureZoneName),
}, },
{ {
align: 'left',
label: t('advanceTickets.notMovableLines'), label: t('advanceTickets.notMovableLines'),
headerClass: 'horizontal-separator',
name: 'notMovableLines', name: 'notMovableLines',
field: 'notMovableLines',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureLines'), label: t('advanceTickets.futureLines'),
headerClass: 'horizontal-separator',
name: 'futureLines', name: 'futureLines',
field: 'futureLines',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
format: (val) => dashIfEmpty(val),
}, },
{ {
label: t('advanceTickets.futureImport'),
name: 'futureImport',
align: 'left', align: 'left',
sortable: true, label: t('advanceTickets.futureImport'),
columnFilter: null, name: 'futureTotalWithVat',
hidden: true,
headerClass: 'horizontal-separator',
format: (row) => toCurrency(row.futureTotalWithVat),
}, },
]); ]);
@ -329,7 +207,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
const query = `tickets/${ticket.futureId}/componentUpdate`; const query = `tickets/${ticket.futureId}/componentUpdate`;
if (!ticket.landed) { if (!ticket.landed) {
const newLanded = await getLanded({ const newLanded = await getLanded({
shipped: userParams.dateToAdvance, shipped: vnTableRef.value.params.dateToAdvance,
addressFk: ticket.futureAddressFk, addressFk: ticket.futureAddressFk,
agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk, agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
warehouseFk: ticket.futureWarehouseFk, warehouseFk: ticket.futureWarehouseFk,
@ -352,7 +230,7 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
zoneFk: ticket.zoneFk ?? ticket.futureZoneFk, zoneFk: ticket.zoneFk ?? ticket.futureZoneFk,
warehouseFk: ticket.futureWarehouseFk, warehouseFk: ticket.futureWarehouseFk,
companyFk: ticket.futureCompanyFk, companyFk: ticket.futureCompanyFk,
shipped: userParams.dateToAdvance, shipped: vnTableRef.value.params.dateToAdvance,
landed: ticket.landed, landed: ticket.landed,
isDeleted: false, isDeleted: false,
isWithoutNegatives, isWithoutNegatives,
@ -364,36 +242,31 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
}; };
const moveTicketsAdvance = async () => { const moveTicketsAdvance = async () => {
try { let ticketsToMove = [];
let ticketsToMove = []; for (const ticket of selectedTickets.value) {
for (const ticket of selectedTickets.value) { if (!ticket.id) {
if (!ticket.id) { try {
try { const { query, params } = await requestComponentUpdate(ticket, false);
const { query, params } = await requestComponentUpdate(ticket, false); axios.post(query, params);
axios.post(query, params); } catch (e) {
} catch (e) { console.error('Error moving ticket', e);
console.error('Error moving ticket', e);
}
continue;
} }
ticketsToMove.push({ continue;
originId: ticket.futureId,
destinationId: ticket.id,
originShipped: ticket.futureShipped,
destinationShipped: ticket.shipped,
workerFk: ticket.workerFk,
});
} }
ticketsToMove.push({
const params = { tickets: ticketsToMove }; originId: ticket.futureId,
await axios.post('Tickets/merge', params); destinationId: ticket.id,
arrayData.fetch({ append: false }); originShipped: ticket.futureShipped,
selectedTickets.value = []; destinationShipped: ticket.shipped,
if (ticketsToMove.length) workerFk: ticket.workerFk,
notify(t('advanceTickets.moveTicketSuccess'), 'positive'); });
} catch (error) {
console.error('Error moving tickets', error);
} }
const params = { tickets: ticketsToMove };
await axios.post('Tickets/merge', params);
vnTableRef.value.reload();
selectedTickets.value = [];
if (ticketsToMove.length) notify(t('advanceTickets.moveTicketSuccess'), 'positive');
}; };
const progressLength = ref(0); const progressLength = ref(0);
@ -434,10 +307,8 @@ const splitTickets = async () => {
progressAdd(ticket.futureId); progressAdd(ticket.futureId);
} }
} }
} catch (error) {
console.error('Error splitting tickets', error);
} finally { } finally {
arrayData.fetch({ append: false }); vnTableRef.value.reload();
} }
}; };
@ -455,19 +326,52 @@ const handleCloseProgressDialog = () => {
const handleCancelProgress = () => (cancelProgress.value = true); const handleCancelProgress = () => (cancelProgress.value = true);
onMounted(async () => { watch(
let today = Date.vnNew(); () => vnTableRef.value.tableRef?.$el,
const tomorrow = new Date(today); ($el) => {
tomorrow.setDate(tomorrow.getDate() + 1); if (!$el) return;
userParams.dateFuture = tomorrow; const head = $el.querySelector('thead');
userParams.dateToAdvance = today; const firstRow = $el.querySelector('thead > tr');
userParams.scopeDays = 1;
userParams.warehouseFk = user.value.warehouseFk;
const filter = { limit: 0 };
await arrayData.addFilter({ filter, userParams });
});
</script>
const newRow = document.createElement('tr');
destinationElRef.value = document.createElement('th');
originElRef.value = document.createElement('th');
newRow.classList.add('bg-header');
destinationElRef.value.classList.add('text-uppercase', 'color-vn-label');
originElRef.value.classList.add('text-uppercase', 'color-vn-label');
destinationElRef.value.setAttribute('colspan', '7');
originElRef.value.setAttribute('colspan', '9');
destinationElRef.value.textContent = `${t(
'advanceTickets.destination'
)} ${toDateFormat(vnTableRef.value.params.dateToAdvance)}`;
originElRef.value.textContent = `${t('advanceTickets.origin')} ${toDateFormat(
vnTableRef.value.params.dateFuture
)}`;
newRow.append(destinationElRef.value, originElRef.value);
head.insertBefore(newRow, firstRow);
},
{ once: true, inmmediate: true }
);
watch(
() => vnTableRef.value.params,
() => {
if (originElRef.value && destinationElRef.value) {
destinationElRef.value.textContent = `${t(
'advanceTickets.destination'
)} ${toDateFormat(vnTableRef.value.params.dateToAdvance)}`;
originElRef.value.textContent = `${t('advanceTickets.origin')} ${toDateFormat(
vnTableRef.value.params.dateFuture
)}`;
}
},
{ deep: true }
);
</script>
<template> <template>
<FetchData <FetchData
url="itemPackingTypes" url="itemPackingTypes"
@ -488,11 +392,6 @@ onMounted(async () => {
auto-load auto-load
@on-fetch="(data) => (zonesOptions = data)" @on-fetch="(data) => (zonesOptions = data)"
/> />
<VnSearchbar
data-key="WeeklyTickets"
:label="t('weeklyTickets.search')"
:info="t('weeklyTickets.searchInfo')"
/>
<VnSubToolbar> <VnSubToolbar>
<template #st-data> <template #st-data>
<QBtn <QBtn
@ -536,174 +435,109 @@ onMounted(async () => {
</VnSubToolbar> </VnSubToolbar>
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<TicketAdvanceFilter data-key="AdvanceTickets" /> <TicketAdvanceFilter data-key="advanceTickets" />
</template> </template>
</RightMenu> </RightMenu>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<QTable <VnTable
:rows="tickets" data-key="advanceTickets"
ref="vnTableRef"
url="Tickets/getTicketsAdvance"
search-url="advanceTickets"
:user-params="userParams"
:limit="0"
:columns="ticketColumns" :columns="ticketColumns"
row-key="index" :table="{
selection="multiple" 'row-key': '$index',
selection: 'multiple',
}"
v-model:selected="selectedTickets" v-model:selected="selectedTickets"
:pagination="{ rowsPerPage: 0 }" :pagination="{ rowsPerPage: 0 }"
:no-data-label="t('globals.noResults')" :no-data-label="t('globals.noResults')"
style="max-width: 99%" :right-search="false"
auto-load
:disable-option="{ card: true }"
> >
<template #header="props"> <template #column-icons="{ row }">
{{ userParams.scopeDays }} <QIcon
<QTr :props="props"> v-if="row.futureAgency !== row.agency && row.agency"
<QTh color="primary"
class="horizontal-separator text-uppercase color-vn-label" name="vn:agency-term"
colspan="7" size="xs"
translate >
> <QTooltip class="column">
{{ t('advanceTickets.destination') }} <span>
{{ toDateFormat(userParams.dateToAdvance) }} {{
</QTh> t('advanceTickets.originAgency', {
<QTh agency: row.futureAgency,
class="horizontal-separator text-uppercase color-vn-label" })
colspan="9" }}
translate </span>
> <span>
{{ t('advanceTickets.origin') }} {{
{{ toDateFormat(userParams.dateFuture) }} t('advanceTickets.destinationAgency', {
</QTh> agency: row.agency,
</QTr> })
<QTr> }}
<QTh> </span>
<QCheckbox v-model="props.selected" /> </QTooltip>
</QTh> </QIcon>
<QTh
v-for="(col, index) in ticketColumns"
:key="index"
:class="{ 'vertical-separator': col.name === 'futureId' }"
>
{{ col.label }}
</QTh>
</QTr>
</template> </template>
<template #top-row="{ cols }"> <template #column-id="{ row }">
<QTr> <QBtn flat class="link">
<QTd /> {{ row.id }}
<QTd <TicketDescriptorProxy :id="row.id" />
v-for="(col, index) in cols" </QBtn>
:key="index"
style="max-width: 100px"
>
<component
:is="col.columnFilter.component"
v-if="col.columnFilter"
v-model="col.columnFilter.filterValue"
v-bind="col.columnFilter.attrs"
v-on="col.columnFilter.event(col)"
dense
/>
</QTd>
</QTr>
</template> </template>
<template #header-cell-availableLines="{ col }"> <template #column-state="{ row }">
<QTh class="vertical-separator"> <QBadge
{{ col.label }} v-if="row.state"
</QTh> text-color="black"
:color="row.classColor"
class="q-ma-none"
dense
>
{{ row.state }}
</QBadge>
<span v-else> {{ dashIfEmpty(row.state) }}</span>
</template> </template>
<template #body-cell-icons="{ row }"> <template #column-import="{ row }">
<QTd class="q-gutter-x-xs"> <QBadge
<QIcon :text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'"
v-if="row.futureAgency !== row.agency && row.agency" :color="totalPriceColor(row.totalWithVat)"
color="primary" class="q-ma-none"
name="vn:agency-term" dense
size="xs" >
> {{ toCurrency(row.totalWithVat || 0) }}
<QTooltip class="column"> </QBadge>
<span>
{{
t('advanceTickets.originAgency', {
agency: row.futureAgency,
})
}}
</span>
<span>
{{
t('advanceTickets.destinationAgency', {
agency: row.agency,
})
}}
</span>
</QTooltip>
</QIcon>
</QTd>
</template> </template>
<template #column-futureId="{ row }">
<template #body-cell-ticketId="{ row }"> <QBtn flat class="link" dense>
<QTd> {{ row.futureId }}
<QBtn flat class="link"> <TicketDescriptorProxy :id="row.futureId" />
{{ row.id }} </QBtn>
<TicketDescriptorProxy :id="row.id" />
</QBtn>
</QTd>
</template> </template>
<template #body-cell-state="{ row }"> <template #column-futureState="{ row }">
<QTd> <QBadge
<QBadge text-color="black"
v-if="row.state" :color="row.futureClassColor"
text-color="black" class="q-ma-none"
:color="row.classColor" dense
class="q-ma-none" >
dense {{ row.futureState }}
> </QBadge>
{{ row.state }}
</QBadge>
<span v-else> {{ dashIfEmpty(row.state) }}</span>
</QTd>
</template> </template>
<template #body-cell-import="{ row }"> <template #column-futureImport="{ row }">
<QTd> <QBadge
<QBadge :text-color="isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'"
:text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'" :color="totalPriceColor(row.futureTotalWithVat)"
:color="totalPriceColor(row.totalWithVat)" class="q-ma-none"
class="q-ma-none" dense
dense >
> {{ toCurrency(row.futureTotalWithVat || 0) }}
{{ toCurrency(row.totalWithVat || 0) }} </QBadge>
</QBadge>
</QTd>
</template> </template>
<template #body-cell-futureId="{ row }"> </VnTable>
<QTd class="vertical-separator">
<QBtn flat class="link" dense>
{{ row.futureId }}
<TicketDescriptorProxy :id="row.futureId" />
</QBtn>
</QTd>
</template>
<template #body-cell-futureState="{ row }">
<QTd>
<QBadge
text-color="black"
:color="row.futureClassColor"
class="q-ma-none"
dense
>
{{ row.futureState }}
</QBadge>
</QTd>
</template>
<template #body-cell-futureImport="{ row }">
<QTd>
<QBadge
:text-color="
isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'
"
:color="totalPriceColor(row.futureTotalWithVat)"
class="q-ma-none"
dense
>
{{ toCurrency(row.futureTotalWithVat || 0) }}
</QBadge>
</QTd>
</template>
</QTable>
<VnProgress <VnProgress
:progress="progressPercentage" :progress="progressPercentage"
:cancelled="cancelProgress" :cancelled="cancelProgress"
@ -722,11 +556,11 @@ onMounted(async () => {
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.vertical-separator { :deep(.vertical-separator) {
border-left: 4px solid white !important; border-left: 4px solid white !important;
} }
.horizontal-separator { :deep(.horizontal-separator) {
border-bottom: 4px solid white !important; border-top: 4px solid white !important;
} }
</style> </style>

View File

@ -11,7 +11,7 @@ import axios from 'axios';
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue'; import VnInputNumber from 'src/components/common/VnInputNumber.vue';
const { t } = useI18n(); const { t, te } = useI18n();
const props = defineProps({ const props = defineProps({
dataKey: { dataKey: {
type: String, type: String,
@ -27,20 +27,21 @@ const warehousesOptions = ref([]);
const itemPackingTypes = ref([]); const itemPackingTypes = ref([]);
const getItemPackingTypes = async () => { const getItemPackingTypes = async () => {
try { const filter = {
const filter = { where: { isActive: true },
where: { isActive: true }, };
}; const { data } = await axios.get('ItemPackingTypes', {
const { data } = await axios.get('ItemPackingTypes', { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); itemPackingTypes.value = data.map((ipt) => ({
itemPackingTypes.value = data.map((ipt) => ({ description: t(ipt.description),
description: t(ipt.description), code: ipt.code,
code: ipt.code, }));
})); };
} catch (error) {
console.error(error); const getLocale = (val) => {
} const param = `params.${val}`;
return te(param) ? t(param) : t(`globals.${param}`);
}; };
onMounted(async () => await getItemPackingTypes()); onMounted(async () => await getItemPackingTypes());
@ -53,6 +54,7 @@ onMounted(async () => await getItemPackingTypes());
auto-load auto-load
/> />
<VnFilterPanel <VnFilterPanel
search-url="advanceTickets"
:data-key="props.dataKey" :data-key="props.dataKey"
:search-button="true" :search-button="true"
:hidden-tags="['search']" :hidden-tags="['search']"
@ -60,7 +62,7 @@ onMounted(async () => await getItemPackingTypes());
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ getLocale(tag.label) }}: </strong>
<span>{{ formatFn(tag.value) }}</span> <span>{{ formatFn(tag.value) }}</span>
</div> </div>
</template> </template>
@ -96,6 +98,7 @@ onMounted(async () => await getItemPackingTypes());
dense dense
outlined outlined
rounded rounded
:use-like="false"
> >
</VnSelect> </VnSelect>
</QItemSection> </QItemSection>
@ -113,6 +116,7 @@ onMounted(async () => await getItemPackingTypes());
dense dense
outlined outlined
rounded rounded
:use-like="false"
> >
</VnSelect> </VnSelect>
</QItemSection> </QItemSection>
@ -136,6 +140,19 @@ onMounted(async () => await getItemPackingTypes());
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('globals.params.departmentFk')"
v-model="params.departmentFk"
url="Departments"
:fields="['id', 'name']"
dense
outlined
rounded
/>
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnSelect <VnSelect

View File

@ -20,11 +20,31 @@ const provinces = ref([]);
const states = ref([]); const states = ref([]);
const agencies = ref([]); const agencies = ref([]);
const warehouses = ref([]); const warehouses = ref([]);
const groupedStates = ref([]);
const getGroupedStates = (data) => {
for (const state of data) {
groupedStates.value.push({
id: state.id,
name: t(`${state.code}`),
code: state.code,
});
}
};
</script> </script>
<template> <template>
<FetchData url="Provinces" @on-fetch="(data) => (provinces = data)" auto-load /> <FetchData url="Provinces" @on-fetch="(data) => (provinces = data)" auto-load />
<FetchData url="States" @on-fetch="(data) => (states = data)" auto-load /> <FetchData url="States" @on-fetch="(data) => (states = data)" auto-load />
<FetchData
url="AlertLevels"
@on-fetch="
(data) => {
getGroupedStates(data);
}
"
auto-load
/>
<FetchData url="AgencyModes" @on-fetch="(data) => (agencies = data)" auto-load /> <FetchData url="AgencyModes" @on-fetch="(data) => (agencies = data)" auto-load />
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load /> <FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table"> <VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table">
@ -90,12 +110,35 @@ const warehouses = ref([]);
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
use-input
dense dense
outlined outlined
rounded rounded
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection v-if="!groupedStates">
<QSkeleton type="QInput" class="full-width" />
</QItemSection>
<QItemSection v-if="groupedStates">
<QSelect
:label="t('Grouped state')"
v-model="params.groupedStates"
@update:model-value="searchFn()"
:options="groupedStates"
option-value="id"
option-label="name"
emit-value
map-options
use-input
dense
outlined
rounded
sort-by="name ASC"
/>
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnInput <VnInput
@ -114,6 +157,15 @@ const warehouses = ref([]);
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<VnInput
v-model="params.nickname"
:label="t('Nickname')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<QCheckbox <QCheckbox
@ -176,6 +228,7 @@ const warehouses = ref([]);
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
use-input
dense dense
outlined outlined
rounded rounded
@ -196,6 +249,7 @@ const warehouses = ref([]);
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
use-input
dense dense
outlined outlined
rounded rounded
@ -216,12 +270,22 @@ const warehouses = ref([]);
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
use-input
dense dense
outlined outlined
rounded rounded
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<VnInput
v-model="params.collectionFk"
:label="t('Collection')"
is-outlined
/>
</QItemSection>
</QItem>
</QExpansionItem> </QExpansionItem>
</template> </template>
</VnFilterPanel> </VnFilterPanel>
@ -245,6 +309,11 @@ en:
provinceFk: Province provinceFk: Province
agencyModeFk: Agency agencyModeFk: Agency
warehouseFk: Warehouse warehouseFk: Warehouse
FREE: Free
ON_PREPARATION: On preparation
PACKED: Packed
DELIVERED: Delivered
ON_PREVIOUS: ON_PREVIOUS
es: es:
params: params:
search: Contiene search: Contiene
@ -278,4 +347,12 @@ es:
Yes: Si Yes: Si
No: No No: No
Days onward: Días adelante Days onward: Días adelante
Grouped state: Estado agrupado
FREE: Libre
ON_PREPARATION: En preparación
PACKED: Encajado
DELIVERED: Servido
ON_PREVIOUS: ON_PREVIOUS
Collection: Colección
Nickname: Nombre mostrado
</i18n> </i18n>

View File

@ -24,33 +24,25 @@ const itemPackingTypes = ref([]);
const stateOptions = ref([]); const stateOptions = ref([]);
const getItemPackingTypes = async () => { const getItemPackingTypes = async () => {
try { const filter = {
const filter = { where: { isActive: true },
where: { isActive: true }, };
}; const { data } = await axios.get('ItemPackingTypes', {
const { data } = await axios.get('ItemPackingTypes', { params: { filter: JSON.stringify(filter) },
params: { filter: JSON.stringify(filter) }, });
}); itemPackingTypes.value = data.map((ipt) => ({
itemPackingTypes.value = data.map((ipt) => ({ description: t(ipt.description),
description: t(ipt.description), code: ipt.code,
code: ipt.code, }));
}));
} catch (error) {
console.error(error);
}
}; };
const getGroupedStates = async () => { const getGroupedStates = async () => {
try { const { data } = await axios.get('AlertLevels');
const { data } = await axios.get('AlertLevels'); stateOptions.value = data.map((state) => ({
stateOptions.value = data.map((state) => ({ id: state.id,
id: state.id, name: t(`futureTickets.${state.code}`),
name: t(`futureTickets.${state.code}`), code: state.code,
code: state.code, }));
}));
} catch (error) {
console.error(error);
}
}; };
onMounted(async () => { onMounted(async () => {

View File

@ -95,6 +95,7 @@ const columns = computed(() => [
columnField: { columnField: {
component: null, component: null,
}, },
columnClass: 'expand',
format: (row, dashIfEmpty) => dashIfEmpty(row.salesPerson), format: (row, dashIfEmpty) => dashIfEmpty(row.salesPerson),
}, },
{ {
@ -153,11 +154,6 @@ const columns = computed(() => [
}, },
columnClass: 'expand', columnClass: 'expand',
}, },
{
align: 'left',
name: 'refFk',
label: t('ticketList.ref'),
},
{ {
align: 'left', align: 'left',
name: 'zoneFk', name: 'zoneFk',
@ -191,6 +187,12 @@ const columns = computed(() => [
}, },
format: (row) => toCurrency(row.totalWithVat), format: (row) => toCurrency(row.totalWithVat),
}, },
{
align: 'left',
name: 'packing',
label: t('ticketSale.packaging'),
format: (row, dashIfEmpty) => dashIfEmpty(row.packing),
},
{ {
align: 'right', align: 'right',
name: 'tableActions', name: 'tableActions',
@ -202,7 +204,7 @@ const columns = computed(() => [
action: (row) => redirectToLines(row.id), action: (row) => redirectToLines(row.id),
}, },
{ {
title: t('ticketList.summary'), title: t('components.smartCard.viewSummary'),
icon: 'preview', icon: 'preview',
isPrimary: true, isPrimary: true,
action: (row) => viewSummary(row.id, TicketSummary), action: (row) => viewSummary(row.id, TicketSummary),
@ -548,7 +550,7 @@ function setReference(data) {
</template> </template>
<template #column-salesPersonFk="{ row }"> <template #column-salesPersonFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row.salesPerson }} {{ dashIfEmpty(row.userName) }}
<CustomerDescriptorProxy :id="row.salesPersonFk" /> <CustomerDescriptorProxy :id="row.salesPersonFk" />
</span> </span>
</template> </template>
@ -577,16 +579,16 @@ function setReference(data) {
{{ row.state }} {{ row.state }}
</QChip> </QChip>
</span> </span>
<span v-else-if="row.state === 'Entregado'">
<span class="link" @click.stop>
{{ row.refFk }}
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</span>
</span>
<span v-else> <span v-else>
{{ row.state }} {{ row.state }}
</span> </span>
</template> </template>
<template #column-refFk="{ row }">
<span class="link" @click.stop>
{{ dashIfEmpty(row.refFk) }}
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</span>
</template>
<template #column-zoneFk="{ row }"> <template #column-zoneFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ dashIfEmpty(row.zoneName) }} {{ dashIfEmpty(row.zoneName) }}

View File

@ -100,7 +100,7 @@ weeklyTickets:
advanceTickets: advanceTickets:
preparation: Preparación preparation: Preparación
origin: Origen origin: Origen
destination: Destinatario destination: Destino
originAgency: 'Agencia origen: {agency}' originAgency: 'Agencia origen: {agency}'
destinationAgency: 'Agencia destino: {agency}' destinationAgency: 'Agencia destino: {agency}'
ticketId: ID ticketId: ID

View File

@ -72,6 +72,16 @@ const agenciesOptions = ref([]);
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnInput v-model="data.m3" label="m3" /> <VnInput v-model="data.m3" label="m3" />
<VnInput
:label="t('travel.basicData.daysInForward')"
v-model="data.daysInForward"
>
<template #append>
<QIcon name="info" class="cursor-info">
<QTooltip>{{ t('raidDays') }}</QTooltip>
</QIcon>
</template>
</VnInput>
</VnRow> </VnRow>
<VnRow> <VnRow>
<QCheckbox <QCheckbox
@ -86,3 +96,10 @@ const agenciesOptions = ref([]);
</template> </template>
</FormModel> </FormModel>
</template> </template>
<i18n>
es:
raidDays: Al rellenarlo, generamos una redada. Indica los días que un travel se moverá automáticamente en el tiempo
en:
raidDays: When filling, a raid is generated. Enter the number of days the travel will automatically forward in time
</i18n>

View File

@ -32,6 +32,7 @@ const filter = {
'warehouseOutFk', 'warehouseOutFk',
'cargoSupplierFk', 'cargoSupplierFk',
'agencyModeFk', 'agencyModeFk',
'daysInForward',
], ],
include: [ include: [
{ {
@ -77,6 +78,22 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
<VnLv :label="t('globals.landed')" :value="toDate(entity.landed)" /> <VnLv :label="t('globals.landed')" :value="toDate(entity.landed)" />
<VnLv :label="t('globals.totalEntries')" :value="entity.totalEntries" /> <VnLv :label="t('globals.totalEntries')" :value="entity.totalEntries" />
</template> </template>
<template #icons="{ entity }">
<QCardActions class="q-gutter-x-md">
<QIcon
v-if="entity.daysInForward"
name="vn:net"
color="primary"
size="xs"
>
<QTooltip>
{{
t('globals.raid', { daysInForward: entity.daysInForward })
}}</QTooltip
>
</QIcon>
</QCardActions>
</template>
<template #actions="{ entity }"> <template #actions="{ entity }">
<QCardActions> <QCardActions>
<QBtn <QBtn

View File

@ -303,6 +303,10 @@ const getLink = (param) => `#/travel/${entityId.value}/${param}`;
<VnLv :label="t('globals.reference')" :value="travel.ref" /> <VnLv :label="t('globals.reference')" :value="travel.ref" />
<VnLv label="m³" :value="travel.m3" /> <VnLv label="m³" :value="travel.m3" />
<VnLv :label="t('globals.totalEntries')" :value="travel.totalEntries" /> <VnLv :label="t('globals.totalEntries')" :value="travel.totalEntries" />
<VnLv
:label="t('travel.basicData.daysInForward')"
:value="travel?.daysInForward"
/>
</QCard> </QCard>
<QCard class="full-width"> <QCard class="full-width">
<VnTitle :text="t('travel.summary.entries')" /> <VnTitle :text="t('travel.summary.entries')" />

View File

@ -45,6 +45,10 @@ const redirectCreateEntryView = (travelData) => {
}; };
const columns = computed(() => [ const columns = computed(() => [
{
name: 'status',
columnFilter: false,
},
{ {
align: 'left', align: 'left',
name: 'id', name: 'id',
@ -221,6 +225,17 @@ const columns = computed(() => [
:is-editable="false" :is-editable="false"
:use-model="true" :use-model="true"
> >
<template #column-status="{ row }">
<div class="row">
<QIcon v-if="!!row.daysInForward" name="vn:net" color="primary">
<QTooltip>
{{
t('globals.raid', { daysInForward: row.daysInForward })
}}</QTooltip
>
</QIcon>
</div>
</template>
<template #column-shipped="{ row }"> <template #column-shipped="{ row }">
<QBadge <QBadge
text-color="black" text-color="black"

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref, onBeforeMount } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
@ -8,32 +8,22 @@ import FormModel from 'src/components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const educationLevels = ref([]); const educationLevels = ref([]);
const countries = ref([]); const countries = ref([]);
const maritalStatus = [ const maritalStatus = [
{ code: 'M', name: t('Married') }, { code: 'M', name: t('Married') },
{ code: 'S', name: t('Single') }, { code: 'S', name: t('Single') },
]; ];
const advancedSummary = ref({});
const workerFilter = { onBeforeMount(async () => {
include: [ advancedSummary.value =
{ (await useAdvancedSummary('Workers', +useRoute().params.id)) ?? {};
relation: 'user', });
scope: {
fields: ['name', 'emailVerified'],
include: { relation: 'emailUser', scope: { fields: ['email'] } },
},
},
{ relation: 'sip', scope: { fields: ['extension', 'secret'] } },
{ relation: 'department', scope: { include: { relation: 'department' } } },
],
};
</script> </script>
<template> <template>
<FetchData <FetchData
:filter="{ fields: ['id', 'name'], order: 'name ASC' }" :filter="{ fields: ['id', 'name'], order: 'name ASC' }"
@ -48,10 +38,16 @@ const workerFilter = {
auto-load auto-load
/> />
<FormModel <FormModel
:filter="workerFilter" :filter="{ where: { id: +$route.params.id } }"
:url="`Workers/${route.params.id}`" url="Workers/summary"
:url-update="`Workers/${$route.params.id}`"
auto-load auto-load
model="Worker" model="Worker"
@on-fetch="
async (data) => {
Object.assign(data, advancedSummary);
}
"
> >
<template #form="{ data }"> <template #form="{ data }">
<VnRow> <VnRow>
@ -134,7 +130,7 @@ const workerFilter = {
<VnInput v-model="data.fi" :label="t('fi')" /> <VnInput v-model="data.fi" :label="t('fi')" />
<VnInputDate :label="t('birth')" v-model="data.birth" /> <VnInputDate :label="t('birth')" v-model="data.birth" />
</VnRow> </VnRow>
<VnRow> <VnRow wrap>
<QCheckbox <QCheckbox
size="sm" size="sm"
:label="t('isFreelance')" :label="t('isFreelance')"

View File

@ -6,7 +6,7 @@ import WorkerFilter from '../WorkerFilter.vue';
<template> <template>
<VnCard <VnCard
data-key="Worker" data-key="Worker"
base-url="Workers" custom-url="Workers/summary"
:descriptor="WorkerDescriptor" :descriptor="WorkerDescriptor"
:filter-panel="WorkerFilter" :filter-panel="WorkerFilter"
search-data-key="WorkerList" search-data-key="WorkerList"

View File

@ -17,6 +17,11 @@ const $props = defineProps({
required: false, required: false,
default: null, default: null,
}, },
dataKey: {
type: String,
required: false,
default: 'workerData',
},
}); });
const image = ref(null); const image = ref(null);
@ -65,7 +70,7 @@ const handlePhotoUpdated = (evt = false) => {
<CardDescriptor <CardDescriptor
ref="cardDescriptorRef" ref="cardDescriptorRef"
module="Worker" module="Worker"
data-key="workerData" :data-key="dataKey"
url="Workers/descriptor" url="Workers/descriptor"
:filter="{ where: { id: entityId } }" :filter="{ where: { id: entityId } }"
title="user.nickname" title="user.nickname"

Some files were not shown because too many files have changed in this diff Show More