Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test
gitea/salix-front/pipeline/head This commit looks good Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2024-11-18 10:13:27 +01:00
commit 29239ef2cd
30 changed files with 134 additions and 180 deletions

View File

@ -77,7 +77,7 @@ const isLoading = ref(false);
const hasChanges = ref(false);
const originalData = ref();
const vnPaginateRef = ref();
const formData = ref();
const formData = ref([]);
const saveButtonRef = ref(null);
const watchChanges = ref();
const formUrl = computed(() => $props.url);

View File

@ -25,7 +25,7 @@ const $props = defineProps({
},
searchUrl: {
type: String,
default: 'params',
default: 'table',
},
});

View File

@ -17,7 +17,7 @@ const $props = defineProps({
},
searchUrl: {
type: String,
default: 'params',
default: 'table',
},
vertical: {
type: Boolean,

View File

@ -49,7 +49,7 @@ const $props = defineProps({
},
searchUrl: {
type: String,
default: 'params',
default: 'table',
},
redirect: {
type: Boolean,

View File

@ -44,7 +44,7 @@ const props = defineProps({
},
limit: {
type: Number,
default: 10,
default: 20,
},
userParams: {
type: Object,
@ -100,7 +100,7 @@ const arrayData = useArrayData(props.dataKey, {
const store = arrayData.store;
onMounted(async () => {
if (props.autoLoad) await fetch();
if (props.autoLoad && !store.data?.length) await fetch();
mounted.value = true;
});
@ -115,7 +115,11 @@ watch(
watch(
() => store.data,
(data) => emit('onChange', data)
(data) => {
if (!mounted.value) return;
emit('onChange', data);
},
{ immediate: true }
);
watch(

View File

@ -45,7 +45,7 @@ const props = defineProps({
},
limit: {
type: Number,
default: 10,
default: 20,
},
userParams: {
type: Object,

View File

@ -270,7 +270,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
const pushUrl = { path: to };
if (to.endsWith('/list') || to.endsWith('/'))
pushUrl.query = newUrl.query;
destroy();
else destroy();
return router.push(pushUrl);
}
}

View File

@ -104,7 +104,7 @@ const exprBuilder = (param, value) => {
<template>
<VnSearchbar
data-key="AccountUsers"
data-key="AccountList"
:expr-builder="exprBuilder"
:label="t('account.search')"
:info="t('account.searchInfo')"
@ -112,12 +112,12 @@ const exprBuilder = (param, value) => {
/>
<RightMenu>
<template #right-panel>
<AccountFilter data-key="AccountUsers" />
<AccountFilter data-key="AccountList" />
</template>
</RightMenu>
<VnTable
ref="tableRef"
data-key="AccountUsers"
data-key="AccountList"
url="VnUsers/preview"
:filter="filter"
order="id DESC"

View File

@ -82,14 +82,14 @@ const exprBuilder = (param, value) => {
<template>
<VnSearchbar
data-key="Roles"
data-key="AccountRolesList"
:expr-builder="exprBuilder"
:label="t('role.searchRoles')"
:info="t('role.searchInfo')"
/>
<VnTable
ref="tableRef"
data-key="Roles"
data-key="AccountRolesList"
:url="`VnRoles`"
:create="{
urlCreate: 'VnRoles',

View File

@ -9,7 +9,7 @@ const { t } = useI18n();
<VnCard
data-key="Role"
:descriptor="RoleDescriptor"
search-data-key="AccountRoles"
search-data-key="AccountRolesList"
:searchbar-props="{
url: 'VnRoles',
label: t('role.searchRoles'),

View File

@ -23,7 +23,7 @@ defineExpose({ states });
<template>
<FetchData url="ClaimStates" @on-fetch="(data) => (states = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table">
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -28,7 +28,7 @@ const exprBuilder = (param, value) => {
</script>
<template>
<VnFilterPanel :data-key="dataKey" :search-button="true" search-url="table">
<VnFilterPanel :data-key="dataKey" :search-button="true">
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -394,16 +394,16 @@ function handleLocation(data, location) {
<VnSearchbar
:info="t('You can search by customer id or name')"
:label="t('Search customer')"
data-key="Customer"
data-key="CustomerList"
/>
<RightMenu>
<template #right-panel>
<CustomerFilter data-key="Customer" />
<CustomerFilter data-key="CustomerList" />
</template>
</RightMenu>
<VnTable
ref="tableRef"
data-key="Customer"
data-key="CustomerList"
url="Clients/filter"
:create="{
urlCreate: 'Clients/createWithUser',

View File

@ -122,7 +122,7 @@ const cols = computed(() => [
:columns="cols"
:right-search="false"
:disable-option="{ card: true }"
:auto-load="!!$route.query.params"
:auto-load="!!$route.query.table"
>
<template #column-supplierFk="{ row }">
<span class="link" @click.stop>

View File

@ -182,11 +182,11 @@ watchEffect(selectedRows);
<VnSearchbar
:info="t('youCanSearchByInvoiceReference')"
:label="t('searchInvoice')"
data-key="invoiceOut"
data-key="invoiceOutList"
/>
<RightMenu>
<template #right-panel>
<InvoiceOutFilter data-key="invoiceOut" />
<InvoiceOutFilter data-key="invoiceOutList" />
</template>
</RightMenu>
<VnSubToolbar>
@ -203,7 +203,7 @@ watchEffect(selectedRows);
</VnSubToolbar>
<VnTable
ref="tableRef"
data-key="invoiceOut"
data-key="invoiceOutList"
:url="`${MODEL}/filter`"
:create="{
urlCreate: 'InvoiceOuts/createManualInvoice',

View File

@ -64,8 +64,7 @@ const columns = computed(() => [
},
{
label: t('globals.name'),
field: 'name',
name: 'description',
name: 'name',
...defaultColumnAttrs,
create: true,
cardVisible: true,
@ -426,7 +425,7 @@ function handleOnDataSave({ CrudModelRef }) {
:default-save="false"
data-key="ItemFixedPrices"
url="FixedPrices/filter"
:order="['description DESC']"
:order="['itemFk DESC', 'name DESC']"
save-url="FixedPrices/crud"
:user-params="{ warehouseFk: user.warehouseFk }"
ref="tableRef"
@ -480,7 +479,7 @@ function handleOnDataSave({ CrudModelRef }) {
</template>
</VnSelect>
</template>
<template #column-description="{ row }">
<template #column-name="{ row }">
<span class="link">
{{ row.name }}
</span>

View File

@ -16,12 +16,9 @@ import { useAcl } from 'src/composables/useAcl';
import { useValidator } from 'src/composables/useValidator';
import { toTimeFormat } from 'filters/date.js';
const $props = defineProps({
formData: {
type: Object,
required: true,
default: () => ({}),
},
const formData = defineModel({
type: Object,
required: true,
});
const emit = defineEmits(['updateForm']);
@ -40,7 +37,6 @@ const agenciesOptions = ref([]);
const zonesOptions = ref([]);
const addresses = ref([]);
const zoneSelectRef = ref();
const formData = ref($props.formData);
watch(
() => formData.value,
@ -69,75 +65,44 @@ const zoneWhere = computed(() => {
: {};
});
const getLanded = async (params) => {
try {
const validParams =
shipped.value && addressId.value && agencyModeId.value && warehouseId.value;
if (!validParams) return;
async function getLanded(params) {
getDate(`Agencies/getLanded`, params);
}
formData.value.zoneFk = null;
zonesOptions.value = [];
const { data } = await axios.get(`Agencies/getLanded`, { params });
if (data) {
formData.value.zoneFk = data.zoneFk;
formData.value.landed = data.landed;
formData.value.shipped = params.shipped;
}
} catch (error) {
console.error(error);
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
async function getShipped(params) {
getDate(`Agencies/getShipped`, params);
}
async function getDate(query, params) {
for (const param in params) {
if (!params[param]) return;
}
};
const getShipped = async (params) => {
try {
const validParams =
landed.value && addressId.value && agencyModeId.value && warehouseId.value;
if (!validParams) return;
formData.value.zoneFk = null;
zonesOptions.value = [];
const { data } = await axios.get(query, { params });
if (!data) return notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
formData.value.zoneFk = null;
zonesOptions.value = [];
const { data } = await axios.get(`Agencies/getShipped`, { params });
if (data) {
formData.value.zoneFk = data.zoneFk;
formData.value.landed = params.landed;
formData.value.shipped = data.shipped;
} else {
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
}
} catch (error) {
console.error(error);
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
}
};
formData.value.zoneFk = data.zoneFk;
if (data.landed) formData.value.landed = data.landed;
if (data.shipped) formData.value.shipped = data.shipped;
}
const onChangeZone = async (zoneId) => {
try {
formData.value.agencyModeFk = null;
const { data } = await axios.get(`Zones/${zoneId}`);
formData.value.agencyModeFk = data.agencyModeFk;
} catch (error) {
console.error(error);
}
formData.value.agencyModeFk = null;
const { data } = await axios.get(`Zones/${zoneId}`);
formData.value.agencyModeFk = data.agencyModeFk;
};
const onChangeAddress = async (addressId) => {
try {
formData.value.nickname = null;
const { data } = await axios.get(`Addresses/${addressId}`);
formData.value.nickname = data.nickname;
} catch (error) {
console.error(error);
}
formData.value.nickname = null;
const { data } = await axios.get(`Addresses/${addressId}`);
formData.value.nickname = data.nickname;
};
const getClientDefaultAddress = async (clientId) => {
try {
const { data } = await axios.get(`Clients/${clientId}`);
if (data) addressId.value = data.defaultAddressFk;
} catch (error) {
console.error(error);
}
const { data } = await axios.get(`Clients/${clientId}`);
if (data) addressId.value = data.defaultAddressFk;
};
const clientAddressesList = async (value) => {
@ -189,18 +154,26 @@ const clientId = computed({
},
});
const landed = computed({
get: () => formData.value?.landed,
set: (val) => {
formData.value.landed = val;
getShipped({
landed: val,
function addDateParams(obj) {
return {
...obj,
...{
addressFk: formData.value?.addressFk,
agencyModeFk: formData.value?.agencyModeFk,
warehouseFk: formData.value?.warehouseFk,
});
},
});
},
};
}
async function setLanded(landed) {
if (!landed) return;
getShipped(addDateParams({ landed }));
}
async function setShipped(shipped) {
if (!shipped) return;
getLanded(addDateParams({ shipped }));
}
const agencyModeId = computed({
get: () => formData.value.agencyModeFk,
@ -248,21 +221,6 @@ const warehouseId = computed({
},
});
const shipped = computed({
get: () => formData.value?.shipped,
set: (val) => {
if (new Date(formData.value?.shipped).toDateString() != val.toDateString())
val.setHours(0, 0, 0, 0);
formData.value.shipped = val;
getLanded({
shipped: val,
addressFk: formData.value?.addressFk,
agencyModeFk: formData.value?.agencyModeFk,
warehouseFk: formData.value?.warehouseFk,
});
},
});
const onFormModelInit = () => {
if (formData.value?.clientFk) clientAddressesList(formData.value?.clientFk);
};
@ -463,18 +421,21 @@ async function getZone(options) {
v-model="formData.shipped"
:required="true"
:rules="validate('basicData.shipped')"
@update:model-value="setShipped"
/>
<VnInputTime
:label="t('basicData.shippedHour')"
v-model="formData.shipped"
:required="true"
:rules="validate('basicData.shippedHour')"
@update:model-value="setShipped"
/>
<VnInputDate
:label="t('basicData.landed')"
v-model="formData.landed"
:required="true"
:rules="validate('basicData.landed')"
@update:model-value="setLanded"
/>
</VnRow>
</QForm>

View File

@ -70,60 +70,51 @@ const isFormInvalid = () => {
};
const getPriceDifference = async () => {
try {
const params = {
landed: formData.value.landed,
addressId: formData.value.addressFk,
agencyModeId: formData.value.agencyModeFk,
zoneId: formData.value.zoneFk,
warehouseId: formData.value.warehouseFk,
shipped: formData.value.shipped,
};
const { data } = await axios.post(
`tickets/${formData.value.id}/priceDifference`,
params
);
formData.value.sale = data;
} catch (error) {
console.error(error);
}
const params = {
landed: formData.value.landed,
addressId: formData.value.addressFk,
agencyModeId: formData.value.agencyModeFk,
zoneId: formData.value.zoneFk,
warehouseId: formData.value.warehouseFk,
shipped: formData.value.shipped,
};
const { data } = await axios.post(
`tickets/${formData.value.id}/priceDifference`,
params
);
formData.value.sale = data;
};
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 = {
clientFk: formData.value.clientFk,
nickname: formData.value.nickname,
agencyModeFk: formData.value.agencyModeFk,
addressFk: formData.value.addressFk,
zoneFk: formData.value.zoneFk,
warehouseFk: formData.value.warehouseFk,
companyFk: formData.value.companyFk,
shipped: formData.value.shipped,
landed: formData.value.landed,
isDeleted: formData.value.isDeleted,
option: formData.value.option,
isWithoutNegatives: formData.value.withoutNegatives,
withWarningAccept: formData.value.withWarningAccept,
keepPrice: false,
};
const params = {
clientFk: formData.value.clientFk,
nickname: formData.value.nickname,
agencyModeFk: formData.value.agencyModeFk,
addressFk: formData.value.addressFk,
zoneFk: formData.value.zoneFk,
warehouseFk: formData.value.warehouseFk,
companyFk: formData.value.companyFk,
shipped: formData.value.shipped,
landed: formData.value.landed,
isDeleted: formData.value.isDeleted,
option: formData.value.option,
isWithoutNegatives: formData.value.withoutNegatives,
withWarningAccept: formData.value.withWarningAccept,
keepPrice: false,
};
const { data } = await axios.post(
`tickets/${formData.value.id}/componentUpdate`,
params
);
const { data } = await axios.post(
`tickets/${formData.value.id}/componentUpdate`,
params
);
if (!data) return;
if (!data) return;
const ticketToMove = data.id;
notify(t('basicData.unroutedTicket'), 'positive');
router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
} catch (error) {
console.error(error);
}
const ticketToMove = data.id;
notify(t('basicData.unroutedTicket'), 'positive');
router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
};
const submitWithNegatives = async () => {
@ -167,7 +158,7 @@ onBeforeMount(async () => await getTicketData());
<TicketBasicDataForm
v-if="initialDataLoaded"
@update-form="($event) => (formData = $event)"
:form-data="formData"
v-model="formData"
/>
</QStep>
<QStep :name="2" :title="t('basicData.priceDifference')">

View File

@ -348,7 +348,6 @@ async function hasDocuware() {
}
async function uploadDocuware(force) {
console.log('force: ', force);
if (!force)
return quasar
.dialog({

View File

@ -47,7 +47,7 @@ const getGroupedStates = (data) => {
/>
<FetchData url="AgencyModes" @on-fetch="(data) => (agencies = 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">
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -460,18 +460,18 @@ function setReference(data) {
auto-load
/>
<VnSearchbar
data-key="Ticket"
data-key="TicketList"
:label="t('Search ticket')"
:info="t('You can search by ticket id or alias')"
/>
<RightMenu>
<template #right-panel>
<TicketFilter data-key="Ticket" />
<TicketFilter data-key="TicketList" />
</template>
</RightMenu>
<VnTable
ref="tableRef"
data-key="Ticket"
data-key="TicketList"
url="Tickets/filter"
:create="{
urlCreate: 'Tickets/new',

View File

@ -24,7 +24,7 @@ defineExpose({ states });
<template>
<FetchData url="warehouses" @on-fetch="(data) => (states = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table">
<VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -14,6 +14,7 @@ import WorkerFilter from '../WorkerFilter.vue';
url: 'Workers/filter',
label: 'Search worker',
info: 'You can search by worker id or name',
order: 'id DESC',
}"
:redirect-on-error="true"
/>

View File

@ -69,7 +69,7 @@ function setNotifications(data) {
:default-reset="false"
:default-remove="false"
:default-save="false"
@on-fetch="setNotifications"
@on-fetch="(data) => data && setNotifications(data)"
search-url="notifications"
>
<template #body>

View File

@ -169,7 +169,7 @@ async function autofillBic(worker) {
</script>
<template>
<VnSearchbar
data-key="Worker"
data-key="WorkerList"
:label="t('Search worker')"
:info="t('You can search by worker id or name')"
/>
@ -191,13 +191,13 @@ async function autofillBic(worker) {
/>
<RightMenu>
<template #right-panel>
<WorkerFilter data-key="Worker" />
<WorkerFilter data-key="WorkerList" />
</template>
</RightMenu>
<VnTable
v-if="defaultPayMethod"
ref="tableRef"
data-key="Worker"
data-key="WorkerList"
url="Workers/filter"
:create="{
urlCreate: 'Workers/new',

View File

@ -26,7 +26,7 @@ const exprBuilder = (param, value) => {
<template>
<VnSearchbar
data-key="Zones"
data-key="ZonesList"
url="Zones"
:filter="{
include: { relation: 'agencyMode', scope: { fields: ['name'] } },

View File

@ -32,7 +32,6 @@ const agencies = ref([]);
:data-key="props.dataKey"
:search-button="true"
:hidden-tags="['search']"
search-url="table"
>
<template #tags="{ tag }">
<div class="q-gutter-x-xs">

View File

@ -139,12 +139,12 @@ onMounted(() => (stateStore.rightDrawer = true));
<ZoneSearchbar />
<RightMenu>
<template #right-panel>
<ZoneFilterPanel data-key="Zones" />
<ZoneFilterPanel data-key="ZonesList" />
</template>
</RightMenu>
<VnTable
ref="tableRef"
data-key="Zones"
data-key="ZonesList"
url="Zones"
:create="{
urlCreate: 'Zones',

View File

@ -8,7 +8,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
userFilter: {},
userParams: {},
url: '',
limit: 10,
limit: 20,
skip: 0,
order: '',
isLoading: false,

View File

@ -5,7 +5,7 @@ import { useRouter } from 'vue-router';
import * as vueRouter from 'vue-router';
describe('useArrayData', () => {
const filter = '{"limit":10,"skip":0}';
const filter = '{"limit":20,"skip":0}';
const params = { supplierFk: 2 };
beforeEach(() => {
vi.spyOn(useRouter(), 'replace');