0
0
Fork 0

Compare commits

..

38 Commits

Author SHA1 Message Date
Alex Moreno 6b06ccd3ff feat: refs #6695 run front 2024-10-21 11:45:27 +02:00
Alex Moreno f558c4db87 feat: refs #6695 run front quasar build 2024-10-21 11:38:24 +02:00
Alex Moreno f40e5f6cdf feat: refs #6695 run front 2024-10-21 11:36:41 +02:00
Alex Moreno 358c624511 feat: refs #6695 run front 2024-10-21 11:36:22 +02:00
Alex Moreno c3fa4839c0 feat: refs #6695 run front 2024-10-21 11:34:39 +02:00
Alex Moreno ca2e0cb277 Merge branch 'dev' into 6695-docker_push 2024-10-21 06:59:40 +00:00
Alex Moreno b52b98f3d7 feat(jenkinsE2E): refs #6695 try fix db 2024-10-07 13:56:40 +02:00
Alex Moreno 8985d04d62 feat(jenkinsE2E): refs #6695 try fix db 2024-10-07 13:53:45 +02:00
Alex Moreno e4b709013e feat(jenkinsE2E): refs #6695 try fix db 2024-10-07 13:51:21 +02:00
Alex Moreno f7bc5f5aff feat(jenkinsE2E): refs #6695 new image 2024-10-07 12:26:07 +02:00
Alex Moreno 779bc29a9f feat(jenkinsE2E): refs #6695 new image 2024-10-07 12:01:28 +02:00
Alex Moreno 99d0b0cb98 feat(jenkinsE2E): refs #6695 try new sintax 2024-10-07 11:53:16 +02:00
Alex Moreno 154fc7d79e feat: refs #6695 jenkins run e2e try fix db 2024-10-07 11:42:39 +02:00
Alex Moreno 3013da930d feat: refs #6695 jenkins run e2e try down and rm 2024-10-07 10:46:22 +02:00
Alex Moreno 0f08e151bc feat: refs #6695 jenkins run e2e rebuild 2024-10-07 10:36:11 +02:00
Alex Moreno efcb70e741 feat: refs #6695 jenkins run e2e whitout rebuild 2024-10-07 10:30:46 +02:00
Alex Moreno 422d3428c5 feat: refs #6695 jenkins run e2e rebuild 2024-10-07 10:08:49 +02:00
Alex Moreno 764849ffd8 feat: refs #6695 jenkins run e2e front deteach 2024-10-07 10:02:26 +02:00
Alex Moreno a9fdd8cafd feat: refs #6695 jenkins run e2e remove ports 2024-10-07 09:57:37 +02:00
Alex Moreno d41a6e9142 feat: refs #6695 jenkins run e2e 2024-10-04 13:00:12 +02:00
Alex Moreno 6c5ae8d7e6 feat: refs #6695 jenkins run e2e 2024-10-04 12:56:11 +02:00
Alex Moreno 43f0b72ff8 feat: refs #6695 jenkins run e2e 2024-10-04 12:52:06 +02:00
Alex Moreno 91538acfaf feat: refs #6695 jenkins run e2e 2024-10-04 12:31:43 +02:00
Alex Moreno 8781905cab feat: refs #6695 jenkins run e2e 2024-10-04 12:26:12 +02:00
Alex Moreno 064ce8042b feat: refs #6695 jenkins run e2e 2024-10-04 12:22:12 +02:00
Alex Moreno 04962de8e2 feat: refs #6695 jenkins run e2e 2024-10-04 12:15:10 +02:00
Alex Moreno 7b4d3d45ba feat: refs #6695 jenkins run e2e 2024-10-04 12:13:53 +02:00
Alex Moreno 421ac4b9ac feat: refs #6695 jenkins run e2e 2024-10-04 12:11:45 +02:00
Alex Moreno da61df0a2a feat: refs #6695 jenkins run e2e 2024-10-04 12:08:47 +02:00
Alex Moreno 81cbeff449 feat: refs #6695 run e2e in docker 2024-10-02 15:20:54 +02:00
Alex Moreno 7a1a51711e Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 6695-docker_push 2024-10-02 10:25:29 +02:00
Alex Moreno a42222c5e6 feat: refs #6695 pull salix-back image and use 2024-09-30 14:30:53 +02:00
Alex Moreno a36c52f31a Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 6695-docker_push 2024-09-30 09:13:50 +02:00
Alex Moreno aa682d0ca5 feat: try run salix back 2024-09-20 15:14:38 +02:00
Alex Moreno 316ca6f97e feat: try run salix back 2024-09-20 15:12:20 +02:00
Alex Moreno fdc60b6322 feat: try run salix back 2024-09-20 15:09:55 +02:00
Alex Moreno 5e1d4ea529 feat: try run salix back 2024-09-20 15:08:17 +02:00
Alex Moreno fb20a89e59 feat: docker pull back image 2024-09-12 10:25:12 +02:00
101 changed files with 1264 additions and 1577 deletions

View File

@ -2,5 +2,5 @@ FROM node:stretch-slim
RUN corepack enable pnpm RUN corepack enable pnpm
RUN pnpm install -g @quasar/cli RUN pnpm install -g @quasar/cli
WORKDIR /app WORKDIR /app
COPY dist/spa ./ COPY dist/spa proxy.mjs ./
CMD ["quasar", "serve", "./", "--history", "--hostname", "0.0.0.0"] CMD ["quasar", "serve", "./", "--history", "--hostname", "0.0.0.0"]

44
Dockerfile.e2e Normal file
View File

@ -0,0 +1,44 @@
FROM node:lts-bookworm
ENV SHELL bash
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g pnpm@8.15.1
RUN pnpm setup
RUN pnpm install -g @quasar/cli@2.2.1
RUN apt-get -y --fix-missing update
RUN apt-get -y --fix-missing upgrade
RUN apt-get -y --no-install-recommends install apt-utils
RUN apt-get install --fix-missing -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth xvfb
WORKDIR /app
COPY \
package.json \
.npmrc \
pnpm-lock.yaml \
./
RUN pnpm install
RUN pnpm install cypress
RUN npx cypress install
COPY \
quasar.config.js \
index.html \
jsconfig.json \
quasar.extensions.json \
.eslintignore \
.eslintrc.cjs \
postcss.config.js \
cypress.config.js \
./
COPY src src
COPY test/cypress test/cypress
COPY public public
# RUN npx quasar build
CMD ["npx", "quasar", "dev"]

57
Jenkinsfile vendored
View File

