Merge branch '7248-tablesObservation' of https://gitea.verdnatura.es/verdnatura/salix-front into 7248-tablesObservation
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
gitea/salix-front/pipeline/pr-dev This commit is unstable
Details
This commit is contained in:
commit
d5fc3423d6
|
@ -347,8 +347,8 @@ watch(formUrl, async () => {
|
|||
<QBtnDropdown
|
||||
v-if="$props.goTo && $props.defaultSave"
|
||||
@click="onSubmitAndGo"
|
||||
:label="tMobile('globals.saveAndContinue')"
|
||||
:title="t('globals.saveAndContinue')"
|
||||
:label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:disable="!hasChanges"
|
||||
color="primary"
|
||||
icon="save"
|
||||
|
|
|
@ -380,8 +380,8 @@ defineExpose({
|
|||
data-cy="saveAndContinueDefaultBtn"
|
||||
v-if="$props.goTo"
|
||||
@click="saveAndGo"
|
||||
:label="tMobile('globals.saveAndContinue')"
|
||||
:title="t('globals.saveAndContinue')"
|
||||
:label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:disable="!hasChanges"
|
||||
color="primary"
|
||||
icon="save"
|
||||
|
|
|
@ -35,6 +35,7 @@ import { getColAlign } from 'src/composables/getColAlign';
|
|||
import RightMenu from '../common/RightMenu.vue';
|
||||
import VnScroll from '../common/VnScroll.vue';
|
||||
import VnCheckboxMenu from '../common/VnCheckboxMenu.vue';
|
||||
import VnCheckbox from '../common/VnCheckbox.vue';
|
||||
|
||||
const arrayData = useArrayData(useAttrs()['data-key']);
|
||||
const $props = defineProps({
|
||||
|
@ -332,6 +333,7 @@ function stopEventPropagation(event) {
|
|||
|
||||
function reload(params) {
|
||||
selected.value = [];
|
||||
selectAll.value = false;
|
||||
CrudModelRef.value.reload(params);
|
||||
}
|
||||
|
||||
|
@ -645,7 +647,7 @@ const rowCtrlClickFunction = computed(() => {
|
|||
return () => {};
|
||||
});
|
||||
const handleHeaderSelection = (evt, data) => {
|
||||
if (evt === 'selected' && data) {
|
||||
if (evt === 'updateSelected' && selectAll.value) {
|
||||
selected.value = tableRef.value.rows;
|
||||
} else if (evt === 'selectAll') {
|
||||
selected.value = data;
|
||||
|
@ -680,7 +682,13 @@ const handleHeaderSelection = (evt, data) => {
|
|||
:class="$attrs['class'] ?? 'q-px-md'"
|
||||
:limit="$attrs['limit'] ?? 100"
|
||||
ref="CrudModelRef"
|
||||
@on-fetch="(...args) => emit('onFetch', ...args)"
|
||||
@on-fetch="
|
||||
(...args) => {
|
||||
selectAll = false;
|
||||
selected = [];
|
||||
emit('onFetch', ...args);
|
||||
}
|
||||
"
|
||||
:search-url="searchUrl"
|
||||
:disable-infinite-scroll="isTableMode"
|
||||
:before-save-fn="removeTextValue"
|
||||
|
@ -718,14 +726,23 @@ const handleHeaderSelection = (evt, data) => {
|
|||
:data-cy
|
||||
>
|
||||
<template #header-selection>
|
||||
<VnCheckboxMenu
|
||||
:searchUrl="searchUrl"
|
||||
:expand="$props.multiCheck.expand"
|
||||
v-model="selectAll"
|
||||
:url="$attrs['url']"
|
||||
@update:selected="handleHeaderSelection('selected', $event)"
|
||||
@select:all="handleHeaderSelection('selectAll', $event)"
|
||||
/>
|
||||
<div class="flex items-center no-wrap" style="display: flex">
|
||||
<VnCheckbox
|
||||
v-model="selectAll"
|
||||
@click="handleHeaderSelection('updateSelected', $event)"
|
||||
/>
|
||||
|
||||
<VnCheckboxMenu
|
||||
v-if="selectAll && $props.multiCheck.expand"
|
||||
:searchUrl="searchUrl"
|
||||
v-model="selectAll"
|
||||
:url="$attrs['url']"
|
||||
@update:selected="
|
||||
handleHeaderSelection('updateSelected', $event)
|
||||
"
|
||||
@select:all="handleHeaderSelection('selectAll', $event)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #top-left v-if="!$props.withoutHeader">
|
||||
|
|
|
@ -9,10 +9,6 @@ const route = useRoute();
|
|||
const { t } = useI18n();
|
||||
const model = defineModel({ type: [Boolean] });
|
||||
const props = defineProps({
|
||||
expand: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
@ -22,29 +18,26 @@ const props = defineProps({
|
|||
default: 'table',
|
||||
},
|
||||
});
|
||||
const value = ref(false);
|
||||
const menuRef = ref(null);
|
||||
const errorMessage = ref(null);
|
||||
const rows = ref(0);
|
||||
const onClick = async () => {
|
||||
errorMessage.value = null;
|
||||
|
||||
if (value.value) {
|
||||
const { filter } = JSON.parse(route.query[props.searchUrl]);
|
||||
filter.limit = 0;
|
||||
const params = {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
};
|
||||
try {
|
||||
const { data } = await axios.get(props.url, params);
|
||||
rows.value = data;
|
||||
} catch (error) {
|
||||
const response = error.response;
|
||||
if (response.data.error.name === 'UserError') {
|
||||
errorMessage.value = t('tooManyResults');
|
||||
} else {
|
||||
errorMessage.value = response.data.error.message;
|
||||
}
|
||||
const { filter } = JSON.parse(route.query[props.searchUrl]);
|
||||
filter.limit = 0;
|
||||
const params = {
|
||||
params: { filter: JSON.stringify(filter) },
|
||||
};
|
||||
try {
|
||||
const { data } = axios.get(props.url, params);
|
||||
rows.value = data;
|
||||
} catch (error) {
|
||||
const response = error.response;
|
||||
if (response.data.error.name === 'UserError') {
|
||||
errorMessage.value = t('tooManyResults');
|
||||
} else {
|
||||
errorMessage.value = response.data.error.message;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -52,57 +45,53 @@ defineEmits(['update:selected', 'select:all']);
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex items-center no-wrap" style="display: flex">
|
||||
<VnCheckbox v-model="value" @click="$emit('update:selected', value)" />
|
||||
<QIcon
|
||||
style="margin-left: -10px"
|
||||
data-cy="btnMultiCheck"
|
||||
v-if="value && $props.expand"
|
||||
name="expand_more"
|
||||
@click="onClick"
|
||||
class="cursor-pointer"
|
||||
color="primary"
|
||||
size="xs"
|
||||
<QIcon
|
||||
style="margin-left: -10px"
|
||||
data-cy="btnMultiCheck"
|
||||
name="expand_more"
|
||||
@click="onClick"
|
||||
class="cursor-pointer"
|
||||
color="primary"
|
||||
size="xs"
|
||||
>
|
||||
<QMenu
|
||||
fit
|
||||
anchor="bottom start"
|
||||
self="top left"
|
||||
ref="menuRef"
|
||||
data-cy="menuMultiCheck"
|
||||
>
|
||||
<QMenu
|
||||
fit
|
||||
anchor="bottom start"
|
||||
self="top left"
|
||||
ref="menuRef"
|
||||
data-cy="menuMultiCheck"
|
||||
>
|
||||
<QList separator>
|
||||
<QItem
|
||||
data-cy="selectAll"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
$refs.menuRef.hide();
|
||||
$emit('select:all', toRaw(rows));
|
||||
"
|
||||
>
|
||||
<QItemSection>
|
||||
<QItemLabel>
|
||||
<span v-text="t('Select all')" />
|
||||
</QItemLabel>
|
||||
<QItemLabel overline caption>
|
||||
<span
|
||||
v-if="errorMessage"
|
||||
class="text-negative"
|
||||
v-text="errorMessage"
|
||||
/>
|
||||
<span
|
||||
v-else
|
||||
v-text="t('records', { rows: rows.length })"
|
||||
/>
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<slot name="more-options"></slot>
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QIcon>
|
||||
</div>
|
||||
<QList separator>
|
||||
<QItem
|
||||
data-cy="selectAll"
|
||||
v-ripple
|
||||
clickable
|
||||
@click="
|
||||
$refs.menuRef.hide();
|
||||
$emit('select:all', toRaw(rows));
|
||||
"
|
||||
>
|
||||
<QItemSection>
|
||||
<QItemLabel>
|
||||
<span v-text="t('Select all')" />
|
||||
</QItemLabel>
|
||||
<QItemLabel overline caption>
|
||||
<span
|
||||
v-if="errorMessage"
|
||||
class="text-negative"
|
||||
v-text="errorMessage"
|
||||
/>
|
||||
<span
|
||||
v-else
|
||||
v-text="t('records', { rows: rows.length ?? 0 })"
|
||||
/>
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<slot name="more-options"></slot>
|
||||
</QList>
|
||||
</QMenu>
|
||||
</QIcon>
|
||||
</template>
|
||||
<i18n lang="yml">
|
||||
en:
|
||||
|
|
|
@ -132,8 +132,7 @@ const card = toRef(props, 'item');
|
|||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
white-space: nowrap;
|
||||
width: 192px;
|
||||
|
||||
p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { ref, reactive, useAttrs, computed } from 'vue';
|
||||
import { onBeforeRouteLeave } from 'vue-router';
|
||||
import { ref, reactive, useAttrs, computed, onMounted, nextTick, } from 'vue';
|
||||
import { onBeforeRouteLeave , useRouter, useRoute} from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import { toDateHourMin } from 'src/filters';
|
||||
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
|
@ -33,10 +34,15 @@ const $props = defineProps({
|
|||
addNote: { type: Boolean, default: false },
|
||||
selectType: { type: Boolean, default: false },
|
||||
justInput: { type: Boolean, default: false },
|
||||
goTo: { type: String, default: '', },
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const stateStore = useStateStore();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const componentIsRendered = ref(false);
|
||||
const newNote = reactive({ text: null, observationTypeFk: null });
|
||||
const observationTypes = ref([]);
|
||||
const vnPaginateRef = ref();
|
||||
|
@ -45,6 +51,7 @@ const defaultObservationType = computed(() =>
|
|||
observationTypes.value.find(ot => ot.code === 'salesPerson')?.id
|
||||
);
|
||||
|
||||
let savedNote = false;
|
||||
let originalText;
|
||||
|
||||
function handleClick(e) {
|
||||
|
@ -68,6 +75,7 @@ async function insert() {
|
|||
};
|
||||
await axios.post($props.url, newBody);
|
||||
await vnPaginateRef.value.fetch();
|
||||
savedNote = true;
|
||||
}
|
||||
|
||||
function confirmAndUpdate() {
|
||||
|
@ -129,8 +137,29 @@ const handleObservationTypes = (data) => {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => (componentIsRendered.value = true));
|
||||
});
|
||||
|
||||
async function saveAndGo() {
|
||||
savedNote = false;
|
||||
await insert();
|
||||
await savedNote;
|
||||
router.push({ path: $props.goTo });
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && componentIsRendered && $props.goTo && !route.path.includes('summary')">
|
||||
<QBtn
|
||||
:label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
:title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
|
||||
color="primary"
|
||||
icon="save"
|
||||
@click="saveAndGo"
|
||||
data-cy="saveContinueNoteButton"
|
||||
/>
|
||||
</Teleport>
|
||||
<FetchData
|
||||
v-if="selectType"
|
||||
url="ObservationTypes"
|
||||
|
@ -176,7 +205,7 @@ const handleObservationTypes = (data) => {
|
|||
:required="'required' in originalAttrs"
|
||||
clearable
|
||||
>
|
||||
<template #append>
|
||||
<template #append v-if="!$props.goTo">
|
||||
<QBtn
|
||||
:title="t('Save (Enter)')"
|
||||
icon="save"
|
||||
|
|
|
@ -6,6 +6,7 @@ import toDateHourMinSec from './toDateHourMinSec';
|
|||
import toRelativeDate from './toRelativeDate';
|
||||
import toCurrency from './toCurrency';
|
||||
import toPercentage from './toPercentage';
|
||||
import toNumber from './toNumber';
|
||||
import toLowerCamel from './toLowerCamel';
|
||||
import dashIfEmpty from './dashIfEmpty';
|
||||
import dateRange from './dateRange';
|
||||
|
@ -34,6 +35,7 @@ export {
|
|||
toRelativeDate,
|
||||
toCurrency,
|
||||
toPercentage,
|
||||
toNumber,
|
||||
dashIfEmpty,
|
||||
dateRange,
|
||||
getParamWhere,
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
export default function (value, fractionSize = 2) {
|
||||
if (isNaN(value)) return value;
|
||||
return new Intl.NumberFormat('es-ES', {
|
||||
style: 'decimal',
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: fractionSize,
|
||||
}).format(value);
|
||||
}
|
|
@ -24,13 +24,14 @@ globals:
|
|||
dataDeleted: Data deleted
|
||||
delete: Delete
|
||||
search: Search
|
||||
lines: Lines
|
||||
changes: Changes
|
||||
dataCreated: Data created
|
||||
add: Add
|
||||
create: Create
|
||||
edit: Edit
|
||||
save: Save
|
||||
saveAndContinue: Save and continue
|
||||
saveAndContinue: Save and go to
|
||||
remove: Remove
|
||||
reset: Reset
|
||||
close: Close
|
||||
|
@ -107,6 +108,8 @@ globals:
|
|||
from: From
|
||||
to: To
|
||||
notes: Notes
|
||||
photos: Photos
|
||||
due-day: Due day
|
||||
refresh: Refresh
|
||||
item: Item
|
||||
ticket: Ticket
|
||||
|
@ -122,6 +125,7 @@ globals:
|
|||
producer: Producer
|
||||
origin: Origin
|
||||
state: State
|
||||
total: Total
|
||||
subtotal: Subtotal
|
||||
visible: Visible
|
||||
price: Price
|
||||
|
@ -347,6 +351,7 @@ globals:
|
|||
vehicleList: Vehicles
|
||||
vehicle: Vehicle
|
||||
entryPreAccount: Pre-account
|
||||
management: Worker management
|
||||
unsavedPopup:
|
||||
title: Unsaved changes will be lost
|
||||
subtitle: Are you sure exit without saving?
|
||||
|
@ -395,6 +400,7 @@ errors:
|
|||
updateUserConfig: Error updating user config
|
||||
tokenConfig: Error fetching token config
|
||||
writeRequest: The requested operation could not be completed
|
||||
claimBeginningQuantity: Cannot import a line with a claimed quantity of 0
|
||||
login:
|
||||
title: Login
|
||||
username: Username
|
||||
|
|
|
@ -25,12 +25,13 @@ globals:
|
|||
openDetail: Ver detalle
|
||||
delete: Eliminar
|
||||
search: Buscar
|
||||
lines: Lineas
|
||||
changes: Cambios
|
||||
add: Añadir
|
||||
create: Crear
|
||||
edit: Modificar
|
||||
save: Guardar
|
||||
saveAndContinue: Guardar y continuar
|
||||
saveAndContinue: Guardar e ir a
|
||||
remove: Eliminar
|
||||
reset: Restaurar
|
||||
close: Cerrar
|
||||
|
@ -111,6 +112,8 @@ globals:
|
|||
from: Desde
|
||||
to: Hasta
|
||||
notes: Notas
|
||||
photos: Fotos
|
||||
due-day: Vencimiento
|
||||
refresh: Actualizar
|
||||
item: Artículo
|
||||
ticket: Ticket
|
||||
|
@ -126,6 +129,7 @@ globals:
|
|||
producer: Productor
|
||||
origin: Origen
|
||||
state: Estado
|
||||
total: Total
|
||||
subtotal: Subtotal
|
||||
visible: Visible
|
||||
price: Precio
|
||||
|
@ -350,6 +354,7 @@ globals:
|
|||
vehicleList: Vehículos
|
||||
vehicle: Vehículo
|
||||
entryPreAccount: Precontabilizar
|
||||
management: Gestión de trabajadores
|
||||
unsavedPopup:
|
||||
title: Los cambios que no haya guardado se perderán
|
||||
subtitle: ¿Seguro que quiere salir sin guardar?
|
||||
|
@ -391,6 +396,7 @@ errors:
|
|||
updateUserConfig: Error al actualizar la configuración de usuario
|
||||
tokenConfig: Error al obtener configuración de token
|
||||
writeRequest: No se pudo completar la operación solicitada
|
||||
claimBeginningQuantity: No se puede importar una linea sin una cantidad reclamada
|
||||
login:
|
||||
title: Inicio de sesión
|
||||
username: Nombre de usuario
|
||||
|
|
|
@ -13,8 +13,10 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
|||
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { notify } = useNotify();
|
||||
const quasar = useQuasar();
|
||||
const route = useRoute();
|
||||
const claim = ref(null);
|
||||
|
@ -176,12 +178,17 @@ async function save(data) {
|
|||
}
|
||||
|
||||
async function importToNewRefundTicket() {
|
||||
await post(`ClaimBeginnings/${claimId}/importToNewRefundTicket`);
|
||||
await claimActionsForm.value.reload();
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
try{
|
||||
await post(`ClaimBeginnings/${claimId}/importToNewRefundTicket`);
|
||||
await claimActionsForm.value.reload();
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
} catch (error) {
|
||||
const errorMessage = error.response?.data?.error?.message;
|
||||
notify( t(errorMessage), 'negative' );
|
||||
}
|
||||
}
|
||||
|
||||
async function post(query, params) {
|
||||
|
|
|
@ -33,6 +33,7 @@ function onBeforeSave(formData, originalData) {
|
|||
<FetchData url="ClaimStates" @on-fetch="setClaimStates" auto-load />
|
||||
<FormModel
|
||||
model="Claim"
|
||||
:go-to="`/claim/${route.params.id}/notes`"
|
||||
:url-update="`Claims/updateClaim/${route.params.id}`"
|
||||
:mapper="onBeforeSave"
|
||||
auto-load
|
||||
|
|
|
@ -78,6 +78,8 @@ const columns = computed(() => [
|
|||
label: t('Quantity'),
|
||||
field: ({ sale }) => sale.quantity,
|
||||
sortable: true,
|
||||
style: 'padding-right: 2%;',
|
||||
headerStyle: 'padding-right: 2%;'
|
||||
},
|
||||
{
|
||||
name: 'claimed',
|
||||
|
@ -110,6 +112,8 @@ const columns = computed(() => [
|
|||
field: ({ sale }) => totalRow(sale),
|
||||
format: (value) => toCurrency(value),
|
||||
sortable: true,
|
||||
style: 'padding-right: 2%;',
|
||||
headerStyle: 'padding-right: 2%;'
|
||||
},
|
||||
]);
|
||||
|
||||
|
@ -152,12 +156,33 @@ function showImportDialog() {
|
|||
.onOk(() => claimLinesForm.value.reload());
|
||||
}
|
||||
|
||||
async function saveWhenHasChanges() {
|
||||
if (claimLinesForm.value.getChanges().updates) {
|
||||
await claimLinesForm.value.onSubmit();
|
||||
onFetch(claimLinesForm.value.formData);
|
||||
function fillClaimedQuantities() {
|
||||
const formData = claimLinesForm.value.formData;
|
||||
let hasChanges = false;
|
||||
|
||||
const selectedRows = formData.filter(row => selected.value.includes(row));
|
||||
|
||||
for (const row of selectedRows) {
|
||||
if (row.quantity === 0 || row.quantity === null) {
|
||||
row.quantity = row.sale.quantity;
|
||||
hasChanges = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasChanges) {
|
||||
quasar.notify({
|
||||
message: t('Quantities filled automatically'),
|
||||
type: 'positive',
|
||||
});
|
||||
} else {
|
||||
quasar.notify({
|
||||
message: t('No quantities to fill'),
|
||||
type: 'info',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<template>
|
||||
<Teleport to="#st-data" v-if="stateStore.isSubToolbarShown()">
|
||||
|
@ -185,15 +210,16 @@ async function saveWhenHasChanges() {
|
|||
auto-load
|
||||
/>
|
||||
<div class="q-pa-md">
|
||||
|
||||
<CrudModel
|
||||
data-key="ClaimLines"
|
||||
data-key="claimLines"
|
||||
ref="claimLinesForm"
|
||||
:go-to="`photos`"
|
||||
:url="`Claims/${route.params.id}/lines`"
|
||||
save-url="ClaimBeginnings/crud"
|
||||
:user-filter="linesFilter"
|
||||
@on-fetch="onFetch"
|
||||
v-model:selected="selected"
|
||||
:default-save="false"
|
||||
:default-reset="false"
|
||||
auto-load
|
||||
:limit="0"
|
||||
|
@ -214,8 +240,7 @@ async function saveWhenHasChanges() {
|
|||
v-model.number="row.quantity"
|
||||
type="number"
|
||||
dense
|
||||
@keyup.enter="saveWhenHasChanges()"
|
||||
@blur="saveWhenHasChanges()"
|
||||
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
|
@ -272,10 +297,7 @@ async function saveWhenHasChanges() {
|
|||
type="number"
|
||||
dense
|
||||
autofocus
|
||||
@keyup.enter="
|
||||
saveWhenHasChanges()
|
||||
"
|
||||
@blur="saveWhenHasChanges()"
|
||||
|
||||
/>
|
||||
</QItemLabel>
|
||||
</template>
|
||||
|
@ -313,6 +335,18 @@ async function saveWhenHasChanges() {
|
|||
</template>
|
||||
</QTable>
|
||||
</template>
|
||||
<template #moreBeforeActions>
|
||||
<QBtn
|
||||
color="primary"
|
||||
text-color="white"
|
||||
:unelevated="true"
|
||||
:label="t('Rellenar cantidades')"
|
||||
:title="t('Rellenar cantidades')"
|
||||
icon="auto_fix_high"
|
||||
:disabled="!selected.length"
|
||||
@click="fillClaimedQuantities"
|
||||
/>
|
||||
</template>
|
||||
</CrudModel>
|
||||
</div>
|
||||
|
||||
|
@ -358,6 +392,8 @@ es:
|
|||
Delete claimed sales: Eliminar ventas reclamadas
|
||||
Discount updated: Descuento actualizado
|
||||
Claimed quantity: Cantidad reclamada
|
||||
Quantities filled automatically: Cantidades rellenadas automáticamente
|
||||
No quantities to fill: No hay cantidades para rellenar
|
||||
You are about to remove {count} rows: '
|
||||
Vas a eliminar <strong>{count}</strong> línea |
|
||||
Vas a eliminar <strong>{count}</strong> líneas'
|
||||
|
|
|
@ -21,9 +21,11 @@ const claimFilter = {
|
|||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnNotes
|
||||
url="claimObservations"
|
||||
:go-to="`/claim/${route.params.id}/lines`"
|
||||
:add-note="$props.addNote"
|
||||
:user-filter="claimFilter"
|
||||
:filter="{ where: { claimFk: claimId } }"
|
||||
|
|
|
@ -54,7 +54,7 @@ const detailsColumns = ref([
|
|||
{
|
||||
name: 'item',
|
||||
label: 'claim.item',
|
||||
field: (row) => row.sale.itemFk,
|
||||
field: (row) => dashIfEmpty(row.sale.itemFk),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
|
@ -67,13 +67,13 @@ const detailsColumns = ref([
|
|||
{
|
||||
name: 'quantity',
|
||||
label: 'claim.quantity',
|
||||
field: (row) => row.sale.quantity,
|
||||
field: (row) => dashIfEmpty(row.sale.quantity),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'claimed',
|
||||
label: 'claim.claimed',
|
||||
field: (row) => row.quantity,
|
||||
field: (row) => dashIfEmpty(row.quantity),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
|
@ -84,7 +84,7 @@ const detailsColumns = ref([
|
|||
{
|
||||
name: 'price',
|
||||
label: 'claim.price',
|
||||
field: (row) => row.sale.price,
|
||||
field: (row) => dashIfEmpty(row.sale.price),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
|
@ -337,23 +337,16 @@ function claimUrl(section) {
|
|||
</QTh>
|
||||
</QTr>
|
||||
</template>
|
||||
<template #body="props">
|
||||
<QTr :props="props">
|
||||
<QTd v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<template v-if="col.name === 'description'">
|
||||
<span class="link">{{
|
||||
dashIfEmpty(col.field(props.row))
|
||||
}}</span>
|
||||
<ItemDescriptorProxy
|
||||
:id="props.row.sale.itemFk"
|
||||
:sale-fk="props.row.saleFk"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ dashIfEmpty(col.field(props.row)) }}
|
||||
</template>
|
||||
</QTd>
|
||||
</QTr>
|
||||
<template #body-cell-description="props">
|
||||
<QTd :props="props">
|
||||
<span class="link">
|
||||
{{ props.value }}
|
||||
</span>
|
||||
<ItemDescriptorProxy
|
||||
:id="props.row.sale.itemFk"
|
||||
:sale-fk="props.row.saleFk"
|
||||
/>
|
||||
</QTd>
|
||||
</template>
|
||||
</QTable>
|
||||
</QCard>
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||
import ModalCloseContract from 'src/pages/Customer/components/ModalCloseContract.vue';
|
||||
import { toDate } from 'src/filters';
|
||||
import CustomerCreditContractsCreate from '../components/CustomerCreditContractsCreate.vue';
|
||||
import VnLv from 'src/components/ui/VnLv.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
@ -16,6 +17,7 @@ const quasar = useQuasar();
|
|||
|
||||
const vnPaginateRef = ref(null);
|
||||
const showQPageSticky = ref(true);
|
||||
const showForm = ref();
|
||||
|
||||
const filter = {
|
||||
order: 'finished ASC, started DESC',
|
||||
|
@ -36,25 +38,21 @@ const fetch = (data) => {
|
|||
data.forEach((element) => {
|
||||
if (!element.finished) {
|
||||
showQPageSticky.value = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const toCustomerCreditContractsCreate = () => {
|
||||
router.push({ name: 'CustomerCreditContractsCreate' });
|
||||
};
|
||||
|
||||
const openDialog = (item) => {
|
||||
quasar.dialog({
|
||||
component: ModalCloseContract,
|
||||
componentProps: {
|
||||
id: item.id,
|
||||
promise: updateData,
|
||||
promise: async () => {
|
||||
await updateData();
|
||||
showQPageSticky.value = true;
|
||||
},
|
||||
},
|
||||
});
|
||||
updateData();
|
||||
showQPageSticky.value = true;
|
||||
};
|
||||
|
||||
const openViewCredit = (credit) => {
|
||||
|
@ -66,14 +64,14 @@ const openViewCredit = (credit) => {
|
|||
});
|
||||
};
|
||||
|
||||
const updateData = () => {
|
||||
vnPaginateRef.value?.fetch();
|
||||
const updateData = async () => {
|
||||
await vnPaginateRef.value?.fetch();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="full-width flex justify-center">
|
||||
<QCard class="card-width q-pa-lg">
|
||||
<section class="row justify-center">
|
||||
<QCard class="q-pa-lg" style="width: 70%">
|
||||
<VnPaginate
|
||||
:user-filter="filter"
|
||||
@on-fetch="fetch"
|
||||
|
@ -84,100 +82,84 @@ const updateData = () => {
|
|||
url="CreditClassifications"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<div v-if="rows.length">
|
||||
<div v-if="rows.length" class="q-gutter-y-md">
|
||||
<QCard
|
||||
v-for="(item, index) in rows"
|
||||
:key="index"
|
||||
:class="{
|
||||
'customer-card': true,
|
||||
'q-mb-md': index < rows.length - 1,
|
||||
'is-active': !item.finished,
|
||||
}"
|
||||
:class="{ disabled: item.finished }"
|
||||
>
|
||||
<QCardSection
|
||||
class="full-width flex justify-between q-py-none"
|
||||
class="full-width"
|
||||
:class="{ 'row justify-between': $q.screen.gt.md }"
|
||||
>
|
||||
<div class="width-state flex">
|
||||
<div
|
||||
class="flex items-center cursor-pointer q-mr-md"
|
||||
v-if="!item.finished"
|
||||
<div class="width-state row no-wrap">
|
||||
<QIcon
|
||||
:style="{
|
||||
visibility: item.finished
|
||||
? 'hidden'
|
||||
: 'visible',
|
||||
}"
|
||||
@click.stop="openDialog(item)"
|
||||
color="primary"
|
||||
name="lock"
|
||||
data-cy="closeBtn"
|
||||
size="md"
|
||||
class="fill-icon q-px-md"
|
||||
>
|
||||
<QIcon
|
||||
@click.stop="openDialog(item)"
|
||||
color="primary"
|
||||
name="lock"
|
||||
size="md"
|
||||
class="fill-icon"
|
||||
>
|
||||
<QTooltip>{{ t('Close contract') }}</QTooltip>
|
||||
</QIcon>
|
||||
</div>
|
||||
<QTooltip>{{ t('Close contract') }}</QTooltip>
|
||||
</QIcon>
|
||||
|
||||
<div>
|
||||
<div class="flex q-mb-xs">
|
||||
<div class="q-mr-sm color-vn-label">
|
||||
{{ t('Since') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ toDate(item.started) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="q-mr-sm color-vn-label">
|
||||
{{ t('To') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ toDate(item.finished) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<VnLv
|
||||
:label="t('Since')"
|
||||
:value="toDate(item.started)"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('To')"
|
||||
:value="toDate(item.finished)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<QSeparator vertical />
|
||||
|
||||
<div class="width-data flex">
|
||||
<div class="column width-data">
|
||||
<div
|
||||
class="full-width flex justify-between items-center"
|
||||
class="column"
|
||||
v-if="item?.insurances.length"
|
||||
v-for="insurance in item.insurances"
|
||||
:key="insurance.id"
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="color-vn-label q-mr-xs">
|
||||
{{ t('Credit') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ item.insurances[0].credit }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="color-vn-label q-mr-xs">
|
||||
{{ t('Grade') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ item.insurances[0].grade || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<div class="color-vn-label q-mr-xs">
|
||||
{{ t('Date') }}:
|
||||
</div>
|
||||
<div class="text-weight-bold">
|
||||
{{ toDate(item.insurances[0].created) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center cursor-pointer">
|
||||
<QIcon
|
||||
@click.stop="openViewCredit(item)"
|
||||
color="primary"
|
||||
name="preview"
|
||||
size="md"
|
||||
>
|
||||
<QTooltip>{{
|
||||
t('View credits')
|
||||
}}</QTooltip>
|
||||
</QIcon>
|
||||
<div
|
||||
:class="{
|
||||
'row q-gutter-x-md': $q.screen.gt.sm,
|
||||
}"
|
||||
class="q-mb-sm"
|
||||
>
|
||||
<VnLv
|
||||
:label="t('Credit')"
|
||||
:value="toCurrency(insurance.credit)"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('Grade')"
|
||||
:value="dashIfEmpty(insurance.grade)"
|
||||
/>
|
||||
<VnLv
|
||||
:label="t('Date')"
|
||||
:value="toDate(insurance.created)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<QBtn
|
||||
@click.stop="openViewCredit(item)"
|
||||
icon="preview"
|
||||
size="md"
|
||||
:title="t('View credits')"
|
||||
data-cy="viewBtn"
|
||||
color="primary"
|
||||
flat
|
||||
/>
|
||||
</QCardSection>
|
||||
</QCard>
|
||||
</div>
|
||||
|
@ -187,11 +169,12 @@ const updateData = () => {
|
|||
</template>
|
||||
</VnPaginate>
|
||||
</QCard>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<QPageSticky :offset="[18, 18]" v-if="showQPageSticky">
|
||||
<QBtn
|
||||
@click.stop="toCustomerCreditContractsCreate()"
|
||||
data-cy="createBtn"
|
||||
@click.stop="showForm = !showForm"
|
||||
color="primary"
|
||||
fab
|
||||
icon="add"
|
||||
|
@ -201,24 +184,25 @@ const updateData = () => {
|
|||
{{ t('New contract') }}
|
||||
</QTooltip>
|
||||
</QPageSticky>
|
||||
|
||||
<QDialog v-model="showForm">
|
||||
<CustomerCreditContractsCreate @on-data-saved="updateData()" />
|
||||
</QDialog>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.customer-card {
|
||||
border: 2px solid var(--vn-light-gray);
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.is-active {
|
||||
background-color: var(--vn-light-gray);
|
||||
}
|
||||
.width-state {
|
||||
width: 30%;
|
||||
}
|
||||
.width-data {
|
||||
width: 65%;
|
||||
width: 50%;
|
||||
}
|
||||
::v-deep(.label) {
|
||||
margin-right: 5px;
|
||||
}
|
||||
::v-deep(.label)::after {
|
||||
content: ':';
|
||||
color: var(--vn-label-color);
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<script setup>
|
||||
import { computed, onBeforeMount, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { toCurrency, toDate } from 'src/filters';
|
||||
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const create = ref(null);
|
||||
const tableRef = ref();
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'created',
|
||||
format: ({ created }) => toDate(created),
|
||||
label: t('Created'),
|
||||
name: 'created',
|
||||
create: true,
|
||||
columnCreate: {
|
||||
component: 'date',
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'grade',
|
||||
label: t('Grade'),
|
||||
name: 'grade',
|
||||
create: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
format: ({ credit }) => toCurrency(credit),
|
||||
label: t('Credit'),
|
||||
name: 'credit',
|
||||
create: true,
|
||||
},
|
||||
]);
|
||||
|
||||
onBeforeMount(async () => {
|
||||
const query = `CreditClassifications/findOne?filter=${encodeURIComponent(
|
||||
JSON.stringify({
|
||||
fields: ['finished'],
|
||||
where: { id: route.params.creditId },
|
||||
}),
|
||||
)}`;
|
||||
const { data } = await axios(query);
|
||||
create.value = data.finished
|
||||
? false
|
||||
: {
|
||||
urlCreate: 'CreditInsurances',
|
||||
title: t('Create Insurance'),
|
||||
onDataSaved: () => tableRef.value.reload(),
|
||||
formInitialData: {
|
||||
created: Date.vnNew(),
|
||||
creditClassificationFk: route.params.creditId,
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnTable
|
||||
v-if="create != null"
|
||||
url="CreditInsurances"
|
||||
ref="tableRef"
|
||||
data-key="creditInsurances"
|
||||
:filter="{
|
||||
where: {
|
||||
creditClassificationFk: `${route.params.creditId}`,
|
||||
},
|
||||
order: 'created DESC',
|
||||
}"
|
||||
:columns="columns"
|
||||
:right-search="false"
|
||||
:is-editable="false"
|
||||
:use-model="true"
|
||||
:column-search="false"
|
||||
:disable-option="{ card: true }"
|
||||
:create
|
||||
auto-load
|
||||
/>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Created: Fecha creación
|
||||
Grade: Grade
|
||||
Credit: Crédito
|
||||
</i18n>
|
|
@ -99,7 +99,13 @@ async function acceptPropagate({ isEqualizated }) {
|
|||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
<VnInput :label="t('Street')" clearable v-model="data.street" required />
|
||||
<VnInput
|
||||
:label="t('Street')"
|
||||
clearable
|
||||
v-model="data.street"
|
||||
:uppercase="true"
|
||||
required
|
||||
/>
|
||||
</VnRow>
|
||||
|
||||
<VnRow>
|
||||
|
|
|
@ -26,6 +26,7 @@ const columns = computed(() => [
|
|||
url: 'Clients',
|
||||
fields: ['id', 'socialName'],
|
||||
optionLabel: 'socialName',
|
||||
optionValue: 'socialName',
|
||||
},
|
||||
},
|
||||
columnClass: 'expand',
|
||||
|
@ -37,8 +38,11 @@ const columns = computed(() => [
|
|||
name: 'city',
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
inWhere: true,
|
||||
attrs: {
|
||||
url: 'Towns',
|
||||
optionValue: 'name',
|
||||
optionLabel: 'name',
|
||||
},
|
||||
},
|
||||
cardVisible: true,
|
||||
|
@ -94,7 +98,7 @@ const columns = computed(() => [
|
|||
</VnSubToolbar>
|
||||
<VnTable
|
||||
:data-key="dataKey"
|
||||
url="Clients/filter"
|
||||
url="Clients/extendedListFilter"
|
||||
:table="{
|
||||
'row-key': 'id',
|
||||
selection: 'multiple',
|
||||
|
|
|
@ -3,44 +3,29 @@ import { reactive, computed } from 'vue';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
import FormModel from 'components/FormModel.vue';
|
||||
import VnRow from 'components/ui/VnRow.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import FormModelPopup from 'src/components/FormModelPopup.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const routeId = computed(() => route.params.id);
|
||||
const router = useRouter();
|
||||
|
||||
const initialData = reactive({
|
||||
started: Date.vnNew(),
|
||||
clientFk: routeId.value,
|
||||
});
|
||||
|
||||
const toCustomerCreditContracts = () => {
|
||||
router.push({ name: 'CustomerCreditContracts' });
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FormModel
|
||||
<FormModelPopup
|
||||
v-on="$attrs"
|
||||
:form-initial-data="initialData"
|
||||
:observe-form-changes="false"
|
||||
url-create="creditClassifications/createWithInsurance"
|
||||
@on-data-saved="toCustomerCreditContracts()"
|
||||
>
|
||||
<template #moreActions>
|
||||
<QBtn
|
||||
:label="t('globals.cancel')"
|
||||
@click="toCustomerCreditContracts"
|
||||
color="primary"
|
||||
flat
|
||||
icon="close"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template #form="{ data }">
|
||||
<template #form-inputs="{ data }">
|
||||
<VnRow>
|
||||
<div class="col">
|
||||
<VnInput
|
||||
|
@ -63,7 +48,7 @@ const toCustomerCreditContracts = () => {
|
|||
</div>
|
||||
</VnRow>
|
||||
</template>
|
||||
</FormModel>
|
||||
</FormModelPopup>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { toCurrency, toDate } from 'src/filters';
|
||||
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const filter = {
|
||||
where: {
|
||||
creditClassificationFk: `${route.params.creditId}`,
|
||||
},
|
||||
limit: 20,
|
||||
};
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
field: 'created',
|
||||
format: ({ created }) => toDate(created),
|
||||
label: t('Created'),
|
||||
name: 'created',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'grade',
|
||||
label: t('Grade'),
|
||||
name: 'grade',
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
format: ({ credit }) => toCurrency(credit),
|
||||
label: t('Credit'),
|
||||
name: 'credit',
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<VnTable
|
||||
url="CreditInsurances"
|
||||
ref="tableRef"
|
||||
data-key="creditInsurances"
|
||||
:filter="filter"
|
||||
:columns="columns"
|
||||
:right-search="false"
|
||||
:is-editable="false"
|
||||
:use-model="true"
|
||||
:column-search="false"
|
||||
:disable-option="{ card: true }"
|
||||
auto-load
|
||||
></VnTable>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Created: Fecha creación
|
||||
Grade: Grade
|
||||
Credit: Crédito
|
||||
</i18n>
|
|
@ -15,7 +15,7 @@ import InvoiceOutDescriptorProxy from 'pages/InvoiceOut/Card/InvoiceOutDescripto
|
|||
import RouteDescriptorProxy from 'src/pages/Route/Card/RouteDescriptorProxy.vue';
|
||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||
import CustomerDescriptorProxy from '../Card/CustomerDescriptorProxy.vue';
|
||||
|
||||
import { getItemPackagingType } from '../composables/getItemPackagingType.js';
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
@ -161,23 +161,6 @@ const setShippedColor = (date) => {
|
|||
};
|
||||
const rowClick = ({ id }) =>
|
||||
window.open(router.resolve({ params: { id }, name: 'TicketSummary' }).href, '_blank');
|
||||
|
||||
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>
|
||||
|
||||
<template>
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
import { describe, it, expect } from 'vitest';
|
||||
import { getItemPackagingType } from '../getItemPackagingType';
|
||||
|
||||
describe('getItemPackagingType', () => {
|
||||
it('should return "-" if ticketSales is null or undefined', () => {
|
||||
expect(getItemPackagingType(null)).toBe('-');
|
||||
expect(getItemPackagingType(undefined)).toBe('-');
|
||||
});
|
||||
|
||||
it('should return "-" if ticketSales does not have a length property', () => {
|
||||
const ticketSales = { someKey: 'someValue' }; // No tiene propiedad length
|
||||
expect(getItemPackagingType(ticketSales)).toBe('-');
|
||||
});
|
||||
|
||||
it('should return unique packaging types as a comma-separated string', () => {
|
||||
const ticketSales = [
|
||||
{ item: { itemPackingTypeFk: 'H' } },
|
||||
{ item: { itemPackingTypeFk: 'V' } },
|
||||
{ item: { itemPackingTypeFk: 'H' } },
|
||||
];
|
||||
expect(getItemPackagingType(ticketSales)).toBe('H, V');
|
||||
});
|
||||
it('should return unique packaging types as a comma-separated string', () => {
|
||||
const ticketSales = [
|
||||
{ item: { itemPackingTypeFk: 'H' } },
|
||||
{ item: { itemPackingTypeFk: 'V' } },
|
||||
{ item: { itemPackingTypeFk: 'H' } },
|
||||
{ item: { itemPackingTypeFk: 'A' } },
|
||||
];
|
||||
expect(getItemPackagingType(ticketSales)).toBe('H, V, A');
|
||||
});
|
||||
|
||||
it('should return "-" if ticketSales is an empty array', () => {
|
||||
expect(getItemPackagingType([])).toBe('-');
|
||||
});
|
||||
});
|
|
@ -0,0 +1,11 @@
|
|||
import { dashIfEmpty } from 'src/filters';
|
||||
|
||||
export function getItemPackagingType(ticketSales) {
|
||||
if (!ticketSales?.length) return '-';
|
||||
|
||||
const packagingTypes = Array.from(
|
||||
new Set(ticketSales.map(({ item: { itemPackingTypeFk } }) => itemPackingTypeFk)),
|
||||
);
|
||||
|
||||
return dashIfEmpty(packagingTypes.join(', '));
|
||||
}
|
|
@ -1,22 +1,20 @@
|
|||
<script setup>
|
||||
import { useRoute } from 'vue-router';
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useQuasar } from 'quasar';
|
||||
import FetchedTags from 'components/ui/FetchedTags.vue';
|
||||
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
||||
import SupplierConsumptionFilter from './SupplierConsumptionFilter.vue';
|
||||
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
||||
|
||||
import { dateRange, toDate } from 'src/filters';
|
||||
import { dashIfEmpty } from 'src/filters';
|
||||
import { usePrintService } from 'composables/usePrintService';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
import axios from 'axios';
|
||||
import { dateRange, toCurrency, toNumber, toDateHourMin } from 'src/filters';
|
||||
import { usePrintService } from 'composables/usePrintService';
|
||||
import useNotify from 'src/composables/useNotify';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import SendEmailDialog from 'components/common/SendEmailDialog.vue';
|
||||
import SupplierConsumptionFilter from './SupplierConsumptionFilter.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import EntryDescriptorProxy from 'src/pages/Entry/Card/EntryDescriptorProxy.vue';
|
||||
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
||||
|
||||
const state = useState();
|
||||
const stateStore = useStateStore();
|
||||
|
@ -31,7 +29,86 @@ const arrayData = useArrayData('SupplierConsumption', {
|
|||
order: ['itemTypeFk', 'itemName', 'itemSize'],
|
||||
userFilter: { where: { supplierFk: route.params.id } },
|
||||
});
|
||||
const headerColumns = computed(() => [
|
||||
{
|
||||
name: 'id',
|
||||
label: t('globals.entry'),
|
||||
align: 'left',
|
||||
field: 'id',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'invoiceNumber',
|
||||
label: t('globals.params.supplierRef'),
|
||||
align: 'left',
|
||||
field: 'invoiceNumber',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'shipped',
|
||||
label: t('globals.shipped'),
|
||||
align: 'center',
|
||||
field: 'shipped',
|
||||
format: toDateHourMin,
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'quantity',
|
||||
label: t('item.list.stems'),
|
||||
align: 'center',
|
||||
field: 'quantity',
|
||||
format: (value) => toNumber(value),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'total',
|
||||
label: t('globals.total'),
|
||||
align: 'center',
|
||||
field: 'total',
|
||||
format: (value) => toCurrency(value),
|
||||
sortable: true,
|
||||
},
|
||||
]);
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
name: 'itemName',
|
||||
label: t('globals.item'),
|
||||
align: 'left',
|
||||
field: 'itemName',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'subName',
|
||||
align: 'left',
|
||||
field: 'subName',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'quantity',
|
||||
label: t('globals.quantity'),
|
||||
align: 'right',
|
||||
field: 'quantity',
|
||||
format: (value) => toNumber(value),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'price',
|
||||
label: t('globals.price'),
|
||||
align: 'right',
|
||||
field: 'price',
|
||||
format: (value) => toCurrency(value),
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
name: 'total',
|
||||
label: t('globals.total'),
|
||||
align: 'right',
|
||||
field: 'total',
|
||||
format: (value) => toCurrency(value),
|
||||
sortable: true,
|
||||
},
|
||||
]);
|
||||
const store = arrayData.store;
|
||||
|
||||
onUnmounted(() => state.unset('SupplierConsumption'));
|
||||
|
@ -100,33 +177,34 @@ const sendCampaignMetricsEmail = ({ address }) => {
|
|||
};
|
||||
|
||||
const totalEntryPrice = (rows) => {
|
||||
let totalPrice = 0;
|
||||
let totalQuantity = 0;
|
||||
if (!rows) return totalPrice;
|
||||
for (const row of rows) {
|
||||
let total = 0;
|
||||
let quantity = 0;
|
||||
|
||||
if (row.buys) {
|
||||
for (const buy of row.buys) {
|
||||
total = total + buy.total;
|
||||
quantity = quantity + buy.quantity;
|
||||
if (!rows) return [];
|
||||
totalRows.value = rows.reduce(
|
||||
(acc, row) => {
|
||||
if (Array.isArray(row.buys)) {
|
||||
const { total, quantity } = row.buys.reduce(
|
||||
(buyAcc, buy) => {
|
||||
buyAcc.total += buy.total || 0;
|
||||
buyAcc.quantity += buy.quantity || 0;
|
||||
return buyAcc;
|
||||
},
|
||||
{ total: 0, quantity: 0 },
|
||||
);
|
||||
row.total = total;
|
||||
row.quantity = quantity;
|
||||
acc.totalPrice += total;
|
||||
acc.totalQuantity += quantity;
|
||||
}
|
||||
}
|
||||
|
||||
row.total = total;
|
||||
row.quantity = quantity;
|
||||
totalPrice = totalPrice + total;
|
||||
totalQuantity = totalQuantity + quantity;
|
||||
}
|
||||
totalRows.value = { totalPrice, totalQuantity };
|
||||
return acc;
|
||||
},
|
||||
{ totalPrice: 0, totalQuantity: 0 },
|
||||
);
|
||||
return rows;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
stateStore.rightDrawer = true;
|
||||
await getSupplierConsumptionData();
|
||||
});
|
||||
const expanded = ref([]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -160,14 +238,14 @@ onMounted(async () => {
|
|||
<div>
|
||||
{{ t('Total entries') }}:
|
||||
<QChip :dense="$q.screen.lt.sm" text-color="white">
|
||||
{{ totalRows.totalPrice }} €
|
||||
{{ toCurrency(totalRows.totalPrice) }}
|
||||
</QChip>
|
||||
</div>
|
||||
<QSeparator dark vertical />
|
||||
<div>
|
||||
{{ t('Total stems entries') }}:
|
||||
<QChip :dense="$q.screen.lt.sm" text-color="white">
|
||||
{{ totalRows.totalQuantity }}
|
||||
{{ toNumber(totalRows.totalQuantity) }}
|
||||
</QChip>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -177,59 +255,111 @@ onMounted(async () => {
|
|||
<SupplierConsumptionFilter data-key="SupplierConsumption" />
|
||||
</template>
|
||||
</RightMenu>
|
||||
<QTable
|
||||
:rows="rows"
|
||||
row-key="id"
|
||||
hide-header
|
||||
class="full-width q-mt-md"
|
||||
:no-data-label="t('No results')"
|
||||
>
|
||||
<template #body="{ row }">
|
||||
<QTr>
|
||||
<QTd no-hover>
|
||||
<span class="label">{{ t('supplier.consumption.entry') }}: </span>
|
||||
<span>{{ row.id }}</span>
|
||||
</QTd>
|
||||
<QTd no-hover>
|
||||
<span class="label">{{ t('globals.date') }}: </span>
|
||||
<span>{{ toDate(row.shipped) }}</span></QTd
|
||||
<QCard class="full-width q-pa-md">
|
||||
<QTable
|
||||
flat
|
||||
bordered
|
||||
:rows="rows"
|
||||
:columns="headerColumns"
|
||||
row-key="id"
|
||||
v-model:expanded="expanded"
|
||||
:grid="$q.screen.lt.md"
|
||||
>
|
||||
<template #header="props">
|
||||
<QTr :props="props">
|
||||
<QTh auto-width />
|
||||
|
||||
<QTh v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<span v-text="col.label" class="tr-header" />
|
||||
</QTh>
|
||||
</QTr>
|
||||
</template>
|
||||
|
||||
<template #body="props">
|
||||
<QTr
|
||||
:props="props"
|
||||
:key="`movement_${props.row.id}`"
|
||||
class="bg-vn-page cursor-pointer"
|
||||
@click="props.expand = !props.expand"
|
||||
>
|
||||
<QTd colspan="6" no-hover>
|
||||
<span class="label">{{ t('globals.reference') }}: </span>
|
||||
<span>{{ row.invoiceNumber }}</span>
|
||||
</QTd>
|
||||
</QTr>
|
||||
<QTr v-for="(buy, index) in row.buys" :key="index">
|
||||
<QTd no-hover>
|
||||
<QBtn flat class="link" dense no-caps>{{ buy.itemName }}</QBtn>
|
||||
<ItemDescriptorProxy :id="buy.itemFk" />
|
||||
</QTd>
|
||||
<QTd auto-width>
|
||||
<QIcon
|
||||
:class="props.expand ? '' : 'rotate-270'"
|
||||
name="expand_circle_down"
|
||||
size="md"
|
||||
:color="props.expand ? 'primary' : 'white'"
|
||||
/>
|
||||
</QTd>
|
||||
|
||||
<QTd no-hover>
|
||||
<span>{{ buy.subName }}</span>
|
||||
<FetchedTags :item="buy" />
|
||||
</QTd>
|
||||
<QTd no-hover> {{ dashIfEmpty(buy.quantity) }}</QTd>
|
||||
<QTd no-hover> {{ dashIfEmpty(buy.price) }}</QTd>
|
||||
<QTd colspan="2" no-hover> {{ dashIfEmpty(buy.total) }}</QTd>
|
||||
</QTr>
|
||||
<QTr>
|
||||
<QTd colspan="5" no-hover>
|
||||
<span class="label">{{ t('Total entry') }}: </span>
|
||||
<span>{{ row.total }} €</span>
|
||||
</QTd>
|
||||
<QTd no-hover>
|
||||
<span class="label">{{ t('Total stems') }}: </span>
|
||||
<span>{{ row.quantity }}</span>
|
||||
</QTd>
|
||||
</QTr>
|
||||
</template>
|
||||
</QTable>
|
||||
<QTd v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<span @click.stop class="link" v-if="col.name === 'id'">
|
||||
{{ col.value }}
|
||||
<EntryDescriptorProxy :id="col.value" />
|
||||
</span>
|
||||
|
||||
<span v-else v-text="col.value" />
|
||||
</QTd>
|
||||
</QTr>
|
||||
|
||||
<QTr
|
||||
v-show="props.expand"
|
||||
:props="props"
|
||||
:key="`expedition_${props.row.id}`"
|
||||
>
|
||||
<QTd colspan="12" style="padding: 1px 0">
|
||||
<QTable
|
||||
color="secondary"
|
||||
card-class="bg-vn-page text-white "
|
||||
style-class="height: 30px"
|
||||
table-header-class="text-white"
|
||||
:rows="props.row.buys"
|
||||
:columns="columns"
|
||||
row-key="id"
|
||||
virtual-scroll
|
||||
v-model:expanded="expanded"
|
||||
>
|
||||
<template #header="props">
|
||||
<QTr :props="props">
|
||||
<QTh
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
>
|
||||
<span v-text="col.label" class="tr-header" />
|
||||
</QTh>
|
||||
</QTr>
|
||||
</template>
|
||||
<template #body="props">
|
||||
<QTr :props="props" :key="`m_${props.row.id}`">
|
||||
<QTd
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:title="col.label"
|
||||
:props="props"
|
||||
>
|
||||
<span
|
||||
@click.stop
|
||||
class="link"
|
||||
v-if="col.name === 'itemName'"
|
||||
>
|
||||
{{ col.value }}
|
||||
<ItemDescriptorProxy :id="props.row.itemFk" />
|
||||
</span>
|
||||
<span v-else v-text="col.value" />
|
||||
</QTd>
|
||||
</QTr>
|
||||
</template>
|
||||
</QTable>
|
||||
</QTd>
|
||||
</QTr>
|
||||
</template>
|
||||
</QTable>
|
||||
</QCard>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.label {
|
||||
color: var(--vn-label-color);
|
||||
.q-table thead tr,
|
||||
.q-table tbody td {
|
||||
height: 30px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||
|
||||
import axios from 'axios';
|
||||
import useNotify from 'src/composables/useNotify.js';
|
||||
|
@ -59,11 +58,25 @@ const zoneWhere = computed(() => {
|
|||
});
|
||||
|
||||
async function getLanded(params) {
|
||||
getDate(`Agencies/getLanded`, params);
|
||||
const data = await getDate(`Agencies/getLanded`, params);
|
||||
formData.value.landed = data.landed;
|
||||
const shippedDate = new Date(params.shipped);
|
||||
const landedDate = new Date(data.hour);
|
||||
shippedDate.setHours(
|
||||
landedDate.getHours(),
|
||||
landedDate.getMinutes(),
|
||||
landedDate.getSeconds(),
|
||||
);
|
||||
formData.value.shipped = shippedDate.toISOString();
|
||||
}
|
||||
|
||||
async function getShipped(params) {
|
||||
getDate(`Agencies/getShipped`, params);
|
||||
const data = await getDate(`Agencies/getShipped`, params);
|
||||
formData.value.landed = params.landed;
|
||||
const [hours, minutes, seconds] = data.hour.split(':').map(Number);
|
||||
let shippedDate = new Date(data.shipped);
|
||||
shippedDate.setHours(hours, minutes, seconds);
|
||||
formData.value.shipped = shippedDate.toISOString();
|
||||
}
|
||||
|
||||
async function getDate(query, params) {
|
||||
|
@ -75,15 +88,8 @@ async function getDate(query, params) {
|
|||
if (!data) return notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
|
||||
|
||||
formData.value.zoneFk = data.zoneFk;
|
||||
formData.value.landed = data.landed;
|
||||
const shippedDate = new Date(params.shipped);
|
||||
const landedDate = new Date(data.hour);
|
||||
shippedDate.setHours(
|
||||
landedDate.getHours(),
|
||||
landedDate.getMinutes(),
|
||||
landedDate.getSeconds(),
|
||||
);
|
||||
formData.value.shipped = shippedDate.toISOString();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const onChangeZone = async (zoneId) => {
|
||||
|
@ -273,8 +279,6 @@ async function getZone(options) {
|
|||
<VnSelect
|
||||
:label="t('ticketList.client')"
|
||||
v-model="clientId"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
url="Clients"
|
||||
:fields="['id', 'name']"
|
||||
sort-by="id"
|
||||
|
@ -309,16 +313,31 @@ async function getZone(options) {
|
|||
<VnSelect
|
||||
:label="t('basicData.address')"
|
||||
v-model="addressId"
|
||||
option-value="id"
|
||||
option-label="nickname"
|
||||
:options="addresses"
|
||||
hide-selected
|
||||
map-options
|
||||
:required="true"
|
||||
:sort-by="['isActive DESC']"
|
||||
:rules="validate('basicData.address')"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItem
|
||||
v-bind="scope.itemProps"
|
||||
:class="{ disabled: !scope.opt.isActive }"
|
||||
>
|
||||
<QItemSection style="min-width: min-content" avatar>
|
||||
<QIcon
|
||||
v-if="
|
||||
scope.opt.isActive &&
|
||||
formData.client.defaultAddressFk === scope.opt.id
|
||||
"
|
||||
size="sm"
|
||||
color="grey"
|
||||
name="star"
|
||||
class="fill-icon"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection>
|
||||
<QItemLabel
|
||||
:class="{
|
||||
|
@ -344,6 +363,9 @@ async function getZone(options) {
|
|||
{{ scope.opt?.agencyMode?.name }}</span
|
||||
>
|
||||
</QItemLabel>
|
||||
<QItemLabel caption>
|
||||
{{ `#${scope.opt?.id}` }}
|
||||
</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
|
@ -425,14 +447,6 @@ async function getZone(options) {
|
|||
:rules="validate('ticketList.shipped')"
|
||||
@update:model-value="setShipped"
|
||||
/>
|
||||
<VnInputTime
|
||||
:label="t('basicData.shippedHour')"
|
||||
v-model="formData.shipped"
|
||||
:required="true"
|
||||
:rules="validate('basicData.shippedHour')"
|
||||
disabled
|
||||
@update:model-value="setShipped"
|
||||
/>
|
||||
<VnInputDate
|
||||
:label="t('basicData.landed')"
|
||||
v-model="formData.landed"
|
||||
|
|
|
@ -20,6 +20,7 @@ export default {
|
|||
'isFreezed',
|
||||
'isTaxDataChecked',
|
||||
'hasElectronicInvoice',
|
||||
'defaultAddressFk',
|
||||
'credit',
|
||||
],
|
||||
include: [
|
||||
|
|
|
@ -582,7 +582,7 @@ function setReference(data) {
|
|||
hide-selected
|
||||
required
|
||||
@update:model-value="() => onClientSelected(data)"
|
||||
:sort-by="'id ASC'"
|
||||
:sort-by="['id ASC']"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
|
@ -608,7 +608,7 @@ function setReference(data) {
|
|||
map-options
|
||||
required
|
||||
:disable="!data.clientId"
|
||||
:sort-by="'isActive DESC'"
|
||||
:sort-by="['isActive DESC']"
|
||||
@update:model-value="() => fetchAvailableAgencies(data)"
|
||||
>
|
||||
<template #option="scope">
|
||||
|
|
|
@ -13,6 +13,8 @@ export default {
|
|||
'daysInForward',
|
||||
'availabled',
|
||||
'awbFk',
|
||||
'isDelivered',
|
||||
'isReceived',
|
||||
],
|
||||
include: [
|
||||
{
|
||||
|
|
|
@ -182,6 +182,7 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
showValue: false,
|
||||
sortable: true,
|
||||
style: 'max-width: 200px;',
|
||||
},
|
||||
{
|
||||
label: t('globals.packages'),
|
||||
|
@ -206,6 +207,7 @@ const columns = computed(() => [
|
|||
align: 'left',
|
||||
showValue: false,
|
||||
sortable: true,
|
||||
style: 'max-width: 75px;',
|
||||
},
|
||||
{
|
||||
label: t('extraCommunity.physicKg'),
|
||||
|
|
|
@ -408,7 +408,7 @@ const isUnsatisfied = async (reason) => {
|
|||
|
||||
const resendEmail = async () => {
|
||||
const params = {
|
||||
recipient: worker.value[0]?.user?.emailUser?.email,
|
||||
recipient: worker.value?.user?.emailUser?.email,
|
||||
week: selectedWeekNumber.value,
|
||||
year: selectedDateYear.value,
|
||||
workerId: Number(route.params.id),
|
||||
|
|
|
@ -33,14 +33,6 @@ const getLocale = (label) => {
|
|||
</div>
|
||||
</template>
|
||||
<template #body="{ params }">
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput :label="t('FI')" v-model="params.fi" filled
|
||||
><template #prepend>
|
||||
<QIcon name="badge" size="xs"></QIcon> </template
|
||||
></VnInput>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput :label="t('First Name')" v-model="params.firstName" filled />
|
||||
|
@ -112,7 +104,6 @@ es:
|
|||
lastName: Apellidos
|
||||
userName: Usuario
|
||||
extension: Extensión
|
||||
FI: NIF
|
||||
First Name: Nombre
|
||||
Last Name: Apellidos
|
||||
User Name: Usuario
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
<script setup>
|
||||
import { computed, onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||
import { useAcl } from 'src/composables/useAcl';
|
||||
|
||||
import VnTable from 'components/VnTable/VnTable.vue';
|
||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||
import WorkerSummary from './Card/WorkerSummary.vue';
|
||||
import RightMenu from 'src/components/common/RightMenu.vue';
|
||||
import WorkerManagementFilter from './WorkerManagementFilter.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const { viewSummary } = useSummaryDialog();
|
||||
const dataKey = 'ManagementList';
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
align: 'left',
|
||||
label: t('tableColumns.firstName'),
|
||||
name: 'firstName',
|
||||
isTitle: true,
|
||||
columnFilter: {
|
||||
name: 'firstName',
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('tableColumns.lastName'),
|
||||
name: 'lastName',
|
||||
columnFilter: {
|
||||
name: 'lastName',
|
||||
},
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('management.NIF'),
|
||||
name: 'fi',
|
||||
columnFilter: {
|
||||
name: 'fi',
|
||||
},
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('tableColumns.email'),
|
||||
name: 'email',
|
||||
columnFilter: {
|
||||
name: 'email',
|
||||
},
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
label: t('management.ssn'),
|
||||
labelAbbreviation: t('management.ssn'),
|
||||
toolTip: t('management.completeSsn'),
|
||||
name: 'SSN',
|
||||
columnFilter: {
|
||||
name: 'SSN',
|
||||
},
|
||||
cardVisible: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
name: 'departmentFk',
|
||||
label: t('tableColumns.department'),
|
||||
columnFilter: {
|
||||
component: 'select',
|
||||
name: 'departmentFk',
|
||||
attrs: {
|
||||
url: 'Departments',
|
||||
},
|
||||
},
|
||||
cardVisible: true,
|
||||
format: (row, dashIfEmpty) => dashIfEmpty(row.department),
|
||||
},
|
||||
{
|
||||
align: 'right',
|
||||
label: '',
|
||||
name: 'tableActions',
|
||||
actions: [
|
||||
{
|
||||
title: t('globals.pageTitles.summary'),
|
||||
icon: 'preview',
|
||||
action: (row) => viewSummary(row?.id, WorkerSummary),
|
||||
isPrimary: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
onMounted(() => {
|
||||
const canAccess = useAcl().hasAcl('Worker', 'management', 'WRITE');
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<VnSearchbar
|
||||
:data-key
|
||||
url="Workers/filter"
|
||||
:label="t('management.search')"
|
||||
:info="t('management.searchInfo')"
|
||||
/>
|
||||
<RightMenu>
|
||||
<template #right-panel>
|
||||
<WorkerManagementFilter :data-key />
|
||||
</template>
|
||||
</RightMenu>
|
||||
<VnTable
|
||||
ref="tableRef"
|
||||
url="Workers/filter"
|
||||
:columns="columns"
|
||||
:data-key
|
||||
:right-search="false"
|
||||
order="id DESC"
|
||||
/>
|
||||
</template>
|
|
@ -0,0 +1,99 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const departments = ref();
|
||||
|
||||
const getLocale = (label) => {
|
||||
const globalLocale = `globals.params.${label}`;
|
||||
return te(globalLocale) ? t(globalLocale) : t(`management.${label}`);
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData url="Departments" @on-fetch="(data) => (departments = data)" auto-load />
|
||||
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
|
||||
<template #tags="{ tag, formatFn }">
|
||||
<div class="q-gutter-x-xs">
|
||||
<strong>{{ getLocale(tag.label) }}: </strong>
|
||||
<span>{{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #body="{ params }">
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput
|
||||
:label="t('tableColumns.firstName')"
|
||||
v-model="params.firstName"
|
||||
filled
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput
|
||||
:label="t('tableColumns.lastName')"
|
||||
v-model="params.lastName"
|
||||
filled
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput
|
||||
:label="t('management.NIF')"
|
||||
v-model="params.fi"
|
||||
filled
|
||||
data-cy="worker-filter-fi"
|
||||
>
|
||||
<template #prepend>
|
||||
<QIcon name="badge" size="xs" />
|
||||
</template>
|
||||
</VnInput>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput
|
||||
:label="t('tableColumns.email')"
|
||||
v-model="params.email"
|
||||
filled
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput :label="t('management.ssn')" v-model="params.SSN" filled />
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('tableColumns.department')"
|
||||
v-model="params.departmentFk"
|
||||
:options="departments"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
emit-value
|
||||
map-options
|
||||
dense
|
||||
filled
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
|
@ -13,3 +13,11 @@ tableColumns:
|
|||
SSN: SSN
|
||||
extension: Extension
|
||||
queue: Queue
|
||||
management:
|
||||
search: Search worker
|
||||
searchInfo: You can search by NIF, NSS or worker name
|
||||
NIF: NIF
|
||||
ssn: SSN
|
||||
completeSsn: National Insurance Number
|
||||
firstName: First Name
|
||||
lastName: Last Name
|
||||
|
|
|
@ -16,3 +16,11 @@ tableColumns:
|
|||
SSN: NSS
|
||||
extension: Extensión
|
||||
queue: Cola
|
||||
management:
|
||||
search: Buscar trabajador
|
||||
searchInfo: Puedes buscar por NIF, NSS o nombre del trabajador
|
||||
NIF: NIF
|
||||
ssn: Núm. SS
|
||||
completeSsn: Número de Seguridad Social
|
||||
firstName: Nombre
|
||||
lastName: Apellidos
|
||||
|
|
|
@ -89,7 +89,7 @@ watch(
|
|||
v-model="formData.geoFk"
|
||||
url="Postcodes/location"
|
||||
:fields="['geoFk', 'code', 'townFk', 'countryFk']"
|
||||
:sort-by="'code ASC'"
|
||||
:sort-by="['code ASC']"
|
||||
option-value="geoFk"
|
||||
option-label="code"
|
||||
:filter-options="['code']"
|
||||
|
|
|
@ -8,9 +8,9 @@ const claimCard = {
|
|||
meta: {
|
||||
menu: [
|
||||
'ClaimBasicData',
|
||||
'ClaimNotes',
|
||||
'ClaimLines',
|
||||
'ClaimPhotos',
|
||||
'ClaimNotes',
|
||||
'ClaimDevelopment',
|
||||
'ClaimAction',
|
||||
'ClaimLog',
|
||||
|
@ -36,6 +36,15 @@ const claimCard = {
|
|||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimBasicData.vue'),
|
||||
},
|
||||
{
|
||||
path: 'notes',
|
||||
name: 'ClaimNotes',
|
||||
meta: {
|
||||
title: 'notes',
|
||||
icon: 'draft',
|
||||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimNotes.vue'),
|
||||
},
|
||||
{
|
||||
path: 'lines',
|
||||
name: 'ClaimLines',
|
||||
|
@ -54,15 +63,6 @@ const claimCard = {
|
|||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimPhoto.vue'),
|
||||
},
|
||||
{
|
||||
path: 'notes',
|
||||
name: 'ClaimNotes',
|
||||
meta: {
|
||||
title: 'notes',
|
||||
icon: 'draft',
|
||||
},
|
||||
component: () => import('src/pages/Claim/Card/ClaimNotes.vue'),
|
||||
},
|
||||
{
|
||||
path: 'development',
|
||||
name: 'ClaimDevelopment',
|
||||
|
|
|
@ -225,7 +225,7 @@ const customerCard = {
|
|||
name: 'CustomerCreditContractsInsurance',
|
||||
component: () =>
|
||||
import(
|
||||
'src/pages/Customer/components/CustomerCreditContractsInsurance.vue'
|
||||
'src/pages/Customer/Card/CustomerCreditContractsInsurance.vue'
|
||||
),
|
||||
},
|
||||
],
|
||||
|
|
|
@ -239,7 +239,7 @@ export default {
|
|||
icon: 'vn:worker',
|
||||
moduleName: 'Worker',
|
||||
keyBinding: 'w',
|
||||
menu: ['WorkerList', 'WorkerDepartment'],
|
||||
menu: ['WorkerList', 'WorkerDepartment', 'WorkerManagement'],
|
||||
},
|
||||
component: RouterView,
|
||||
redirect: { name: 'WorkerMain' },
|
||||
|
@ -283,6 +283,22 @@ export default {
|
|||
departmentCard,
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'management',
|
||||
name: 'WorkerManagement',
|
||||
meta: {
|
||||
title: 'management',
|
||||
icon: 'view_list',
|
||||
acls: [
|
||||
{
|
||||
model: 'Worker',
|
||||
props: 'isRoleAdvanced',
|
||||
accessType: 'READ',
|
||||
},
|
||||
],
|
||||
},
|
||||
component: () => import('src/pages/Worker/WorkerManagement.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('ClaimLines', () => {
|
||||
const claimId = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
cy.viewport(1920, 1080);
|
||||
cy.login('developer');
|
||||
cy.visit(`/#/claim/${claimId}/lines`);
|
||||
});
|
||||
|
||||
it('should add new line', () => {
|
||||
cy.get('.q-page-sticky > div > .q-btn').click();
|
||||
cy.get('.q-card > .q-table__container > .q-table__middle > .q-table > thead > tr > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg').click();
|
||||
cy.get('.q-card__actions > .q-btn--unelevated').click();
|
||||
cy.get('.q-notification__message').should('have.text', 'Lines added to claim');
|
||||
})
|
||||
|
||||
it('should autofill claimed quantity if 0 or null', () => {
|
||||
cy.get('thead > tr > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg').click();
|
||||
cy.get('.q-btn--unelevated').click();
|
||||
cy.checkNotification('Quantities filled automatically');
|
||||
cy.get('.q-btn--unelevated').click();
|
||||
cy.checkNotification('No quantities to fill');
|
||||
})
|
||||
});
|
|
@ -1,5 +1,4 @@
|
|||
describe('ClaimNotes', () => {
|
||||
const saveBtn = '.q-field__append > .q-btn > .q-btn__content > .q-icon';
|
||||
const firstNote = '.q-infinite-scroll :nth-child(1) > .q-card__section--vert';
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
|
@ -11,9 +10,9 @@ describe('ClaimNotes', () => {
|
|||
cy.get('.q-textarea')
|
||||
.should('be.visible')
|
||||
.should('not.be.disabled')
|
||||
.type(message);
|
||||
.type(message, "{{enter}}");
|
||||
|
||||
cy.get(saveBtn).click();
|
||||
cy.dataCy("saveContinueNoteButton").click();
|
||||
cy.get(firstNote).should('have.text', message);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,7 +7,28 @@ describe('Client credit contracts', () => {
|
|||
timeout: 5000,
|
||||
});
|
||||
});
|
||||
it('Should load layout', () => {
|
||||
cy.get('.q-page').should('be.visible');
|
||||
it('Should add a new contract and an additional credit', () => {
|
||||
cy.dataCy('createBtn').click();
|
||||
cy.dataCy('Credit_input').type(123);
|
||||
cy.dataCy('Grade_input').type(9);
|
||||
cy.dataCy('FormModelPopup_save').click();
|
||||
cy.checkNotification('Data created');
|
||||
cy.dataCy('createBtn').should('not.exist');
|
||||
});
|
||||
|
||||
it('Should add an additional credit', () => {
|
||||
cy.dataCy('viewBtn').eq(0).click();
|
||||
cy.get('.q-page-sticky > div').click();
|
||||
cy.dataCy('Credit_input').type(321);
|
||||
cy.dataCy('Grade_input').type(89);
|
||||
cy.dataCy('FormModelPopup_save').click();
|
||||
cy.checkNotification('Data created');
|
||||
});
|
||||
|
||||
it('Should close a contract', () => {
|
||||
cy.dataCy('closeBtn').eq(0).click();
|
||||
cy.get('.q-btn--unelevated').click();
|
||||
cy.checkNotification('Data saved');
|
||||
cy.dataCy('createBtn').should('exist');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -53,10 +53,10 @@ describe('InvoiceInDescriptor', () => {
|
|||
expect(response.statusCode).to.equal(200);
|
||||
});
|
||||
});
|
||||
// https://redmine.verdnatura.es/issues/8767
|
||||
it.skip('should download the file properly', () => {
|
||||
|
||||
it('should download the file properly', () => {
|
||||
cy.visit('/#/invoice-in/1/summary');
|
||||
cy.validateDownload(() => cy.selectDescriptorOption(5));
|
||||
cy.selectDescriptorOption(5);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -84,7 +84,7 @@ describe('InvoiceInDescriptor', () => {
|
|||
|
||||
beforeEach(() => cy.visit(`/#/invoice-in/${originalId}/summary`));
|
||||
|
||||
it.skip('should create a correcting invoice and redirect to original invoice', () => {
|
||||
it('should create a correcting invoice and redirect to original invoice', () => {
|
||||
createCorrective();
|
||||
redirect(originalId);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/// <reference types="cypress" />
|
||||
describe('OrderCatalog', () => {
|
||||
describe.skip('OrderCatalog', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
describe('TicketList', () => {
|
||||
beforeEach(() => {
|
||||
cy.login('developer');
|
||||
cy.viewport(1920, 1080);
|
||||
cy.visit('/#/ticket/list', false);
|
||||
});
|
||||
|
||||
|
@ -76,7 +77,7 @@ describe('TicketList', () => {
|
|||
});
|
||||
}).as('ticket');
|
||||
|
||||
cy.selectOption('[data-cy="Warehouse_select"]', 'Warehouse Five');
|
||||
cy.selectOption('[data-cy="Warehouse_select"]', 'Warehouse One');
|
||||
cy.searchBtnFilterPanel();
|
||||
cy.wait('@ticket').then((interception) => {
|
||||
const data = interception.response.body[0];
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
describe('WorkerManagement', () => {
|
||||
const nif = '12091201A';
|
||||
const searchButton = '.q-scrollarea__content > .q-btn--standard > .q-btn__content';
|
||||
const url = '/#/worker/management';
|
||||
|
||||
it('should not enter the section', () => {
|
||||
cy.login('salesPerson');
|
||||
cy.visit(url);
|
||||
cy.url().should('include', '/dashboard');
|
||||
});
|
||||
|
||||
it('should enter the section and filter by NIF, then open the worker summary popup', () => {
|
||||
cy.login('hr');
|
||||
cy.visit(url);
|
||||
cy.dataCy('worker-filter-fi').type(nif);
|
||||
cy.get(searchButton).click();
|
||||
cy.dataCy('tableAction-0').click();
|
||||
cy.get('.summaryHeader').should('exist');
|
||||
cy.get('.summaryHeader').should('be.visible');
|
||||
cy.get('.summaryBody').should('exist');
|
||||
cy.get('.summaryBody').should('be.visible');
|
||||
});
|
||||
});
|
|
@ -194,9 +194,7 @@ Cypress.Commands.add('fillInForm', (obj, opts = {}) => {
|
|||
cy.selectOption(el, val);
|
||||
break;
|
||||
case 'date':
|
||||
cy.get(el).type(
|
||||
`{selectall}{backspace}${val}`,
|
||||
).blur();
|
||||
cy.get(el).type(`{selectall}{backspace}${val}`).blur();
|
||||
break;
|
||||
case 'time':
|
||||
cy.get(el).click();
|
||||
|
@ -571,24 +569,6 @@ Cypress.Commands.add('validateCheckbox', (selector, expectedVal = 'true') => {
|
|||
cy.get(selector).should('have.attr', 'aria-checked', expectedVal.toString());
|
||||
});
|
||||
|
||||
Cypress.Commands.add('validateDownload', (trigger, opts = {}) => {
|
||||
const {
|
||||
url = /api\/dms\/\d+\/downloadFile\?access_token=.+/,
|
||||
types = ['text/plain', 'image/jpeg'],
|
||||
alias = 'download',
|
||||
} = opts;
|
||||
cy.intercept('GET', url).as(alias);
|
||||
trigger().then(() => {
|
||||
cy.wait(`@${alias}`).then(({ response }) => {
|
||||
expect(response.statusCode).to.equal(200);
|
||||
const isValidType = types.some((type) =>
|
||||
response.headers['content-type'].includes(type),
|
||||
);
|
||||
expect(isValidType).to.be.true;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('validatePdfDownload', (match, trigger) => {
|
||||
cy.window().then((win) => {
|
||||
cy.stub(win, 'open')
|
||||
|
|
Loading…
Reference in New Issue