@ -64,15 +64,66 @@ pipeline {
sh 'pnpm install --prefer-offline' sh 'pnpm install --prefer-offline'
} }
} }
stage('Test') { // UNCOMMENT ME!
// stage('Test') {
// when {
// expression { !PROTECTED_BRANCH }
// }
// environment {
// NODE_ENV = ""
// }
// steps {
// sh 'pnpm run test:unit:ci'
// }
// post {
// always {
// junit(
// testResults: 'junitresults.xml',
// allowEmptyResults: true
// )
// }
// }
// }
stage('E2E') {
when { when {
expression { !PROTECTED_BRANCH } expression { !PROTECTED_BRANCH }
} }
environment { environment {
NODE_ENV = "" CREDENTIALS = credentials('docker-registry')
IMAGE = "$REGISTRY/salix-back"
} }
steps { steps {
sh 'pnpm run test:unit:ci' script {
def packageJson = readJSON file: 'package.json'
env.VERSION = "${packageJson.version}-e2e${env.BUILD_ID}"
}
// // sh 'docker pull $IMAGE:dev'
// sh 'git clone https://gitea.verdnatura.es/verdnatura/salix.git'
// // sh 'docker ps -a'
// sh 'docker network create salix_default'
// sh 'docker-compose -f docker-compose.yml build db'
// sh 'docker-compose -f docker-compose.yml up db'
// sh 'docker run --name back $IMAGE:dev'
sh 'rm -rf salix'
sh 'docker-compose down'
sh 'docker-compose rm'
// sh 'docker rm -f back'
// sh 'docker rm -f db'
// sh 'docker rm -f front'
// sh 'docker rm -f e2e'
sh 'git clone --branch dev https://gitea.verdnatura.es/verdnatura/salix.git'
// sh 'cd front'
// sh '# export VERSION=e2e-try'
// sh 'docker build -f salix/back/Dockerfile -t back ./salix'
sh 'quasar build'
sh 'docker-compose -f docker-compose.e2e.yml build front'
sh 'docker-compose -f docker-compose.e2e.yml up front'
// sh 'pnpm i @verdnatura/myt'
// sh 'cd salix && npx myt run -t --ci -d -n front_default'
// // sh 'docker-compose -f docker-compose.e2e.yml up --build db'
// sh 'docker run --net=host -v ./test/cypress/storage:/salix/storage -d back'
// sh 'docker-compose -f docker-compose.e2e.yml up e2e'
} }
post { post {
always { always {

View File

@ -9,7 +9,7 @@ module.exports = defineConfig({
supportFile: 'test/cypress/support/index.js', supportFile: 'test/cypress/support/index.js',
videosFolder: 'test/cypress/videos', videosFolder: 'test/cypress/videos',
video: false, video: false,
specPattern: 'test/cypress/integration/**/*.spec.js', specPattern: 'test/cypress/integration/claim/*.spec.js',
experimentalRunAllSpecs: true, experimentalRunAllSpecs: true,
component: { component: {
componentFolder: 'src', componentFolder: 'src',

12
dind.sh Normal file
View File

@ -0,0 +1,12 @@
docker stop dind-container || true && docker rm dind-container || true
docker run --privileged -d \
-p 2376:2376 \
-e DOCKER_TLS_CERTDIR="" \
--name dind-container \
-v /home/alexm/Projects/salix-front:/front \
docker:dind \
dockerd -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock
docker exec -it dind-container sh

44
docker-compose.e2e.yml Normal file
View File

@ -0,0 +1,44 @@
services:
front:
image: registry.verdnatura.es/salix-frontend:${VERSION:?}
command: quasar serve --history --proxy ./proxy.mjs --hostname localhost --port 9000
build:
context: .
dockerfile: ./Dockerfile
network_mode: host
e2e:
image: registry.verdnatura.es/salix-frontend:${VERSION:?}
command: npx cypress run
build:
context: .
dockerfile: ./Dockerfile.e2e
network_mode: host
# db:
# image: db
# command: npx myt run -t --ci -d -n front_default
# build:
# context: .
# dockerfile: test/cypress/db/Dockerfile
# network_mode: host
# volumes:
# - /var/run/docker.sock:/var/run/docker.sock
# back:
# image: back
# build:
# context: ./salix
# dockerfile: salix/back/Dockerfile
# # depends_on:
# # - db
# ports:
# - 3000:3000
# - 5000:5000
# volumes:
# - ./test/cypress/storage:/salix/storage
# e2e-2:
# image: registry.verdnatura.es/salix-frontend:${VERSION:?}
# command: npx cypress run --config-file test/cypress/configs/cypress.config.2.js
# build:
# context: .
# dockerfile: ./Dockerfile.e2e

View File

@ -1,7 +1,7 @@
version: '3.7' version: '3.7'
services: services:
main: main:
image: registry.verdnatura.es/salix-frontend:${VERSION:?} image: registry.verdnatura.es/salix-frontend:${VERSION:?}
build: build:
context: . context: .
dockerfile: ./Dockerfile dockerfile: ./Dockerfile

13
e2e.sh Normal file
View File

@ -0,0 +1,13 @@
git clone --branch dev https://gitea.verdnatura.es/verdnatura/salix.git
cd front
export VERSION=e2e-try
# docker buildx build -f salix/back/Dockerfile -t back ./salix
# pnpm i @verdnatura/myt
# cd salix && npx myt run -t --ci -d -n front_default
# docker run --net=host -v ./test/cypress/storage:/salix/storage -d back
# docker-compose -f docker-compose.e2e.yml -d up front
# docker-compose -f docker-compose.e2e.yml up e2e --build
docker-compose -f docker-compose.e2e.yml up front --build -d
docker-compose -f docker-compose.e2e.yml up e2e --build

View File

@ -829,8 +829,8 @@ packages:
vue-i18n: vue-i18n:
optional: true optional: true
dependencies: dependencies:
'@intlify/message-compiler': 10.0.0-beta.5 '@intlify/message-compiler': 10.0.0
'@intlify/shared': 10.0.0-beta.5 '@intlify/shared': 10.0.0
jsonc-eslint-parser: 1.4.1 jsonc-eslint-parser: 1.4.1
source-map: 0.6.1 source-map: 0.6.1
vue-i18n: 9.9.1(vue@3.4.19) vue-i18n: 9.9.1(vue@3.4.19)
@ -844,11 +844,11 @@ packages:
'@intlify/message-compiler': 9.9.1 '@intlify/message-compiler': 9.9.1
'@intlify/shared': 9.9.1 '@intlify/shared': 9.9.1
/@intlify/message-compiler@10.0.0-beta.5: /@intlify/message-compiler@10.0.0:
resolution: {integrity: sha512-hLLchnM1dmtSEruerkzvU9vePsLqBXz3RU85SCx/Vd12fFQiymP+/5Rn9MJ8MyfLmIOLDEx4PRh+/GkIQP6oog==} resolution: {integrity: sha512-OcaWc63NC/9p1cMdgoNKBj4d61BH8sUW1Hfs6YijTd9656ZR4rNqXAlRnBrfS5ABq0vjQjpa8VnyvH9hK49yBw==}
engines: {node: '>= 16'} engines: {node: '>= 16'}
dependencies: dependencies:
'@intlify/shared': 10.0.0-beta.5 '@intlify/shared': 10.0.0
source-map-js: 1.0.2 source-map-js: 1.0.2
dev: true dev: true
@ -859,8 +859,8 @@ packages:
'@intlify/shared': 9.9.1 '@intlify/shared': 9.9.1
source-map-js: 1.0.2 source-map-js: 1.0.2
/@intlify/shared@10.0.0-beta.5: /@intlify/shared@10.0.0:
resolution: {integrity: sha512-g9bq5Y1bOcC9qxtNk4UWtF3sXm6Wh0fGISb7vD5aLyF7yQv7ZFjxQjJzBP2GqG/9+PAGYutqjP1GGadNqFtyAQ==} resolution: {integrity: sha512-6ngLfI7DOTew2dcF9WMJx+NnMWghMBhIiHbGg+wRvngpzD5KZJZiJVuzMsUQE1a5YebEmtpTEfUrDp/NqVGdiw==}
engines: {node: '>= 16'} engines: {node: '>= 16'}
dev: true dev: true
@ -884,7 +884,7 @@ packages:
optional: true optional: true
dependencies: dependencies:
'@intlify/bundle-utils': 4.0.0(vue-i18n@9.9.1) '@intlify/bundle-utils': 4.0.0(vue-i18n@9.9.1)
'@intlify/shared': 10.0.0-beta.5 '@intlify/shared': 10.0.0
'@rollup/pluginutils': 4.2.1 '@rollup/pluginutils': 4.2.1
'@vue/compiler-sfc': 3.4.19 '@vue/compiler-sfc': 3.4.19
debug: 4.3.4(supports-color@8.1.1) debug: 4.3.4(supports-color@8.1.1)

6
proxy.mjs Normal file
View File

@ -0,0 +1,6 @@
export default [
{
path: '/api',
rule: { target: 'http://localhost:3000' },
},
];

View File

@ -109,7 +109,7 @@ module.exports = configure(function (/* ctx */) {
}, },
proxy: { proxy: {
'/api': { '/api': {
target: 'http://0.0.0.0:3000', target: 'http://localhost:3000',
logLevel: 'debug', logLevel: 'debug',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,

View File

@ -2,11 +2,9 @@ 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;
@ -17,7 +15,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;
}; };
@ -26,10 +24,10 @@ const onRequestError = (error) => {
}; };
const onResponse = (response) => { const onResponse = (response) => {
const config = response.config; const { method } = response.config;
stateQuery.remove(config);
if (config.method === 'patch') { const isSaveRequest = method === 'patch';
if (isSaveRequest) {
notify('globals.dataSaved', 'positive'); notify('globals.dataSaved', 'positive');
} }
@ -37,9 +35,37 @@ const onResponse = (response) => {
}; };
const onResponseError = (error) => { const onResponseError = (error) => {
stateQuery.remove(error.config); let message = '';
if (session.isLoggedIn() && error.response?.status === 401) { const response = error.response;
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);
@ -48,6 +74,8 @@ const onResponseError = (error) => {
return Promise.reject(error); return Promise.reject(error);
} }
notify(message, 'negative');
return Promise.reject(error); return Promise.reject(error);
}; };

View File

@ -3,51 +3,14 @@ import qFormMixin from './qformMixin';
import mainShortcutMixin from './mainShortcutMixin'; 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.mixin(mainShortcutMixin);
app.directive('shortcut', keyShortcut); app.directive('shortcut', keyShortcut);
app.config.errorHandler = (error) => { app.config.errorHandler = function (err) {
let message; console.error(err);
const response = error.response; notify('globals.error', 'negative', 'error');
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,20 +79,14 @@ async function onProvinceCreated(data) {
watch( watch(
() => [postcodeFormData.countryFk], () => [postcodeFormData.countryFk],
async (newCountryFk, oldValueFk) => { async (newCountryFk, oldValueFk) => {
if (Array.isArray(newCountryFk)) { if (!!oldValueFk[0] && newCountryFk[0] !== oldValueFk[0]) {
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 (oldValueFk !== newCountryFk) { if ((newCountryFk, newCountryFk !== postcodeFormData.countryFk)) {
await provincesFetchDataRef.value.fetch({ await provincesFetchDataRef.value.fetch({
where: { where: {
countryFk: newCountryFk, countryFk: newCountryFk[0],
}, },
}); });
await townsFetchDataRef.value.fetch({ await townsFetchDataRef.value.fetch({
@ -109,12 +103,9 @@ watch(
watch( watch(
() => postcodeFormData.provinceFk, () => postcodeFormData.provinceFk,
async (newProvinceFk) => { async (newProvinceFk) => {
if (Array.isArray(newProvinceFk)) { if (newProvinceFk[0] && newProvinceFk[0] !== postcodeFormData.provinceFk) {
newProvinceFk = newProvinceFk[0];
}
if (newProvinceFk !== postcodeFormData.provinceFk) {
await townsFetchDataRef.value.fetch({ await townsFetchDataRef.value.fetch({
where: { provinceFk: newProvinceFk }, where: { provinceFk: newProvinceFk[0] },
}); });
} }
} }
@ -134,26 +125,16 @@ 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 <FetchData @on-fetch="handleCountries" auto-load url="Countries" />
@on-fetch="handleCountries"
:sort-by="['name ASC']"
:limit="30"
auto-load
url="Countries"
/>
<FormModelPopup <FormModelPopup
url-create="postcodes" url-create="postcodes"
model="postcode" model="postcode"

View File

@ -46,8 +46,6 @@ 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,6 +217,9 @@ 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,7 +61,6 @@ 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')"
@ -71,7 +70,6 @@ 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,7 +3,6 @@ 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';
@ -13,7 +12,6 @@ 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';
@ -52,14 +50,6 @@ 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 } from 'vue'; import { ref, watch } 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

@ -316,7 +316,6 @@ defineExpose({
selected, selected,
CrudModelRef, CrudModelRef,
params, params,
tableRef,
}); });
function handleOnDataSaved(_) { function handleOnDataSaved(_) {
@ -417,7 +416,6 @@ function handleScroll() {
ref="tableRef" 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"
@ -457,11 +455,7 @@ function handleScroll() {
/> />
</template> </template>
<template #header-cell="{ col }"> <template #header-cell="{ col }">
<QTh <QTh v-if="col.visible ?? true">
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'}`"
@ -821,7 +815,6 @@ es:
top: 0; top: 0;
} }
} }
.vnTable { .vnTable {
thead tr th { thead tr th {
position: sticky; position: sticky;
@ -860,9 +853,6 @@ 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

@ -1,19 +0,0 @@
<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

@ -9,6 +9,10 @@ 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,
@ -20,22 +24,30 @@ const emit = defineEmits(['cancel', 'close']);
const dialogRef = ref(null); const dialogRef = ref(null);
const showDialog = defineModel('showDialog', { const _showDialog = computed({
type: Boolean, get: () => $props.showDialog,
default: false, set: (value) => {
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="emit('close')"> <QDialog ref="dialogRef" v-model="_showDialog" @hide="onDialogHide">
<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 v-close-popup /> <QBtn icon="close" flat round dense @click="emit('close')" />
</QCardSection> </QCardSection>
<QCardSection> <QCardSection>
<div class="column"> <div class="column">
@ -68,7 +80,7 @@ const progressLabel = computed(() => `${Math.round($props.progress * 100)}%`);
type="button" type="button"
flat flat
class="text-primary" class="text-primary"
v-close-popup @click="cancel()"
> >
{{ t('globals.cancel') }} {{ t('globals.cancel') }}
</QBtn> </QBtn>

View File

@ -141,7 +141,6 @@ 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

@ -1,33 +0,0 @@
<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

@ -1,55 +0,0 @@
<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

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

View File

@ -304,14 +304,12 @@ 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
errors: errors:
statusUnauthorized: Access denied statusUnauthorized: Access denied
statusInternalServerError: An internal server error has ocurred statusInternalServerError: An internal server error has ocurred
@ -558,6 +556,7 @@ 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

View File

@ -312,10 +312,8 @@ 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
errors: errors:
statusUnauthorized: Acceso denegado statusUnauthorized: Acceso denegado
statusInternalServerError: Ha ocurrido un error interno del servidor statusInternalServerError: Ha ocurrido un error interno del servidor
@ -567,6 +565,7 @@ 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

View File

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

View File

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

View File

@ -46,15 +46,29 @@ const columns = computed(() => [
]); ]);
const deleteSubRole = async (row) => { const deleteSubRole = async (row) => {
await axios.delete(`${urlPath.value}/${row.id}`); try {
fetchSubRoles(); await axios.delete(`${urlPath.value}/${row.id}`);
notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive'); fetchSubRoles();
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) => {
await axios.post(urlPath.value, subRoleFormData); try {
notify(t('Role added! Changes will take a while to fully propagate.'), 'positive'); await axios.post(urlPath.value, subRoleFormData);
fetchSubRoles(); notify(
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('globals.changeState')" :label="t('ticket.summary.changeState')"
> >
<QList> <QList>
<QVirtualScroll <QVirtualScroll

View File

@ -11,7 +11,6 @@ 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();
@ -164,12 +163,14 @@ const fetchEntryBuys = async () => {
data-key="EntrySummary" data-key="EntrySummary"
> >
<template #header-left> <template #header-left>
<VnToSummary <router-link
v-if="route?.name !== 'EntrySummary'" v-if="route?.name !== 'EntrySummary'"
:route-name="'EntrySummary'" :to="{ name: 'EntrySummary', params: { id: entityId } }"
:entity-id="entityId" class="header link"
:url="entryUrl" :href="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>

View File

@ -78,7 +78,7 @@ const ticketsColumns = ref([
align: 'left', align: 'left',
}, },
{ {
name: 'nickname', name: 'quantity',
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-nickname="{ value, row }"> <template #body-cell-quantity="{ value, row }">
<QTd> <QTd>
<QBtn class="no-uppercase link" flat dense> <QBtn class="no-uppercase link" flat dense>
{{ value }} {{ value }}
<CustomerDescriptorProxy :id="row.clientFk" /> <CustomerDescriptorProxy :id="row.id" />
</QBtn> </QBtn>
</QTd> </QTd>
</template> </template>

View File

@ -229,7 +229,7 @@ onBeforeMount(() => {
> >
<template #body-cell-id="{ row }"> <template #body-cell-id="{ row }">
<QTd> <QTd>
<QBtn flat class="link"> {{ row.ticketFk }}</QBtn> <QBtn flat color="primary"> {{ row.ticketFk }}</QBtn>
<TicketDescriptorProxy :id="row.ticketFk" /> <TicketDescriptorProxy :id="row.ticketFk" />
</QTd> </QTd>
</template> </template>
@ -251,35 +251,22 @@ onBeforeMount(() => {
</template> </template>
<template #body-cell-requester="{ row }"> <template #body-cell-requester="{ row }">
<QTd> <QTd>
<QBtn flat dense class="link"> {{ row.requesterName }}</QBtn> <QBtn flat dense color="primary"> {{ row.requesterName }}</QBtn>
<WorkerDescriptorProxy :id="row.requesterFk" /> <WorkerDescriptorProxy :id="row.requesterFk" />
</QTd> </QTd>
</template> </template>
<template #body-cell-attender="{ row }"> <template #body-cell-attender="{ row }">
<QTd> <QTd>
<VnSelect <VnSelect
url="Workers/search"
v-model="row.attenderFk" v-model="row.attenderFk"
:params="{ departmentCodes: ['shopping'] }" :where="{ role: 'buyer' }"
:fields="['id', 'nickname']" sort-by="id"
sort-by="nickname ASC" url="Workers"
hide-selected hide-selected
option-label="nickname" option-label="firstName"
option-value="id" option-value="id"
dense dense
> />
<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>
</QTd> </QTd>
</template> </template>
<template #body-cell-item="{ row }"> <template #body-cell-item="{ row }">
@ -305,7 +292,7 @@ onBeforeMount(() => {
</template> </template>
<template #body-cell-concept="{ row }"> <template #body-cell-concept="{ row }">
<QTd> <QTd>
<QBtn flat dense class="link"> {{ row.itemDescription }}</QBtn> <QBtn flat dense color="primary"> {{ row.itemDescription }}</QBtn>
<ItemDescriptorProxy :id="row.itemFk" /> <ItemDescriptorProxy :id="row.itemFk" />
</QTd> </QTd>
</template> </template>

View File

@ -174,16 +174,6 @@ 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>
@ -284,11 +274,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
@ -301,7 +291,6 @@ 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

@ -52,27 +52,15 @@ const redirectToItemTypeBasicData = (_, { id }) => {
</VnRow> </VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
url="Workers/search"
v-model="data.workerFk" v-model="data.workerFk"
:label="t('shared.worker')" :label="t('itemType.shared.worker')"
sort-by="nickname ASC" url="Workers"
:fields="['id', 'nickname']" sort-by="firstName ASC"
:params="{ departmentCodes: ['shopping'] }" :fields="['id', 'firstName']"
option-label="nickname"
option-value="id" option-value="id"
option-label="firstName"
hide-selected hide-selected
><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('itemType.shared.category')" :label="t('itemType.shared.category')"

View File

@ -41,27 +41,15 @@ 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')"
sort-by="nickname ASC" url="Workers"
:fields="['id', 'nickname']" sort-by="firstName ASC"
:params="{ departmentCodes: ['shopping'] }" :fields="['id', 'firstName']"
option-label="nickname"
option-value="id" option-value="id"
option-label="firstName"
hide-selected hide-selected
><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')"

View File

@ -6,7 +6,6 @@ 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());
@ -56,11 +55,6 @@ 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,7 +12,6 @@ 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';
@ -29,17 +28,14 @@ const { validate } = useValidator();
const { notify } = useNotify(); const { notify } = useNotify();
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const canEditZone = useAcl().hasAny([ const agencyFetchRef = ref(null);
{ model: 'Ticket', props: 'editZone', accessType: 'WRITE' }, const zonesFetchRef = ref(null);
]);
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(
@ -48,8 +44,6 @@ 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',
@ -58,16 +52,18 @@ const agencyByWarehouseFilter = computed(() => ({
}, },
})); }));
const zoneWhere = computed(() => { function zoneWhere() {
return formData.value?.agencyModeFk if (formData?.value?.agencyModeFk) {
? { return formData.value?.agencyModeFk
shipped: formData.value?.shipped, ? {
addressFk: formData.value?.addressFk, shipped: formData.value?.shipped,
agencyModeFk: formData.value?.agencyModeFk, addressFk: formData.value?.addressFk,
warehouseFk: formData.value?.warehouseFk, agencyModeFk: formData.value?.agencyModeFk,
} warehouseFk: formData.value?.warehouseFk,
: {}; }
}); : {};
}
}
const getLanded = async (params) => { const getLanded = async (params) => {
try { try {
@ -112,20 +108,32 @@ const getShipped = async (params) => {
}; };
const onChangeZone = async (zoneId) => { const onChangeZone = async (zoneId) => {
formData.value.agencyModeFk = null; try {
const { data } = await axios.get(`Zones/${zoneId}`); formData.value.agencyModeFk = null;
formData.value.agencyModeFk = data.agencyModeFk; const { data } = await axios.get(`Zones/${zoneId}`);
formData.value.agencyModeFk = data.agencyModeFk;
} catch (error) {
console.error(error);
}
}; };
const onChangeAddress = async (addressId) => { const onChangeAddress = async (addressId) => {
formData.value.nickname = null; try {
const { data } = await axios.get(`Addresses/${addressId}`); formData.value.nickname = null;
formData.value.nickname = data.nickname; const { data } = await axios.get(`Addresses/${addressId}`);
formData.value.nickname = data.nickname;
} catch (error) {
console.error(error);
}
}; };
const getClientDefaultAddress = async (clientId) => { const getClientDefaultAddress = async (clientId) => {
const { data } = await axios.get(`Clients/${clientId}`); try {
if (data) addressId.value = data.defaultAddressFk; const { data } = await axios.get(`Clients/${clientId}`);
if (data) addressId.value = data.defaultAddressFk;
} catch (error) {
console.error(error);
}
}; };
const clientAddressesList = async (value) => { const clientAddressesList = async (value) => {
@ -262,17 +270,7 @@ const redirectToCustomerAddress = () => {
}); });
}; };
async function getZone(options) { onMounted(() => onFormModelInit());
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
@ -418,7 +416,6 @@ async function getZone(options) {
: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"
@ -427,10 +424,11 @@ async function getZone(options) {
:fields="['id', 'name']" :fields="['id', 'name']"
sort-by="id" sort-by="id"
:where="zoneWhere" :where="zoneWhere"
:rules="validate('basicData.zone')" hide-selected
map-options
:required="true" :required="true"
:disable="!canEditZone" @focus="zonesFetchRef.fetch()"
@update:options="getZone" :rules="validate('basicData.zone')"
> >
<template #option="scope"> <template #option="scope">
<QItem v-bind="scope.itemProps"> <QItem v-bind="scope.itemProps">

View File

@ -70,51 +70,60 @@ const isFormInvalid = () => {
}; };
const getPriceDifference = async () => { const getPriceDifference = async () => {
const params = { try {
landed: formData.value.landed, const params = {
addressId: formData.value.addressFk, landed: formData.value.landed,
agencyModeId: formData.value.agencyModeFk, addressId: formData.value.addressFk,
zoneId: formData.value.zoneFk, agencyModeId: formData.value.agencyModeFk,
warehouseId: formData.value.warehouseFk, zoneId: formData.value.zoneFk,
shipped: formData.value.shipped, warehouseId: formData.value.warehouseFk,
}; shipped: formData.value.shipped,
const { data } = await axios.post( };
`tickets/${formData.value.id}/priceDifference`, const { data } = await axios.post(
params `tickets/${formData.value.id}/priceDifference`,
); params
formData.value.sale = data; );
formData.value.sale = data;
} catch (error) {
console.error(error);
}
}; };
const submit = async () => { const submit = async () => {
if (!formData.value.option) return notify(t('basicData.chooseAnOption'), 'negative'); try {
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,20 +34,26 @@ const newTicketFormData = reactive({});
const date = new Date(); const date = new Date();
const createTicket = async () => { const createTicket = async () => {
const expeditionIds = $props.selectedExpeditions.map((expedition) => expedition.id); try {
const params = { const expeditionIds = $props.selectedExpeditions.map(
clientId: $props.ticket.clientFk, (expedition) => expedition.id
landed: newTicketFormData.landed, );
warehouseId: $props.ticket.warehouseFk, const params = {
addressId: $props.ticket.addressFk, clientId: $props.ticket.clientFk,
agencyModeId: $props.ticket.agencyModeFk, landed: newTicketFormData.landed,
routeId: newTicketFormData.routeFk, warehouseId: $props.ticket.warehouseFk,
expeditionIds: expeditionIds, addressId: $props.ticket.addressFk,
}; 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,19 +150,31 @@ const getTotal = computed(() => {
}); });
const getComponentsSum = async () => { const getComponentsSum = async () => {
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`); try {
componentsList.value = data; const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
componentsList.value = data;
} catch (error) {
console.error(error);
}
}; };
const getTheoricalCost = async () => { const getTheoricalCost = async () => {
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`); try {
theoricalCost.value = data; const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
theoricalCost.value = data;
} catch (error) {
console.error(error);
}
}; };
const getTicketVolume = async () => { const getTicketVolume = async () => {
if (!ticketData.value) return; try {
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`); if (!ticketData.value) return;
ticketVolume.value = data[0].volume; const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
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 { useRoute, useRouter } from 'vue-router'; import { 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,7 +23,6 @@ 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();
@ -41,8 +40,6 @@ 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' };
@ -334,49 +331,10 @@ 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) {
console.log('force: ', 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=" :url="`Tickets/${ticketId}/isEditable`"
route.path.startsWith('/ticket')
? `Tickets/${ticketId}/isEditable`
: `Tickets/${ticket}/isEditable`
"
auto-load auto-load
@on-fetch="handleFetchData" @on-fetch="handleFetchData"
/> />
@ -494,13 +452,7 @@ async function uploadDocuware(force) {
<QItemSection side> <QItemSection side>
<QIcon name="keyboard_arrow_right" /> <QIcon name="keyboard_arrow_right" />
</QItemSection> </QItemSection>
<QMenu <QMenu anchor="top end" self="top start" auto-close bordered>
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>
@ -508,14 +460,6 @@ async function uploadDocuware(force) {
<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
@ -534,7 +478,7 @@ async function uploadDocuware(force) {
<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 @click="hasDocuware()"> <QMenu anchor="top end" self="top start" auto-close>
<QList> <QList>
<QItem <QItem
@click="sendDeliveryNoteConfirmation('deliveryNote')" @click="sendDeliveryNoteConfirmation('deliveryNote')"
@ -543,7 +487,11 @@ async function uploadDocuware(force) {
> >
<QItemSection>{{ t('Send PDF') }}</QItemSection> <QItemSection>{{ t('Send PDF') }}</QItemSection>
</QItem> </QItem>
<QItem @click="uploadDocuware(!hasDocuwareFile)" v-ripple clickable> <QItem
@click="sendDeliveryNoteConfirmation('withoutPrices')"
v-ripple
clickable
>
<QItemSection>{{ t('Send PDF to tablet') }}</QItemSection> <QItemSection>{{ t('Send PDF to tablet') }}</QItemSection>
</QItem> </QItem>
<QItem <QItem
@ -747,6 +695,4 @@ 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,21 +13,12 @@ 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');
@ -56,9 +47,6 @@ 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 } from 'vue'; import { onMounted, ref, computed, onUnmounted, watch } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -15,8 +15,6 @@ 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();
@ -25,24 +23,50 @@ 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 vnTableRef = ref(); const tableRef = 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',
@ -163,12 +187,18 @@ const showNewTicketDialog = (withRoute = false) => {
}; };
const deleteExpedition = async () => { const deleteExpedition = async () => {
const expeditionIds = selectedRows.value.map((expedition) => expedition.id); try {
const params = { expeditionIds }; const expeditionIds = selectedExpeditions.value.map(
await axios.post('Expeditions/deleteExpeditions', params); (expedition) => expedition.id
vnTableRef.value.reload(); );
selectedExpeditions.value = []; const params = { expeditionIds };
notify(t('expedition.expeditionRemoved'), 'positive'); await axios.post('Expeditions/deleteExpeditions', params);
await refetchExpeditions();
selectedExpeditions.value = [];
notify(t('expedition.expeditionRemoved'), 'positive');
} catch (error) {
console.error(error);
}
}; };
const showLog = async (expedition) => { const showLog = async (expedition) => {
@ -177,19 +207,29 @@ const showLog = async (expedition) => {
}; };
const getExpeditionState = async (expedition) => { const getExpeditionState = async (expedition) => {
const filter = { try {
where: { expeditionFk: expedition.id }, const filter = {
order: ['created DESC'], where: { expeditionFk: expedition.id },
}; 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) => {
...state, const scannedState = scannedStates.find((s) => s.id === state.id);
isScanned: !!state.isScanned, return {
})); ...state,
isScanned: scannedState ? scannedState.isScanned : false,
};
});
} catch (error) {
console.error(error);
}
}; };
onMounted(async () => { onMounted(async () => {
@ -202,35 +242,9 @@ 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
: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"
@ -284,11 +298,11 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</QBtnGroup> </QBtnGroup>
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<VnTable <VnTable
ref="vnTableRef" ref="tableRef"
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"
@ -297,16 +311,6 @@ 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 }">
@ -320,7 +324,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
<ExpeditionNewTicket <ExpeditionNewTicket
:ticket="ticketData" :ticket="ticketData"
:with-route="newTicketWithRoute" :with-route="newTicketWithRoute"
:selected-expeditions="selectedRows" :selected-expeditions="selectedExpeditions"
/> />
</QDialog> </QDialog>
<QDialog ref="logsTableDialogRef" transition-show="scale" transition-hide="scale"> <QDialog ref="logsTableDialogRef" transition-show="scale" transition-hide="scale">
@ -341,7 +345,11 @@ 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

@ -22,7 +22,6 @@ 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';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
@ -769,8 +768,6 @@ 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
@ -778,9 +775,6 @@ 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>

View File

@ -165,10 +165,14 @@ const createRefund = async (withWarehouse) => {
negative: true, negative: true,
}; };
const { data } = await axios.post('Tickets/cloneAll', params); try {
const [refundTicket] = data; const { data } = await axios.post('Tickets/cloneAll', params);
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive'); const [refundTicket] = data;
push({ name: 'TicketSale', params: { id: refundTicket.id } }); notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
push({ name: 'TicketSale', params: { id: refundTicket.id } });
} catch (error) {
console.error(error);
}
}; };
</script> </script>

View File

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

View File

@ -46,32 +46,40 @@ watch(
onMounted(async () => await getDefaultTaxClass()); onMounted(async () => await getDefaultTaxClass());
const createRefund = async () => { const createRefund = async () => {
if (!selected.value.length) return; try {
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 () => {
let filter = { try {
where: { code: 'G' }, let filter = {
}; where: { code: 'G' },
const { data } = await axios.get('TaxClasses/findOne', { };
params: { filter: JSON.stringify(filter) }, const { data } = await axios.get('TaxClasses/findOne', {
}); 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,8 +19,6 @@ 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();
@ -70,7 +68,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,
@ -87,10 +85,6 @@ 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>
@ -105,14 +99,6 @@ function isOnTicketCard() {
: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 }} ({{
@ -126,7 +112,7 @@ function isOnTicketCard() {
ref="stateBtnDropdownRef" ref="stateBtnDropdownRef"
color="black" color="black"
text-color="white" text-color="white"
:label="t('globals.changeState')" :label="t('ticket.summary.changeState')"
:disable="!isEditable()" :disable="!isEditable()"
> >
<VnSelect <VnSelect

View File

@ -75,18 +75,22 @@ const columns = computed(() => [
]); ]);
const applyVolumes = async (salesData) => { const applyVolumes = async (salesData) => {
if (!salesData.length) return; try {
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,20 +1,24 @@
<script setup> <script setup>
import { ref, computed, reactive, watch } from 'vue'; import { onMounted, ref, computed, reactive } 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 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();
@ -25,58 +29,109 @@ 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 originElRef = ref(null); const exprBuilder = (param, value) => {
const destinationElRef = ref(null); switch (param) {
let today = Date.vnNew().toISOString(); case 'id':
const tomorrow = new Date(today); case 'futureId':
tomorrow.setDate(tomorrow.getDate() + 1); case 'liters':
const userParams = reactive({ case 'futureLiters':
dateFuture: tomorrow, case 'lines':
dateToAdvance: today, case 'futureLines':
warehouseFk: user.value.warehouseFk, case 'totalWithVat':
ipt: 'H', case 'futureTotalWithVat':
futureIpt: 'H', case 'futureZone':
isFullMovable: true, case 'notMovableLines':
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',
hidden: true,
headerClass: 'horizontal-separator',
},
{
align: 'center',
label: t('advanceTickets.ticketId'),
name: 'id',
headerClass: 'horizontal-separator',
},
{
align: 'left', align: 'left',
label: t('advanceTickets.ipt'), columnFilter: null,
name: 'ipt', },
{
label: t('advanceTickets.ticketId'),
name: 'ticketId',
align: 'center',
sortable: true,
columnFilter: { columnFilter: {
component: 'select', component: VnInput,
type: 'text',
filterValue: null,
filterParamKey: 'id',
event: getInputEvents,
attrs: { attrs: {
url: 'itemPackingTypes', dense: true,
fields: ['code', 'description'],
where: { isActive: true },
optionValue: 'code',
optionLabel: 'description',
inWhere: false,
}, },
}, },
format: (row, dashIfEmpty) => dashIfEmpty(row.ipt),
headerClass: 'horizontal-separator',
}, },
{ {
label: t('advanceTickets.ipt'),
name: 'ipt',
field: 'ipt',
align: 'left', align: 'left',
sortable: true,
columnFilter: {
component: VnSelect,
filterParamKey: 'iptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: {
options: itemPackingTypesOptions.value,
'option-value': 'code',
'option-label': 'description',
dense: true,
},
},
format: (val) => dashIfEmpty(val),
},
{
label: t('advanceTickets.state'), label: t('advanceTickets.state'),
name: 'state', name: 'state',
headerClass: 'horizontal-separator', align: 'left',
hidden: true, sortable: true,
columnFilter: null,
}, },
{ {
label: t('advanceTickets.preparation'), label: t('advanceTickets.preparation'),
@ -84,105 +139,171 @@ const ticketColumns = computed(() => [
field: 'preparation', field: 'preparation',
align: 'left', align: 'left',
sortable: true, sortable: true,
headerClass: 'horizontal-separator', columnFilter: null,
columnFilter: false,
}, },
{ {
align: 'left',
label: t('advanceTickets.liters'), label: t('advanceTickets.liters'),
headerClass: 'horizontal-separator',
name: 'liters', name: 'liters',
field: 'liters',
align: 'left',
sortable: true,
columnFilter: {
component: VnInput,
type: 'text',
filterValue: null,
event: getInputEvents,
attrs: {
dense: true,
},
},
}, },
{ {
align: 'left',
label: t('advanceTickets.lines'), label: t('advanceTickets.lines'),
name: 'lines', name: 'lines',
headerClass: 'horizontal-separator', field: 'lines',
format: (row, dashIfEmpty) => dashIfEmpty(row.lines), 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.import'), label: t('advanceTickets.import'),
name: 'totalWithVat', field: 'import',
hidden: true, name: 'import',
headerClass: 'horizontal-separator', align: 'left',
format: (row) => toCurrency(row.totalWithVat), sortable: true,
}, },
{ {
align: 'left',
label: t('advanceTickets.futureId'), label: t('advanceTickets.futureId'),
name: 'futureId', name: 'futureId',
headerClass: 'vertical-separator horizontal-separator', align: 'left',
columnClass: 'vertical-separator', sortable: true,
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: 'select', component: VnSelect,
filterParamKey: 'futureIptColFilter',
type: 'select',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
url: 'itemPackingTypes', options: itemPackingTypesOptions.value,
fields: ['code', 'description'], 'option-value': 'code',
where: { isActive: true }, 'option-label': 'description',
optionValue: 'code', dense: true,
optionLabel: 'description',
}, },
}, },
headerClass: 'horizontal-separator', format: (val) => dashIfEmpty(val),
format: (row, dashIfEmpty) => dashIfEmpty(row.futureIpt),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureState'), label: t('advanceTickets.futureState'),
name: 'futureState', name: 'futureState',
headerClass: 'horizontal-separator', align: 'left',
hidden: true, sortable: 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', align: 'left',
label: t('advanceTickets.futureZone'), sortable: true,
name: 'futureZoneFk',
columnClass: 'expand',
columnFilter: { columnFilter: {
component: 'select', component: VnInput,
inWhere: true, type: 'text',
filterValue: null,
event: getInputEvents,
attrs: { attrs: {
url: 'Zones', dense: true,
fields: ['id', 'name'],
}, },
}, },
columnField: { format: (val) => dashIfEmpty(val),
component: null, },
{
label: t('advanceTickets.futureZone'),
name: 'futureZoneName',
field: 'futureZoneName',
align: 'left',
sortable: true,
columnFilter: {
component: VnSelect,
type: 'select',
filterValue: null,
filterParamKey: 'futureZoneFk',
event: getInputEvents,
attrs: {
options: zonesOptions.value,
'option-value': 'id',
'option-label': 'name',
dense: true,
},
}, },
headerClass: 'horizontal-separator', format: (val) => dashIfEmpty(val),
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),
}, },
{ {
align: 'left',
label: t('advanceTickets.futureImport'), label: t('advanceTickets.futureImport'),
name: 'futureTotalWithVat', name: 'futureImport',
hidden: true, align: 'left',
headerClass: 'horizontal-separator', sortable: true,
format: (row) => toCurrency(row.futureTotalWithVat), columnFilter: null,
}, },
]); ]);
@ -208,7 +329,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: vnTableRef.value.params.dateToAdvance, shipped: userParams.dateToAdvance,
addressFk: ticket.futureAddressFk, addressFk: ticket.futureAddressFk,
agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk, agencyModeFk: ticket.agencyModeFk ?? ticket.futureAgencyModeFk,
warehouseFk: ticket.futureWarehouseFk, warehouseFk: ticket.futureWarehouseFk,
@ -231,7 +352,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: vnTableRef.value.params.dateToAdvance, shipped: userParams.dateToAdvance,
landed: ticket.landed, landed: ticket.landed,
isDeleted: false, isDeleted: false,
isWithoutNegatives, isWithoutNegatives,
@ -243,31 +364,36 @@ const requestComponentUpdate = async (ticket, isWithoutNegatives) => {
}; };
const moveTicketsAdvance = async () => { const moveTicketsAdvance = async () => {
let ticketsToMove = []; try {
for (const ticket of selectedTickets.value) { let ticketsToMove = [];
if (!ticket.id) { for (const ticket of selectedTickets.value) {
try { if (!ticket.id) {
const { query, params } = await requestComponentUpdate(ticket, false); try {
axios.post(query, params); const { query, params } = await requestComponentUpdate(ticket, false);
} catch (e) { axios.post(query, params);
console.error('Error moving ticket', e); } catch (e) {
console.error('Error moving ticket', e);
}
continue;
} }
continue; ticketsToMove.push({
originId: ticket.futureId,
destinationId: ticket.id,
originShipped: ticket.futureShipped,
destinationShipped: ticket.shipped,
workerFk: ticket.workerFk,
});
} }
ticketsToMove.push({
originId: ticket.futureId,
destinationId: ticket.id,
originShipped: ticket.futureShipped,
destinationShipped: ticket.shipped,
workerFk: ticket.workerFk,
});
}
const params = { tickets: ticketsToMove }; const params = { tickets: ticketsToMove };
await axios.post('Tickets/merge', params); await axios.post('Tickets/merge', params);
vnTableRef.value.reload(); arrayData.fetch({ append: false });
selectedTickets.value = []; selectedTickets.value = [];
if (ticketsToMove.length) notify(t('advanceTickets.moveTicketSuccess'), 'positive'); if (ticketsToMove.length)
notify(t('advanceTickets.moveTicketSuccess'), 'positive');
} catch (error) {
console.error('Error moving tickets', error);
}
}; };
const progressLength = ref(0); const progressLength = ref(0);
@ -308,8 +434,10 @@ const splitTickets = async () => {
progressAdd(ticket.futureId); progressAdd(ticket.futureId);
} }
} }
} catch (error) {
console.error('Error splitting tickets', error);
} finally { } finally {
vnTableRef.value.reload(); arrayData.fetch({ append: false });
} }
}; };
@ -327,52 +455,19 @@ const handleCloseProgressDialog = () => {
const handleCancelProgress = () => (cancelProgress.value = true); const handleCancelProgress = () => (cancelProgress.value = true);
watch( onMounted(async () => {
() => vnTableRef.value.tableRef?.$el, let today = Date.vnNew();
($el) => { const tomorrow = new Date(today);
if (!$el) return; tomorrow.setDate(tomorrow.getDate() + 1);
const head = $el.querySelector('thead'); userParams.dateFuture = tomorrow;
const firstRow = $el.querySelector('thead > tr'); userParams.dateToAdvance = today;
userParams.scopeDays = 1;
const newRow = document.createElement('tr'); userParams.warehouseFk = user.value.warehouseFk;
destinationElRef.value = document.createElement('th'); const filter = { limit: 0 };
originElRef.value = document.createElement('th'); await arrayData.addFilter({ filter, userParams });
});
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> </script>
<template> <template>
<FetchData <FetchData
url="itemPackingTypes" url="itemPackingTypes"
@ -393,6 +488,11 @@ watch(
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
@ -436,109 +536,174 @@ watch(
</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">
<VnTable <QTable
data-key="advanceTickets" :rows="tickets"
ref="vnTableRef"
url="Tickets/getTicketsAdvance"
search-url="advanceTickets"
:user-params="userParams"
:limit="0"
:columns="ticketColumns" :columns="ticketColumns"
:table="{ row-key="index"
'row-key': '$index', selection="multiple"
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')"
:right-search="false" style="max-width: 99%"
auto-load
:disable-option="{ card: true }"
> >
<template #column-icons="{ row }"> <template #header="props">
<QIcon {{ userParams.scopeDays }}
v-if="row.futureAgency !== row.agency && row.agency" <QTr :props="props">
color="primary" <QTh
name="vn:agency-term" class="horizontal-separator text-uppercase color-vn-label"
size="xs" colspan="7"
> translate
<QTooltip class="column"> >
<span> {{ t('advanceTickets.destination') }}
{{ {{ toDateFormat(userParams.dateToAdvance) }}
t('advanceTickets.originAgency', { </QTh>
agency: row.futureAgency, <QTh
}) class="horizontal-separator text-uppercase color-vn-label"
}} colspan="9"
</span> translate
<span> >
{{ {{ t('advanceTickets.origin') }}
t('advanceTickets.destinationAgency', { {{ toDateFormat(userParams.dateFuture) }}
agency: row.agency, </QTh>
}) </QTr>
}} <QTr>
</span> <QTh>
</QTooltip> <QCheckbox v-model="props.selected" />
</QIcon> </QTh>
<QTh
v-for="(col, index) in ticketColumns"
:key="index"
:class="{ 'vertical-separator': col.name === 'futureId' }"
>
{{ col.label }}
</QTh>
</QTr>
</template> </template>
<template #column-id="{ row }"> <template #top-row="{ cols }">
<QBtn flat class="link"> <QTr>
{{ row.id }} <QTd />
<TicketDescriptorProxy :id="row.id" /> <QTd
</QBtn> 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>
<template #column-state="{ row }"> <template #header-cell-availableLines="{ col }">
<QBadge <QTh class="vertical-separator">
v-if="row.state" {{ col.label }}
text-color="black" </QTh>
:color="row.classColor"
class="q-ma-none"
dense
>
{{ row.state }}
</QBadge>
<span v-else> {{ dashIfEmpty(row.state) }}</span>
</template> </template>
<template #column-import="{ row }"> <template #body-cell-icons="{ row }">
<QBadge <QTd class="q-gutter-x-xs">
:text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'" <QIcon
:color="totalPriceColor(row.totalWithVat)" v-if="row.futureAgency !== row.agency && row.agency"
class="q-ma-none" color="primary"
dense name="vn:agency-term"
> size="xs"
{{ toCurrency(row.totalWithVat || 0) }} >
</QBadge> <QTooltip class="column">
<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 }">
<QBtn flat class="link" dense> <template #body-cell-ticketId="{ row }">
{{ row.futureId }} <QTd>
<TicketDescriptorProxy :id="row.futureId" /> <QBtn flat class="link">
</QBtn> {{ row.id }}
<TicketDescriptorProxy :id="row.id" />
</QBtn>
</QTd>
</template> </template>
<template #column-futureState="{ row }"> <template #body-cell-state="{ row }">
<QBadge <QTd>
text-color="black" <QBadge
:color="row.futureClassColor" v-if="row.state"
class="q-ma-none" text-color="black"
dense :color="row.classColor"
> class="q-ma-none"
{{ row.futureState }} dense
</QBadge> >
{{ row.state }}
</QBadge>
<span v-else> {{ dashIfEmpty(row.state) }}</span>
</QTd>
</template> </template>
<template #column-futureImport="{ row }"> <template #body-cell-import="{ row }">
<QBadge <QTd>
:text-color="isLessThan50(row.futureTotalWithVat) ? 'black' : 'white'" <QBadge
:color="totalPriceColor(row.futureTotalWithVat)" :text-color="isLessThan50(row.totalWithVat) ? 'black' : 'white'"
class="q-ma-none" :color="totalPriceColor(row.totalWithVat)"
dense class="q-ma-none"
> dense
{{ toCurrency(row.futureTotalWithVat || 0) }} >
</QBadge> {{ toCurrency(row.totalWithVat || 0) }}
</QBadge>
</QTd>
</template> </template>
</VnTable> <template #body-cell-futureId="{ row }">
<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"
@ -557,11 +722,11 @@ watch(
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
:deep(.vertical-separator) { .vertical-separator {
border-left: 4px solid white !important; border-left: 4px solid white !important;
} }
:deep(.horizontal-separator) { .horizontal-separator {
border-top: 4px solid white !important; border-bottom: 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, te } = useI18n(); const { t } = useI18n();
const props = defineProps({ const props = defineProps({
dataKey: { dataKey: {
type: String, type: String,
@ -27,21 +27,20 @@ const warehousesOptions = ref([]);
const itemPackingTypes = ref([]); const itemPackingTypes = ref([]);
const getItemPackingTypes = async () => { const getItemPackingTypes = async () => {
const filter = { try {
where: { isActive: true }, const filter = {
}; where: { isActive: true },
const { data } = await axios.get('ItemPackingTypes', { };
params: { filter: JSON.stringify(filter) }, const { data } = await axios.get('ItemPackingTypes', {
}); params: { filter: JSON.stringify(filter) },
itemPackingTypes.value = data.map((ipt) => ({ });
description: t(ipt.description), itemPackingTypes.value = data.map((ipt) => ({
code: ipt.code, description: t(ipt.description),
})); code: ipt.code,
}; }));
} catch (error) {
const getLocale = (val) => { console.error(error);
const param = `params.${val}`; }
return te(param) ? t(param) : t(`globals.${param}`);
}; };
onMounted(async () => await getItemPackingTypes()); onMounted(async () => await getItemPackingTypes());
@ -54,7 +53,6 @@ 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']"
@ -62,7 +60,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>{{ getLocale(tag.label) }}: </strong> <strong>{{ t(`params.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span> <span>{{ formatFn(tag.value) }}</span>
</div> </div>
</template> </template>
@ -98,7 +96,6 @@ onMounted(async () => await getItemPackingTypes());
dense dense
outlined outlined
rounded rounded
:use-like="false"
> >
</VnSelect> </VnSelect>
</QItemSection> </QItemSection>
@ -116,7 +113,6 @@ onMounted(async () => await getItemPackingTypes());
dense dense
outlined outlined
rounded rounded
:use-like="false"
> >
</VnSelect> </VnSelect>
</QItemSection> </QItemSection>
@ -140,19 +136,6 @@ 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,31 +20,11 @@ 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">
@ -110,35 +90,12 @@ const getGroupedStates = (data) => {
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
@ -157,15 +114,6 @@ const getGroupedStates = (data) => {
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<VnInput
v-model="params.nickname"
:label="t('Nickname')"
is-outlined
/>
</QItemSection>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<QCheckbox <QCheckbox
@ -228,7 +176,6 @@ const getGroupedStates = (data) => {
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
use-input
dense dense
outlined outlined
rounded rounded
@ -249,7 +196,6 @@ const getGroupedStates = (data) => {
option-label="name" option-label="name"
emit-value emit-value
map-options map-options
use-input
dense dense
outlined outlined
rounded rounded
@ -270,22 +216,12 @@ const getGroupedStates = (data) => {
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>
@ -309,11 +245,6 @@ 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
@ -347,12 +278,4 @@ 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,25 +24,33 @@ const itemPackingTypes = ref([]);
const stateOptions = ref([]); const stateOptions = ref([]);
const getItemPackingTypes = async () => { const getItemPackingTypes = async () => {
const filter = { try {
where: { isActive: true }, const filter = {
}; where: { isActive: true },
const { data } = await axios.get('ItemPackingTypes', { };
params: { filter: JSON.stringify(filter) }, const { data } = await axios.get('ItemPackingTypes', {
}); params: { filter: JSON.stringify(filter) },
itemPackingTypes.value = data.map((ipt) => ({ });
description: t(ipt.description), itemPackingTypes.value = data.map((ipt) => ({
code: ipt.code, description: t(ipt.description),
})); code: ipt.code,
}));
} catch (error) {
console.error(error);
}
}; };
const getGroupedStates = async () => { const getGroupedStates = async () => {
const { data } = await axios.get('AlertLevels'); try {
stateOptions.value = data.map((state) => ({ const { data } = await axios.get('AlertLevels');
id: state.id, stateOptions.value = data.map((state) => ({
name: t(`futureTickets.${state.code}`), id: state.id,
code: state.code, name: t(`futureTickets.${state.code}`),
})); code: state.code,
}));
} catch (error) {
console.error(error);
}
}; };
onMounted(async () => { onMounted(async () => {

View File

@ -550,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>
{{ dashIfEmpty(row.userName) }} {{ dashIfEmpty(row.salesPerson) }}
<CustomerDescriptorProxy :id="row.salesPersonFk" /> <CustomerDescriptorProxy :id="row.salesPersonFk" />
</span> </span>
</template> </template>

View File

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

View File

@ -17,11 +17,6 @@ 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);
@ -70,7 +65,7 @@ const handlePhotoUpdated = (evt = false) => {
<CardDescriptor <CardDescriptor
ref="cardDescriptorRef" ref="cardDescriptorRef"
module="Worker" module="Worker"
:data-key="dataKey" data-key="workerData"
url="Workers/descriptor" url="Workers/descriptor"
:filter="{ where: { id: entityId } }" :filter="{ where: { id: entityId } }"
title="user.nickname" title="user.nickname"

View File

@ -12,11 +12,6 @@ const $props = defineProps({
<template> <template>
<QPopupProxy> <QPopupProxy>
<WorkerDescriptor <WorkerDescriptor v-if="$props.id" :id="$props.id" :summary="WorkerSummary" />
v-if="$props.id"
:id="$props.id"
:summary="WorkerSummary"
data-key="workerDescriptorProxy"
/>
</QPopupProxy> </QPopupProxy>
</template> </template>

View File

@ -44,9 +44,8 @@ async function toggleNotification(notification) {
`worker.notificationsManager.${notification.active ? '' : 'un'}subscribed` `worker.notificationsManager.${notification.active ? '' : 'un'}subscribed`
), ),
}); });
} catch (e) { } catch {
notification.active = !notification.active; notification.active = !notification.active;
throw e;
} }
} }

View File

@ -34,13 +34,21 @@ const columns = computed(() => [
]); ]);
const deleteWarehouse = async (row) => { const deleteWarehouse = async (row) => {
await axios.delete(`${urlPath.value}/${row.id}`); try {
fetchWarehouses(); await axios.delete(`${urlPath.value}/${row.id}`);
fetchWarehouses();
} catch (error) {
console.error(error);
}
}; };
const createZoneWarehouse = async (ZoneWarehouseFormData) => { const createZoneWarehouse = async (ZoneWarehouseFormData) => {
await axios.post(urlPath.value, ZoneWarehouseFormData); try {
fetchWarehouses(); await axios.post(urlPath.value, ZoneWarehouseFormData);
fetchWarehouses();
} catch (error) {
console.error(error);
}
}; };
watch( watch(

View File

@ -1,31 +0,0 @@
import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
export const useStateQueryStore = defineStore('stateQueryStore', () => {
const queries = ref(new Set());
function add(query) {
queries.value.add(query);
return query;
}
function isLoading() {
return computed(() => queries.value.size);
}
function remove(query) {
queries.value.delete(query);
}
function reset() {
queries.value = new Set();
}
return {
add,
isLoading,
remove,
queries,
reset,
};
});

View File

@ -1,2 +1,3 @@
videos/* videos/*
screenshots/* screenshots/*
storage/*

View File

@ -0,0 +1,18 @@
FROM node:lts-bookworm
ENV SHELL bash
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN npm install -g pnpm@8.15.1
RUN pnpm setup
RUN apt install libkrb5-dev libssl-dev
RUN npm i -g pnpm
WORKDIR /salix
COPY salix/db db
COPY salix/myt.config.yml .
COPY salix/.git .git
# COPY node_modules node_modules
RUN pnpm i @verdnatura/myt

View File

@ -22,14 +22,12 @@ describe('ClaimPhoto', () => {
}); });
it('should open first image dialog change to second and close', () => { it('should open first image dialog change to second and close', () => {
cy.get( cy.get(':nth-last-child(1) > .q-card').click();
':nth-child(1) > .q-card > .q-img > .q-img__container > .q-img__image'
).click();
cy.get('.q-carousel__slide > .q-img > .q-img__container > .q-img__image').should( cy.get('.q-carousel__slide > .q-img > .q-img__container > .q-img__image').should(
'be.visible' 'be.visible'
); );
cy.get('.q-carousel__control > .q-btn > .q-btn__content > .q-icon').click(); cy.get('.q-carousel__control > button').click();
cy.get( cy.get(
'.q-dialog__inner > .q-toolbar > .q-btn > .q-btn__content > .q-icon' '.q-dialog__inner > .q-toolbar > .q-btn > .q-btn__content > .q-icon'
@ -41,7 +39,7 @@ describe('ClaimPhoto', () => {
it('should remove third and fourth file', () => { it('should remove third and fourth file', () => {
cy.get( cy.get(
'.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon' '.multimediaParent > :nth-last-child(1) > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get( cy.get(
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block' '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
@ -49,7 +47,7 @@ describe('ClaimPhoto', () => {
cy.get('.q-notification__message').should('have.text', 'Data deleted'); cy.get('.q-notification__message').should('have.text', 'Data deleted');
cy.get( cy.get(
'.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon' '.multimediaParent > :nth-last-child(1) > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get( cy.get(
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block' '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client consignee', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/address', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client balance', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/balance', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client basic data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/basic-data', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client billing data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/billing-data', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client credits', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/credits', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client fiscal data', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/fiscal-data', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client greuges', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/greuges', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,63 +0,0 @@
/// <reference types="cypress" />
describe('Client list', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('/#/customer/list', {
timeout: 5000,
onBeforeLoad(win) {
cy.stub(win, 'open');
},
});
});
it('Client list create new client', () => {
cy.get('.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon').click();
const data = {
Name: { val: 'Name 1' },
'Social name': { val: 'TEST 1' },
'Tax number': { val: '20852113Z' },
'Web user': { val: 'user_test_1' },
Street: { val: 'C/ STREET 1' },
Email: { val: 'user.test@1.com' },
'Business type': { val: 'Otros', type: 'select' },
'Sales person': { val: 'salesboss', type: 'select' },
Location: { val: '46000, Valencia(Province one), España', type: 'select' },
};
cy.fillInForm(data);
cy.get('.q-mt-lg > .q-btn--standard').click();
cy.checkNotification('created');
cy.url().should('include', '/summary');
});
it('Client list search client', () => {
const search = 'Jessica Jones';
cy.searchByLabel('Name', search);
cy.get('.title > span').should('have.text', search);
let id = null;
cy.get('.q-item > .q-item__label').then((text) => {
id = text.text().trim().split('#')[1];
cy.get('.q-item > .q-item__label').should('have.text', ` #${id}`);
cy.url().should('include', `/customer/${id}/summary`);
});
});
it('Client founded create ticket', () => {
const search = 'Jessica Jones';
cy.searchByLabel('Name', search);
cy.clickButtonsDescriptor(2);
cy.waitForElement('#formModel');
cy.waitForElement('.q-form');
cy.checkValueForm(1, search);
});
it('Client founded create order', () => {
const search = 'Jessica Jones';
cy.searchByLabel('Name', search);
cy.clickButtonsDescriptor(4);
cy.waitForElement('#formModel');
cy.waitForElement('.q-form');
cy.checkValueForm(2, search);
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client notes', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/notes', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client recoveries', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/recoveries', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client web-access', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/web-access', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client credit opinion', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/credit-management/credit-contracts', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client credit opinion', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/credit-management/credit-opinion', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client consumption', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/others/consumption', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client contacts', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/others/contacts', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client mandates', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/others/mandates', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client samples', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/others/samples', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client unpaid', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1110/others/unpaid', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -1,13 +0,0 @@
/// <reference types="cypress" />
describe('Client web payments', () => {
beforeEach(() => {
cy.viewport(1280, 720);
cy.login('developer');
cy.visit('#/customer/1101/others/web-payments', {
timeout: 5000,
});
});
it('Should load layout', () => {
cy.get('.q-card').should('be.visible');
});
});

View File

@ -13,7 +13,7 @@ describe('Logout', () => {
}); });
describe('not user', () => { describe('not user', () => {
beforeEach(() => { beforeEach(() => {
cy.intercept('GET', '**DefaultViewConfigs**', { cy.intercept('GET', '**/VnUsers/acl', {
statusCode: 401, statusCode: 401,
body: { body: {
error: { error: {
@ -24,11 +24,10 @@ describe('Logout', () => {
}, },
}, },
statusMessage: 'AUTHORIZATION_REQUIRED', statusMessage: 'AUTHORIZATION_REQUIRED',
}); }).as('someRoute');
}); });
it('when token not exists', () => { it('when token not exists', () => {
cy.get('.q-list > [href="#/item"]').click(); cy.reload();
cy.get('.q-notification__message').should( cy.get('.q-notification__message').should(
'have.text', 'have.text',
'Authorization Required' 'Authorization Required'

View File

@ -24,7 +24,7 @@ describe('Recover Password', () => {
it('should change password to user', () => { it('should change password to user', () => {
// Get token from mail // Get token from mail
cy.request( cy.request(
`http://localhost:3000/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN` `/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN`
).then((response) => { ).then((response) => {
const regex = /access_token=([a-zA-Z0-9]+)/; const regex = /access_token=([a-zA-Z0-9]+)/;
const [match] = response.body[0].body.match(regex); const [match] = response.body[0].body.match(regex);

View File

@ -11,7 +11,7 @@ describe('Two Factor', () => {
it('should enable two factor to sysadmin', () => { it('should enable two factor to sysadmin', () => {
cy.request( cy.request(
'PATCH', 'PATCH',
`http://localhost:3000/api/VnUsers/${userId}/update-user?access_token=DEFAULT_TOKEN`, `/api/VnUsers/${userId}/update-user?access_token=DEFAULT_TOKEN`,
{ twoFactor: 'email' } { twoFactor: 'email' }
); );
}); });
@ -41,7 +41,7 @@ describe('Two Factor', () => {
// Get code from mail // Get code from mail
cy.request( cy.request(
`http://localhost:3000/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN` `/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN`
).then((response) => { ).then((response) => {
const tempDiv = document.createElement('div'); const tempDiv = document.createElement('div');
tempDiv.innerHTML = response.body[0].body; tempDiv.innerHTML = response.body[0].body;

View File

@ -7,20 +7,31 @@ describe('AgencyWorkCenter', () => {
const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon'; const createButton = '.q-page-sticky > div > .q-btn > .q-btn__content > .q-icon';
const workCenterCombobox = 'input[role="combobox"]'; const workCenterCombobox = 'input[role="combobox"]';
it('check workCenter crud', () => { it('assign workCenter', () => {
// create
cy.get(createButton).click(); cy.get(createButton).click();
cy.get(workCenterCombobox).type('workCenterOne{enter}'); cy.get(workCenterCombobox).type('workCenterOne{enter}');
cy.hasNotify('Data created'); cy.get('.q-notification__message').should('have.text', 'Data created');
});
// expect error when duplicate it('delete workCenter', () => {
cy.get(createButton).click();
cy.get('[data-cy="FormModelPopup_save"]').click();
cy.hasNotify('This workCenter is already assigned to this agency');
cy.get('[data-cy="FormModelPopup_cancel"]').click();
// delete
cy.get('.q-item__section--side > .q-btn > .q-btn__content > .q-icon').click(); cy.get('.q-item__section--side > .q-btn > .q-btn__content > .q-icon').click();
cy.hasNotify('WorkCenter removed successfully'); cy.get('.q-notification__message').should(
'have.text',
'WorkCenter removed successfully'
);
});
it('error on duplicate workCenter', () => {
cy.get(createButton).click();
cy.get(workCenterCombobox).type('workCenterOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created');
cy.get(createButton).click();
cy.get(
'.vn-row > .q-field > .q-field__inner > .q-field__control > .q-field__control-container'
).type('workCenterOne{enter}');
cy.get(
':nth-child(2) > .q-notification__wrapper > .q-notification__content > .q-notification__message'
).should('have.text', 'This workCenter is already assigned to this agency');
}); });
}); });

View File

@ -1,28 +0,0 @@
/// <reference types="cypress" />
describe('Ticket expedtion', () => {
const tableContent = '.q-table .q-virtual-scroll__content';
const stateTd = 'td:nth-child(9)';
beforeEach(() => {
cy.login('developer');
cy.viewport(1920, 1080);
});
it('should change the state', () => {
cy.visit('#/ticket/1/expedition');
cy.intercept('GET', /\/api\/Expeditions\/filter/).as('expeditions');
cy.intercept('POST', /\/api\/Expeditions\/crud/).as('crud');
cy.wait('@expeditions');
cy.selectRows([1, 2]);
cy.get('#subToolbar [aria-controls]:nth-child(1)').click();
cy.get('.q-menu .q-item').contains('Perdida').click();
cy.wait('@crud');
cy.get(`${tableContent} tr:nth-child(-n+2) ${stateTd}`).each(($el) => {
cy.wrap($el).contains('Perdida');
});
});
});

View File

@ -17,7 +17,10 @@ describe('WorkerNotificationsManager', () => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/worker/${salesPersonId}/notifications`); cy.visit(`/#/worker/${salesPersonId}/notifications`);
cy.get(firstAvailableNotification).click(); cy.get(firstAvailableNotification).click();
cy.hasNotify('The notification subscription of this worker cant be modified'); cy.notificationHas(
'.q-notification__message',
'The notification subscription of this worker cant be modified'
);
}); });
it('should active a notification that is yours', () => { it('should active a notification that is yours', () => {

View File

View File

View File

View File

View File

View File

View File

@ -83,7 +83,7 @@ Cypress.Commands.add('getValue', (selector) => {
Cypress.Commands.add('selectOption', (selector, option) => { Cypress.Commands.add('selectOption', (selector, option) => {
cy.waitForElement(selector); cy.waitForElement(selector);
cy.get(selector).find('.q-select__dropdown-icon').click(); cy.get(selector).find('.q-select__dropdown-icon').click();
cy.get('.q-menu .q-item').contains(option).click(); cy.get('.q-menu .q-item').contains(option).should('be.visible').click();
}); });
Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => { Cypress.Commands.add('fillInForm', (obj, form = '.q-form > .q-card') => {
@ -152,14 +152,6 @@ Cypress.Commands.add('notificationHas', (selector, text) => {
cy.get(selector).should('have.text', text); cy.get(selector).should('have.text', text);
}); });
Cypress.Commands.add('selectRows', (rows) => {
rows.forEach((row) => {
cy.get('.q-table .q-virtual-scroll__content tr .q-checkbox__inner')
.eq(row - 1)
.click();
});
});
Cypress.Commands.add('fillRow', (rowSelector, data) => { Cypress.Commands.add('fillRow', (rowSelector, data) => {
// Usar el selector proporcionado para obtener la fila deseada // Usar el selector proporcionado para obtener la fila deseada
cy.waitForElement('tbody'); cy.waitForElement('tbody');
@ -262,14 +254,3 @@ Cypress.Commands.add('openUserPanel', () => {
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image' '.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image'
).click(); ).click();
}); });
Cypress.Commands.add('hasNotify', (text) => {
//last
cy.get('.q-notification')
.should('be.visible')
.last()
.then(($lastNotification) => {
if (!Cypress.$($lastNotification).text().includes(text))
throw new Error(`Notification not found: "${text}"`);
});
});

View File

@ -15,3 +15,6 @@
import './commands'; import './commands';
Cypress.Screenshot.defaults({
screenshotOnRunFailure: false,
});

View File

@ -7,59 +7,75 @@ vi.mock('src/composables/useSession', () => ({
getToken: () => 'DEFAULT_TOKEN', getToken: () => 'DEFAULT_TOKEN',
isLoggedIn: () => vi.fn(), isLoggedIn: () => vi.fn(),
destroy: () => vi.fn(), destroy: () => vi.fn(),
}), })
}));
vi.mock('src/stores/useStateQueryStore', () => ({
useStateQueryStore: () => ({
add: () => vi.fn(),
remove: () => vi.fn(),
}),
})); }));
describe('Axios boot', () => { describe('Axios boot', () => {
describe('onRequest()', async () => { describe('onRequest()', async () => {
it('should set the "Authorization" property on the headers', async () => { it('should set the "Authorization" property on the headers', async () => {
const config = { headers: {} }; const config = { headers: {} };
const resultConfig = onRequest(config); const resultConfig = onRequest(config);
expect(resultConfig).toEqual( expect(resultConfig).toEqual(expect.objectContaining({
expect.objectContaining({ headers: {
headers: { Authorization: 'DEFAULT_TOKEN'
Authorization: 'DEFAULT_TOKEN', }
}, }));
})
);
}); });
}); })
describe('onResponseError()', async () => { describe('onResponseError()', async () => {
it('should call to the Notify plugin with a message error for an status code "500"', async () => { it('should call to the Notify plugin with a message error for an status code "500"', async () => {
Notify.create = vi.fn()
const error = { const error = {
response: { response: {
status: 500, status: 500
}, }
}; };
const result = onResponseError(error); const result = onResponseError(error);
expect(result).rejects.toEqual(expect.objectContaining(error));
expect(result).rejects.toEqual(
expect.objectContaining(error)
);
expect(Notify.create).toHaveBeenCalledWith(
expect.objectContaining({
message: 'An internal server error has ocurred',
type: 'negative',
})
);
}); });
it('should call to the Notify plugin with a message from the response property', async () => { it('should call to the Notify plugin with a message from the response property', async () => {
Notify.create = vi.fn()
const error = { const error = {
response: { response: {
status: 401, status: 401,
data: { data: {
error: { error: {
message: 'Invalid user or password', message: 'Invalid user or password'
}, }
}, }
}, }
}; };
const result = onResponseError(error); const result = onResponseError(error);
expect(result).rejects.toEqual(expect.objectContaining(error));
expect(result).rejects.toEqual(
expect.objectContaining(error)
);
expect(Notify.create).toHaveBeenCalledWith(
expect.objectContaining({
message: 'Invalid user or password',
type: 'negative',
})
);
}); });
}); })
}); });

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